@aglyn/plugins-ai 1.2.0 → 1.4.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 (83) hide show
  1. package/package.json +17 -17
  2. package/src/lib/components/ai-insight-dialog.component.js +7 -2
  3. package/src/lib/components/ai-insight-dialog.component.js.map +1 -1
  4. package/src/lib/components/ai-job-request.component.d.ts +28 -0
  5. package/src/lib/components/ai-job-request.component.js +103 -0
  6. package/src/lib/components/ai-job-request.component.js.map +1 -0
  7. package/src/lib/components/ai-jobs-list-page.component.d.ts +2 -0
  8. package/src/lib/components/ai-jobs-list-page.component.js +2 -2
  9. package/src/lib/components/ai-jobs-list-page.component.js.map +1 -1
  10. package/src/lib/components/ai-site-build-page.component.js +36 -6
  11. package/src/lib/components/ai-site-build-page.component.js.map +1 -1
  12. package/src/lib/components/ai-site-import-job.component.js +2 -2
  13. package/src/lib/components/ai-site-import-job.component.js.map +1 -1
  14. package/src/lib/insights/ai-insight-digest.d.ts +34 -5
  15. package/src/lib/insights/ai-insight-digest.js +171 -10
  16. package/src/lib/insights/ai-insight-digest.js.map +1 -1
  17. package/src/lib/jobs/ai-job-import-step.d.ts +35 -2
  18. package/src/lib/jobs/ai-job-import-step.js +124 -12
  19. package/src/lib/jobs/ai-job-import-step.js.map +1 -1
  20. package/src/lib/jobs/ai-job-insight-step.d.ts +1 -1
  21. package/src/lib/jobs/ai-job-insight-step.js +5 -1
  22. package/src/lib/jobs/ai-job-insight-step.js.map +1 -1
  23. package/src/lib/jobs/ai-jobs.d.ts +6 -0
  24. package/src/lib/jobs/ai-jobs.js +43 -6
  25. package/src/lib/jobs/ai-jobs.js.map +1 -1
  26. package/src/lib/jobs/ai-layout-stock-photos.d.ts +13 -6
  27. package/src/lib/jobs/ai-layout-stock-photos.js +104 -32
  28. package/src/lib/jobs/ai-layout-stock-photos.js.map +1 -1
  29. package/src/lib/jobs/ai-site-import-compile.js +110 -23
  30. package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
  31. package/src/lib/jobs/ai-site-import-document.d.ts +5 -0
  32. package/src/lib/jobs/ai-site-import-document.js.map +1 -1
  33. package/src/lib/jobs/ai-site-import-forms.d.ts +83 -0
  34. package/src/lib/jobs/ai-site-import-forms.js +376 -0
  35. package/src/lib/jobs/ai-site-import-forms.js.map +1 -0
  36. package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1101-recordings.d.ts +21 -0
  37. package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1101-recordings.js +77 -0
  38. package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-1101-recordings.js.map +1 -0
  39. package/src/lib/layout-language/ai-layout-compiler.d.ts +2 -0
  40. package/src/lib/layout-language/ai-layout-compiler.js +215 -30
  41. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  42. package/src/lib/layout-language/ai-layout-language.d.ts +12 -0
  43. package/src/lib/layout-language/ai-layout-language.js.map +1 -1
  44. package/src/lib/model/ai-credit-estimate.d.ts +25 -22
  45. package/src/lib/model/ai-credit-estimate.js +24 -22
  46. package/src/lib/model/ai-credit-estimate.js.map +1 -1
  47. package/src/lib/model/ai-insight.d.ts +4 -0
  48. package/src/lib/model/ai-insight.js +1 -0
  49. package/src/lib/model/ai-insight.js.map +1 -1
  50. package/src/lib/model/ai-site-build-progress.d.ts +8 -0
  51. package/src/lib/model/ai-site-build-progress.js +62 -1
  52. package/src/lib/model/ai-site-build-progress.js.map +1 -1
  53. package/src/lib/model/ai-site-import-fidelity.d.ts +2 -0
  54. package/src/lib/model/ai-site-import-fidelity.js +41 -5
  55. package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
  56. package/src/lib/model/ai-site-import-report.d.ts +60 -0
  57. package/src/lib/model/ai-site-import-report.js +116 -0
  58. package/src/lib/model/ai-site-import-report.js.map +1 -0
  59. package/src/lib/model/ai-site-import-view.d.ts +7 -1
  60. package/src/lib/model/ai-site-import-view.js +14 -2
  61. package/src/lib/model/ai-site-import-view.js.map +1 -1
  62. package/src/lib/model/ai-site-import.d.ts +49 -2
  63. package/src/lib/model/ai-site-import.js +81 -23
  64. package/src/lib/model/ai-site-import.js.map +1 -1
  65. package/src/lib/plugin.js +1 -1
  66. package/src/lib/plugin.js.map +1 -1
  67. package/src/lib/runtime/ai-insight-check.js +22 -6
  68. package/src/lib/runtime/ai-insight-check.js.map +1 -1
  69. package/src/lib/server/ai-insight-digest-route.js +3 -1
  70. package/src/lib/server/ai-insight-digest-route.js.map +1 -1
  71. package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +4 -0
  72. package/src/lib/site-import/fixtures/site-layout-recordings.js +9 -4
  73. package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
  74. package/src/lib/site-import/site-import-css.d.ts +10 -1
  75. package/src/lib/site-import/site-import-css.js +19 -12
  76. package/src/lib/site-import/site-import-css.js.map +1 -1
  77. package/src/lib/site-import/site-import-html.d.ts +17 -4
  78. package/src/lib/site-import/site-import-html.js +146 -17
  79. package/src/lib/site-import/site-import-html.js.map +1 -1
  80. package/src/lib/site-import/site-import-layout.js +194 -32
  81. package/src/lib/site-import/site-import-layout.js.map +1 -1
  82. package/src/lib/tools/ai-insight-tool.js +11 -3
  83. package/src/lib/tools/ai-insight-tool.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/plugins/ai/src/lib/plugin.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\nimport { PLATFORM_BRAND_NAME, aiAddonName, registerConsoleExtension } from '@aglyn/aglyn'\nimport { LinearProgress } from '@mui/material'\nimport { createElement } from 'react'\nimport { AiAssistProviderOnHost } from './components/ai-assist-provider-on-host.component'\nimport { AI_PLUGIN_ID } from './constants'\nimport { registerAiDeclarations } from './declarations'\nimport { lazyWidget } from './lazy-widget'\n\n/*\n * Every component below is registered by name and loaded the first time the\n * shell draws it (AGL-3649); see `lazyWidget`. The console loads this plugin\n * on every screen, so a static import of a component here is downloaded by\n * every reader of every page, staff cards included.\n */\n\n/** What a page shows while its code arrives. */\nconst PAGE_LOADING = createElement(LinearProgress, { 'aria-label': 'Loading' })\n\nconst AiSaveAsComponent = lazyWidget('AiSaveAsComponent', () =>\n import('./components/ai-save-as-component.component').then(\n (m) => m.AiSaveAsComponent,\n ),\n)\nconst AiGenerateSectionControl = lazyWidget('AiGenerateSectionControl', () =>\n import('./components/besigner-ai-controls.component').then(\n (m) => m.AiGenerateSectionControl,\n ),\n)\nconst AiRewriteControl = lazyWidget('AiRewriteControl', () =>\n import('./components/besigner-ai-controls.component').then(\n (m) => m.AiRewriteControl,\n ),\n)\nconst AssistPanelOnHost = lazyWidget('AssistPanelOnHost', () =>\n import('./components/ai-permissions-on-host.component').then(\n (m) => m.AssistPanelOnHost,\n ),\n)\nconst AiCreditsCard = lazyWidget('AiCreditsCard', () =>\n import('./components/ai-credits-card.component').then((m) => m.default),\n)\nconst AiJobsTopBarIndicator = lazyWidget('AiJobsTopBarIndicator', () =>\n import('./components/ai-jobs-indicator.component').then((m) => m.default),\n)\nconst AiCollaboratorCreditsCell = lazyWidget('AiCollaboratorCreditsCell', () =>\n import('./components/ai-credits-columns.component').then(\n (m) => m.AiCollaboratorCreditsCell,\n ),\n)\nconst AiCollaboratorCreditsHeader = lazyWidget(\n 'AiCollaboratorCreditsHeader',\n () =>\n import('./components/ai-credits-columns.component').then(\n (m) => m.AiCollaboratorCreditsHeader,\n ),\n)\nconst AiMemberCreditsCell = lazyWidget('AiMemberCreditsCell', () =>\n import('./components/ai-credits-columns.component').then(\n (m) => m.AiMemberCreditsCell,\n ),\n)\nconst AiMemberCreditsHeader = lazyWidget('AiMemberCreditsHeader', () =>\n import('./components/ai-credits-columns.component').then(\n (m) => m.AiMemberCreditsHeader,\n ),\n)\nconst AssistSignalsPage = lazyWidget(\n 'AssistSignalsPage',\n () =>\n import('./components/assist-signals-page.component').then(\n (m) => m.AssistSignalsPage,\n ),\n PAGE_LOADING,\n)\nconst BillingAssistOverageCard = lazyWidget('BillingAssistOverageCard', () =>\n import('./components/billing-assist-overage-card.component').then(\n (m) => m.default,\n ),\n)\nconst AiTopUsersCard = lazyWidget('AiTopUsersCard', () =>\n import('./components/billing-ai-top-users.component').then(\n (m) => m.AiTopUsersCard,\n ),\n)\nconst AiAllotmentsCard = lazyWidget('AiAllotmentsCard', () =>\n import('./components/billing-ai-allotments.component').then(\n (m) => m.AiAllotmentsCard,\n ),\n)\nconst AiCollaboratorAllotmentCell = lazyWidget(\n 'AiCollaboratorAllotmentCell',\n () =>\n import('./components/host-ai-allotments.component').then(\n (m) => m.AiCollaboratorAllotmentCell,\n ),\n)\nconst AiCollaboratorAllotmentHeader = lazyWidget(\n 'AiCollaboratorAllotmentHeader',\n () =>\n import('./components/host-ai-allotments.component').then(\n (m) => m.AiCollaboratorAllotmentHeader,\n ),\n)\nconst AiSiteAllotmentCard = lazyWidget('AiSiteAllotmentCard', () =>\n import('./components/host-ai-allotments.component').then(\n (m) => m.AiSiteAllotmentCard,\n ),\n)\nconst MemberAiAllotmentCard = lazyWidget('MemberAiAllotmentCard', () =>\n import('./components/member-ai-allotment-card.component').then(\n (m) => m.default,\n ),\n)\nconst MemberAiUsageCard = lazyWidget('MemberAiUsageCard', () =>\n import('./components/member-ai-usage-card.component').then((m) => m.default),\n)\nconst AiThemeProposalCard = lazyWidget('AiThemeProposalCard', () =>\n import('./components/ai-theme-proposal-card.component').then(\n (m) => m.default,\n ),\n)\nconst StaffOrgAiCard = lazyWidget('StaffOrgAiCard', () =>\n import('./components/staff-org-ai-card.component').then((m) => m.default),\n)\nconst StaffOrgAiConversations = lazyWidget('StaffOrgAiConversations', () =>\n import('./components/staff-org-ai-conversations.component').then((m) => m.default),\n)\nconst StaffOrgUsageAiCreditsCell = lazyWidget(\n 'StaffOrgUsageAiCreditsCell',\n () =>\n import('./components/staff-org-usage-ai-columns.component').then(\n (m) => m.StaffOrgUsageAiCreditsCell,\n ),\n)\nconst StaffOrgUsageAiOverageCell = lazyWidget(\n 'StaffOrgUsageAiOverageCell',\n () =>\n import('./components/staff-org-usage-ai-columns.component').then(\n (m) => m.StaffOrgUsageAiOverageCell,\n ),\n)\nconst StaffOrgUsageAiPool = lazyWidget('StaffOrgUsageAiPool', () =>\n import('./components/staff-org-usage-ai-columns.component').then(\n (m) => m.StaffOrgUsageAiPool,\n ),\n)\nconst StaffOrgUsageAssistCell = lazyWidget('StaffOrgUsageAssistCell', () =>\n import('./components/staff-org-usage-ai-columns.component').then(\n (m) => m.StaffOrgUsageAssistCell,\n ),\n)\nconst StaffOrgsAiSpendCell = lazyWidget('StaffOrgsAiSpendCell', () =>\n import('./components/staff-orgs-ai-spend-column.component').then(\n (m) => m.StaffOrgsAiSpendCell,\n ),\n)\nconst StaffOrgsAiSpendHeader = lazyWidget('StaffOrgsAiSpendHeader', () =>\n import('./components/staff-orgs-ai-spend-column.component').then(\n (m) => m.StaffOrgsAiSpendHeader,\n ),\n)\nconst StaffUserAiUsageCard = lazyWidget('StaffUserAiUsageCard', () =>\n import('./components/staff-user-ai-usage-card.component').then(\n (m) => m.default,\n ),\n)\nconst AiSeoAuditCard = lazyWidget('AiSeoAuditCard', () =>\n import('./components/ai-seo-audit-card.component').then((m) => m.default),\n)\nconst AiSiteBatchCard = lazyWidget('AiSiteBatchCard', () =>\n import('./components/ai-site-batch-card.component').then((m) => m.default),\n)\nconst AiSiteSeoStartCard = lazyWidget('AiSiteSeoStartCard', () =>\n import('./components/ai-site-seo-start-card.component').then(\n (m) => m.default,\n ),\n)\nconst AiSiteMemoryCard = lazyWidget('AiSiteMemoryCard', () =>\n import('./components/ai-site-memory-card.component').then((m) => m.default),\n)\nconst AiSiteStartCard = lazyWidget('AiSiteStartCard', () =>\n import('./components/ai-site-start-card.component').then((m) => m.default),\n)\nconst AiSeoFieldsCard = lazyWidget('AiSeoFieldsCard', () =>\n import('./components/ai-seo-fields-card.component').then((m) => m.default),\n)\nconst AiDescribeAutomationButton = lazyWidget(\n 'AiDescribeAutomationButton',\n () =>\n import('./components/ai-describe-automation.component').then(\n (m) => m.default,\n ),\n)\nconst AiReviseAutomation = lazyWidget('AiReviseAutomation', () =>\n import('./components/ai-revise-automation.component').then((m) => m.default),\n)\nconst AiDescribeOrgAutomationButton = lazyWidget(\n 'AiDescribeOrgAutomationButton',\n () =>\n import('./components/ai-describe-org-automation.component').then(\n (m) => m.default,\n ),\n)\nconst AiInsightHostCard = lazyWidget('AiInsightHostCard', () =>\n import('./components/ai-insight-card.component').then(\n (m) => m.AiInsightHostCard,\n ),\n)\nconst AiInsightOrgCard = lazyWidget('AiInsightOrgCard', () =>\n import('./components/ai-insight-card.component').then(\n (m) => m.AiInsightOrgCard,\n ),\n)\nconst AiLogicCreateButton = lazyWidget('AiLogicCreateButton', () =>\n import('./components/ai-logic.component').then((m) => m.AiLogicCreateButton),\n)\nconst AiLogicFixReference = lazyWidget('AiLogicFixReference', () =>\n import('./components/ai-logic.component').then((m) => m.AiLogicFixReference),\n)\nconst AiLogicFunctionTools = lazyWidget('AiLogicFunctionTools', () =>\n import('./components/ai-logic.component').then((m) => m.AiLogicFunctionTools),\n)\nconst AiFunnelAskButton = lazyWidget('AiFunnelAskButton', () =>\n import('./components/ai-funnel-zones.component').then(\n (m) => m.AiFunnelAskButton,\n ),\n)\nconst AiFunnelCreateButton = lazyWidget('AiFunnelCreateButton', () =>\n import('./components/ai-funnel-zones.component').then(\n (m) => m.AiFunnelCreateButton,\n ),\n)\nconst AiCrmEmailDraft = lazyWidget('AiCrmEmailDraft', () =>\n import('./components/ai-crm-email-draft.component').then((m) => m.default),\n)\nconst AiCrmImportMapping = lazyWidget('AiCrmImportMapping', () =>\n import('./components/ai-crm-import-mapping.component').then((m) => m.default),\n)\nconst AiCrmRecordCard = lazyWidget('AiCrmRecordCard', () =>\n import('./components/ai-crm-record-card.component').then((m) => m.default),\n)\nconst AiDescribePageButton = lazyWidget('AiDescribePageButton', () =>\n import('./components/ai-describe-page.component').then((m) => m.default),\n)\nconst AiMediaCreateButton = lazyWidget('AiMediaCreateButton', () =>\n import('./components/ai-media-create.component').then((m) => m.default),\n)\nconst AiDescribeComponentButton = lazyWidget('AiDescribeComponentButton', () =>\n import('./components/ai-describe-button.component').then(\n (m) => m.AiDescribeComponentButton,\n ),\n)\nconst AiDescribeFormButton = lazyWidget('AiDescribeFormButton', () =>\n import('./components/ai-describe-button.component').then(\n (m) => m.AiDescribeFormButton,\n ),\n)\nconst AiDescribeLayoutButton = lazyWidget('AiDescribeLayoutButton', () =>\n import('./components/ai-describe-button.component').then(\n (m) => m.AiDescribeLayoutButton,\n ),\n)\nconst AiDescribeTemplateButton = lazyWidget('AiDescribeTemplateButton', () =>\n import('./components/ai-describe-button.component').then(\n (m) => m.AiDescribeTemplateButton,\n ),\n)\nconst AiDescribeEmailButton = lazyWidget('AiDescribeEmailButton', () =>\n import('./components/ai-describe-email.component').then(\n (m) => m.AiDescribeEmailButton,\n ),\n)\nconst AiExperimentResultCard = lazyWidget('AiExperimentResultCard', () =>\n import('./components/ai-experiment-cards.component').then(\n (m) => m.AiExperimentResultCard,\n ),\n)\nconst AiExperimentVariantsCard = lazyWidget('AiExperimentVariantsCard', () =>\n import('./components/ai-experiment-cards.component').then(\n (m) => m.AiExperimentVariantsCard,\n ),\n)\nconst AiExplainAutomation = lazyWidget('AiExplainAutomation', () =>\n import('./components/ai-explain-automation.component').then(\n (m) => m.AiExplainAutomation,\n ),\n)\nconst AiExplainRunFailure = lazyWidget('AiExplainRunFailure', () =>\n import('./components/ai-explain-automation.component').then(\n (m) => m.AiExplainRunFailure,\n ),\n)\nconst AiCreateCampaignButton = lazyWidget('AiCreateCampaignButton', () =>\n import('./components/ai-campaign-create.component').then((m) => m.default),\n)\nconst AiMarketingInsightButton = lazyWidget('AiMarketingInsightButton', () =>\n import('./components/ai-marketing-insight.component').then((m) => m.default),\n)\nconst AiCreateOverlayButton = lazyWidget('AiCreateOverlayButton', () =>\n import('./components/ai-overlay-cards.component').then(\n (m) => m.AiCreateOverlayButton,\n ),\n)\nconst AiOverlayEditorCard = lazyWidget('AiOverlayEditorCard', () =>\n import('./components/ai-overlay-cards.component').then(\n (m) => m.AiOverlayEditorCard,\n ),\n)\nconst AiProductCopyCard = lazyWidget('AiProductCopyCard', () =>\n import('./components/ai-product-copy-card.component').then((m) => m.default),\n)\nconst AiProductImportOption = lazyWidget('AiProductImportOption', () =>\n import('./components/ai-product-import-option.component').then(\n (m) => m.default,\n ),\n)\nconst AiProductsHubCard = lazyWidget('AiProductsHubCard', () =>\n import('./components/ai-products-hub-card.component').then((m) => m.default),\n)\nconst AiCreateProductsButton = lazyWidget('AiCreateProductsButton', () =>\n import('./components/ai-products-create-button.component').then(\n (m) => m.default,\n ),\n)\nconst AiJobsPage = lazyWidget(\n 'AiJobsPage',\n () => import('./components/ai-jobs-page.component').then((m) => m.default),\n PAGE_LOADING,\n)\n\n/**\n * The Aglyn AI plugin's console half (AGL-2939): the assistant dock, the\n * besigner copy assistant's provider, the billing, member and staff cards,\n * the member tables' credit columns and the Assist signal staff page — each\n * mounted through a shell-owned zone (AGL-2940) or the staff area's generic\n * route, so no console page imports this plugin.\n *\n * No `featureFlag` on the extension: the plugin's doors are gated one by\n * one — the dock reads the `release_assist` verdict the shell hands it, the\n * generative doors answer 404 behind `release_ai_generative`, the billing\n * cards render only where the plan sells a band — and a flag here would\n * switch off the released doors with the unreleased ones.\n */\nexport function registerAiConsole(): void {\n registerAiDeclarations()\n registerConsoleExtension({\n pluginId: AI_PLUGIN_ID,\n displayName: 'AI',\n // The besigner copy assistant (AGL-89/419): mounted by the shell around\n // every console page, and opened by this plugin's besigner controls.\n providers: [AiAssistProviderOnHost],\n // The Assist docs-gap and cost board (AGL-1860, AGL-2252), at the staff\n // URL and under the tab it has always had.\n staffPages: [\n {\n id: 'assist-signals',\n label: 'Assist signal',\n header: {\n // The configured brand, not ours (AGL-2153/2260): a white-label\n // deployment and a self-host operator both read this header.\n title: `${PLATFORM_BRAND_NAME} Assist Signal`,\n docsTopic: 'assistSignals',\n },\n Component: AssistSignalsPage,\n },\n ],\n // A site's AI jobs (AGL-3596), an address under the site and no tab:\n // `/ai-jobs` lists them, and `/ai-jobs/{jobId}` is one job's page —\n // \"Building your site\" (AGL-3594), where the guided start lands a person\n // and where a site job's notification opens. The `href` is a literal,\n // `AI_SITE_BUILD_HREF`'s value, because the tab-title manifest is read\n // from this source (`ai-jobs-page.spec.tsx` holds the two equal).\n navItems: [\n {\n label: 'AI jobs',\n href: '/ai-jobs',\n recordTitle: 'Building your site',\n header: { title: 'AI jobs', docsTopic: 'aiJobsAndActivity', docsAnchor: '#the-ai-jobs-page' },\n unlisted: true,\n ownsSubtree: true,\n permission: 'ai.generate',\n Component: AiJobsPage,\n },\n ],\n widgets: [\n {\n slot: 'consoleDock',\n widgetId: 'ai-assist-dock',\n title: 'Assistant',\n Component: AssistPanelOnHost,\n },\n // The AI jobs indicator (AGL-3593), beside the notifications bell on\n // every page: what the workspace's jobs are doing, and the way to them.\n // Gated as the other generative widgets are; it asks the shell for the\n // release flags of the jobs and of the panel it opens.\n {\n slot: 'consoleTopBar',\n widgetId: 'ai-jobs-indicator',\n title: 'AI jobs',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n Component: AiJobsTopBarIndicator,\n },\n {\n slot: 'orgBillingUsage',\n widgetId: 'ai-credits-meter',\n title: 'AI credits',\n Component: AiCreditsCard,\n },\n {\n slot: 'orgBillingUsage',\n widgetId: 'ai-credits-overage',\n title: 'AI credits overage',\n Component: BillingAssistOverageCard,\n },\n // The per-member usage (AGL-2928): who drew the credits the meter\n // counts, on Billing → Usage, on each member's page, on the staff\n // user page, and as a column of both member tables.\n {\n slot: 'orgBillingUsage',\n widgetId: 'ai-usage-by-member',\n title: 'Who is generating what',\n permission: 'billing.view',\n Component: AiTopUsersCard,\n },\n // The collaborators table's AI toggles (AGL-2927) are the platform's\n // own per-site Permissions dialog now (AGL-4047), which draws every\n // per-site key, these two included; `/api/ai/host-permissions` stays\n // for the native apps.\n // The copy assistant's besigner controls (AGL-89, AGL-169): Generate a\n // section on every editor's toolbar, and Rewrite with AI under the\n // selected element's fields. Each opens the provider's dialog, and is\n // drawn only while the reader holds the door's permission.\n {\n slot: 'besignerToolbar',\n widgetId: 'ai-generate-section',\n title: 'Generate a section with AI',\n Component: AiGenerateSectionControl,\n },\n {\n slot: 'besignerInspector',\n widgetId: 'ai-rewrite-copy',\n title: 'Rewrite with AI',\n Component: AiRewriteControl,\n },\n // Save the selection as a reusable component (AGL-2908): the component\n // job's second entry point, which proposes the properties a section\n // should declare and applies them as the manual promote does.\n {\n slot: 'besignerInspector',\n widgetId: 'ai-save-as-component',\n title: 'Make a reusable component with AI',\n permission: 'ai.generate',\n Component: AiSaveAsComponent,\n },\n {\n slot: 'orgMember',\n widgetId: 'ai-member-usage',\n title: 'AI usage',\n Component: MemberAiUsageCard,\n },\n // The allotments (AGL-2942): a member's or a site's monthly share of\n // the pool, set on Billing → Usage, on each member's page and on a\n // site's collaborators card — each card asks the route what its\n // reader may see and change.\n {\n slot: 'orgBillingUsage',\n widgetId: 'ai-allotments',\n title: 'AI allotments',\n permission: 'billing.view',\n Component: AiAllotmentsCard,\n },\n {\n slot: 'orgMember',\n widgetId: 'ai-member-allotment',\n title: 'AI allotment',\n Component: MemberAiAllotmentCard,\n },\n {\n slot: 'hostMembers',\n widgetId: 'ai-collaborator-allotment',\n title: 'AI allotment',\n column: {\n header: 'AI allotment',\n align: 'right',\n Header: AiCollaboratorAllotmentHeader,\n },\n Component: AiCollaboratorAllotmentCell,\n },\n {\n slot: 'hostMembers',\n widgetId: 'ai-site-allotment',\n title: 'Site AI allotment',\n Component: AiSiteAllotmentCard,\n },\n // Themes by AI (AGL-2938): a brief on the site's Theme section, a\n // proposal previewed before and after, and the editor's own Save to\n // keep it. Generation is sold as `aiGenerative` and held by\n // `ai.generate`, so the shell withholds the card from a plan or a\n // member without either; the card itself asks the route about the\n // release flag before it shows anything.\n {\n slot: 'hostTheme',\n widgetId: 'ai-theme-proposal',\n title: 'Theme assistant',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n Component: AiThemeProposalCard,\n },\n {\n slot: 'staffOrg',\n widgetId: 'ai-org-usage',\n title: 'AI usage',\n Component: StaffOrgAiCard,\n },\n {\n slot: 'staffOrg',\n widgetId: 'ai-org-conversations',\n title: `${PLATFORM_BRAND_NAME} AI requests`,\n Component: StaffOrgAiConversations,\n },\n {\n slot: 'staffUser',\n widgetId: 'ai-account-usage',\n title: 'AI usage across organizations',\n Component: StaffUserAiUsageCard,\n },\n // The same card for one account, across every org it asked in\n // (AGL-3660); the slot passes `uid`, which puts it in account mode.\n {\n slot: 'staffUser',\n widgetId: 'ai-account-requests',\n title: `${PLATFORM_BRAND_NAME} AI requests`,\n Component: StaffOrgAiConversations,\n },\n // The staff tables' AI figures (AGL-2984): the Organizations list's\n // spend column, and the usage table's three columns with the credit\n // pool line the org page draws above it.\n {\n slot: 'staffOrgsListColumn',\n widgetId: 'ai-orgs-spend',\n title: 'AI spend (month)',\n column: {\n header: 'AI spend (month)',\n align: 'right',\n Header: StaffOrgsAiSpendHeader,\n },\n Component: StaffOrgsAiSpendCell,\n },\n {\n slot: 'staffOrgUsageColumn',\n widgetId: 'ai-usage-assist-cost',\n title: 'Assist',\n column: { header: 'Assist', align: 'right' },\n Component: StaffOrgUsageAssistCell,\n },\n {\n slot: 'staffOrgUsageColumn',\n widgetId: 'ai-usage-credits',\n title: 'AI credits used',\n column: { header: 'AI credits used', align: 'right' },\n Component: StaffOrgUsageAiCreditsCell,\n },\n {\n slot: 'staffOrgUsageColumn',\n widgetId: 'ai-usage-overage',\n title: 'AI overage billed ($)',\n column: { header: 'AI overage billed ($)', align: 'right' },\n Component: StaffOrgUsageAiOverageCell,\n },\n {\n slot: 'staffOrgUsageColumn',\n widgetId: 'ai-usage-pool',\n title: 'AI credit pool',\n Component: StaffOrgUsageAiPool,\n },\n {\n slot: 'orgMembersListColumn',\n widgetId: 'ai-member-credits',\n title: 'AI credits (month)',\n column: { header: 'AI credits (month)', align: 'right', Header: AiMemberCreditsHeader },\n Component: AiMemberCreditsCell,\n },\n {\n slot: 'hostMembers',\n widgetId: 'ai-collaborator-credits',\n title: 'AI credits (site, month)',\n column: {\n header: 'AI credits (site, month)',\n align: 'right',\n Header: AiCollaboratorCreditsHeader,\n },\n Component: AiCollaboratorCreditsCell,\n },\n // SEO by AI (AGL-2910): \"Write SEO\" inside every search listing editor\n // — a page's SEO card and a product's listing — and the site audit on\n // the site's SEO section. Generation is sold as `aiGenerative` and held\n // by `ai.generate`, so the shell withholds both from a plan or a member\n // without either; each card asks the jobs route about the release flag\n // before it shows anything, and neither ever writes what it proposes.\n {\n slot: 'seoFields',\n widgetId: 'ai-seo-fields',\n title: 'SEO assistant',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n Component: AiSeoFieldsCard,\n },\n {\n slot: 'hostSeo',\n widgetId: 'ai-seo-audit',\n title: 'SEO audit',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n Component: AiSeoAuditCard,\n },\n // A page from a brief (AGL-2907): \"Create with AI\" beside Templates and\n // Create New Screen. Gated as the other generative widgets are.\n // On a plan that could buy the AI add-on and has not, each \"Create with\n // AI\" entry here is mounted anyway (`showWhenNotEntitled`) and opens\n // the add-on's dialog instead of the brief (AGL-3601). The shell holds\n // each behind `release_ai_generative` too, so an entry draws at once\n // and asks the jobs route nothing until its brief is sent.\n {\n slot: 'hostScreens',\n widgetId: 'ai-describe-page',\n title: 'Describe a page',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiDescribePageButton,\n },\n // The same entry for a page template, a layout and a form (AGL-3043),\n // beside the create action of the page that lists each: the same\n // dialog and the same gates.\n {\n slot: 'hostTemplates',\n widgetId: 'ai-describe-template',\n title: 'Describe a page template',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiDescribeTemplateButton,\n },\n {\n slot: 'hostLayouts',\n widgetId: 'ai-describe-layout',\n title: 'Describe a layout',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiDescribeLayoutButton,\n },\n {\n slot: 'hostForms',\n widgetId: 'ai-describe-form',\n title: 'Describe a form',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiDescribeFormButton,\n },\n // And a reusable component from a brief (AGL-3051), beside Templates\n // and Create Component: the component job's first entry point, which\n // had none in the console.\n // Pictures from a description (AGL-3602): \"Create with AI\" beside Upload\n // media in the media library, and in its empty state. Gated as the\n // other generative widgets are, by the shell alone: it asks nothing of\n // a server until someone creates a picture, and the door decides then.\n // Like every Create with AI entry it is mounted without the add-on too\n // and opens its own upsell there (AGL-3601).\n {\n slot: 'mediaLibrary',\n widgetId: 'ai-media-create',\n title: 'Create images with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiMediaCreateButton,\n },\n {\n slot: 'hostComponents',\n widgetId: 'ai-describe-component',\n title: 'Describe a reusable component',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiDescribeComponentButton,\n },\n // An email design from a brief (AGL-3596), beside New template on a\n // site's email templates — the zone the email plugin hosts. Its dialog\n // also offers the draft campaign that would send it; the Campaigns\n // section's own door is `ai-create-campaign`, below.\n {\n slot: 'hostEmailTemplates',\n widgetId: 'ai-describe-email',\n title: 'Describe an email',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiDescribeEmailButton,\n },\n // Automations by AI (AGL-2919), in the zones the workflows plugin hosts\n // on its Automation page: \"Create with AI\" beside Add action and Recipes,\n // \"Explain it\" in the editor of a saved automation, and \"Why did this\n // fail?\" on a failed run. Gated as the other generative widgets are,\n // the release flag included, by the shell alone (AGL-3601): none asks\n // the jobs route anything until it is used, and none of them changes an\n // automation.\n {\n slot: 'hostAutomations',\n widgetId: 'ai-describe-automation',\n title: 'Describe an automation',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiDescribeAutomationButton,\n },\n // Funnels by AI (AGL-3605), in the zones the funnels plugin hosts on\n // its card: a draft from a description, and its results explained.\n {\n slot: 'funnelsCreate',\n widgetId: 'ai-describe-funnel',\n title: 'Describe a funnel',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiFunnelCreateButton,\n },\n {\n slot: 'funnelInsight',\n widgetId: 'ai-explain-funnel',\n title: 'Ask AI about this funnel',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiFunnelAskButton,\n },\n {\n slot: 'automationEditor',\n widgetId: 'ai-explain-automation',\n title: 'Explain this automation',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n releaseFlag: 'release_ai_generative',\n Component: AiExplainAutomation,\n },\n // \"Change with AI\" and \"Fix with AI\" in a saved action's editor\n // (AGL-3603): a changed copy drafted OFF beside it, never the saved\n // action written in place.\n {\n slot: 'automationEditor',\n widgetId: 'ai-revise-automation',\n title: 'Change this automation with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n releaseFlag: 'release_ai_generative',\n Component: AiReviseAutomation,\n },\n // \"Create with AI\" on the workspace's Org automations (AGL-3603): one\n // of the workspace's automations drafted from a description and opened\n // in that section's editor, unsaved and switched off.\n {\n slot: 'orgAutomations',\n widgetId: 'ai-describe-org-automation',\n title: 'Describe an org automation',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiDescribeOrgAutomationButton,\n },\n // \"Ask AI about these numbers\" (AGL-3603): a tile on a site's\n // dashboard and Analytics page, which both draw `hostDashboard`, and on\n // the workspace's sites page. It opens the insight dialog the Assist\n // panel opens, gated as every generative widget is.\n {\n slot: 'hostDashboard',\n widgetId: 'ai-insight-ask',\n title: 'Ask AI about these numbers',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiInsightHostCard,\n },\n {\n slot: 'orgDashboard',\n widgetId: 'ai-insight-ask',\n title: 'Ask AI about these numbers',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiInsightOrgCard,\n },\n // Logic by AI (AGL-3603), in the zones the logic plugin hosts on its\n // Functions & Variables page: Create with AI in the Functions and\n // Variables card headers, Explain / Change / Fix in a saved function's\n // editor, and Fix with AI on a broken reference an automation holds.\n // Each proposal opens unsaved in the logic editor; none is saved here.\n {\n slot: 'hostLogic',\n widgetId: 'ai-describe-logic',\n title: 'Describe a function or variable',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiLogicCreateButton,\n },\n {\n slot: 'logicFunctionEditor',\n widgetId: 'ai-logic-function',\n title: 'This function with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n releaseFlag: 'release_ai_generative',\n Component: AiLogicFunctionTools,\n },\n {\n slot: 'logicReferenceIssue',\n widgetId: 'ai-logic-fix-reference',\n title: 'Fix this reference with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n releaseFlag: 'release_ai_generative',\n Component: AiLogicFixReference,\n },\n {\n slot: 'automationRun',\n widgetId: 'ai-explain-run-failure',\n title: 'Why did this run fail?',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n releaseFlag: 'release_ai_generative',\n Component: AiExplainRunFailure,\n },\n // CRM by AI (AGL-2917): a record's summary and next step on its page,\n // a draft in the one-to-one composer, and an import's column matches.\n // The CRM hosts each zone, so it is drawn only where the CRM is; the\n // shell holds the plan and `ai.generate`, each card asks the jobs route\n // about the release flag before it shows anything, and none writes what\n // it proposes.\n {\n slot: 'recordInsights',\n widgetId: 'ai-crm-record',\n title: 'AI summary',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n Component: AiCrmRecordCard,\n },\n {\n slot: 'recordEmail',\n widgetId: 'ai-crm-email',\n title: 'Draft with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n Component: AiCrmEmailDraft,\n },\n {\n slot: 'importMapping',\n widgetId: 'ai-crm-import-mapping',\n title: 'Match columns with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n Component: AiCrmImportMapping,\n },\n // The guided start (AGL-2918), on the page a newly created site lands\n // on: a few questions that become a site scaffold. Gated as the other\n // generative widgets are, and it asks the jobs route about the release\n // flag before it shows anything — so a workspace the feature is not\n // released to gets the blank page and nothing else. Skipping is the\n // zone's own `startBlank`, which creates nothing.\n {\n slot: 'hostFirstRun',\n widgetId: 'ai-site-start',\n title: 'Start this site with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n Component: AiSiteStartCard,\n },\n // The listing those answers describe (AGL-2918), on the site's SEO\n // section: the site-wide search title and description the guided start\n // implies, offered where they are edited. The same gates as every\n // generative widget, and it stages into the SEO form rather than\n // writing it — a person's Update is the write, as it is for the audit\n // card beside it.\n {\n slot: 'hostSeo',\n widgetId: 'ai-site-seo-start',\n title: 'The listing your answers describe',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n Component: AiSiteSeoStartCard,\n },\n // What Aglyn AI learned from the site's applied edits (AGL-3661), on\n // Setup → Business profile, where the owner reads and forgets it. No\n // generate permission: reading and clearing what the AI keeps about a\n // site is every editor's, and the rules hold the write to the server.\n {\n slot: 'hostBusinessProfile',\n widgetId: 'ai-site-memory',\n title: `What ${aiAddonName()} learned`,\n featureFlag: 'aiGenerative',\n Component: AiSiteMemoryCard,\n },\n // The agency batch (AGL-2911): one brief across many of the org's\n // sites, from the page that lists them. The card asks the jobs route\n // about the release flag before it shows anything, and its own door\n // holds the plan band and the caller's permission on every site it is\n // pointed at.\n {\n slot: 'orgSites',\n widgetId: 'ai-site-batch',\n title: 'Generate sites with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n Component: AiSiteBatchCard,\n },\n // Commerce by AI (AGL-2916): product copy in the product editor, the\n // catalog, categories and discounts on the products hub, and copy for\n // an import as it lands. The commerce plugin hosts the zones and makes\n // every write. The shell holds the release flag; the products hub card\n // reads its recent proposals before it draws its own controls, but\n // offers the \"Create with AI\" door's brief from the moment it mounts.\n {\n slot: 'productEditor',\n widgetId: 'ai-product-copy',\n title: 'Product copy assistant',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n Component: AiProductCopyCard,\n },\n {\n slot: 'productsHub',\n widgetId: 'ai-products-hub',\n title: 'Build your catalog with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n releaseFlag: 'release_ai_generative',\n Component: AiProductsHubCard,\n },\n // \"Create with AI\" beside Add product and in the empty catalog\n // (AGL-3596): a door to the card's Propose products brief, shown only\n // while that card is on the page to take it.\n {\n slot: 'productsCreate',\n widgetId: 'ai-products-create',\n title: 'Propose products',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiCreateProductsButton,\n },\n {\n slot: 'productImport',\n widgetId: 'ai-product-import',\n title: 'Write imported product copy with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n Component: AiProductImportOption,\n },\n // A/B tests by AI (AGL-2914): variants written in the experiment\n // editor, and one test's result read in plain words below its figures.\n // The A/B testing card hosts both zones, so they are drawn only where\n // that card is and only on a site with A/B testing; the shell holds the\n // plan band, `ai.generate` and the release flag, and neither card asks\n // the jobs route anything until it is used (AGL-3601). Neither writes: the\n // experiment editor's Save is the only write, and an explanation has\n // nothing to apply.\n {\n slot: 'experimentVariants',\n widgetId: 'ai-experiment-variants',\n title: 'Write variants with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n releaseFlag: 'release_ai_generative',\n Component: AiExperimentVariantsCard,\n },\n {\n slot: 'experimentResult',\n widgetId: 'ai-experiment-result',\n title: 'Explain this result with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n releaseFlag: 'release_ai_generative',\n Component: AiExperimentResultCard,\n },\n // Overlays by AI (AGL-3603), in the zones the marketing plugin's\n // overlays list hosts: \"Create with AI\" beside New bar and New popup,\n // and \"Write with AI\" among the overlay editor's fields. Both start a\n // `text` job asked for overlay copy; neither writes — the list saves a\n // created overlay switched off, and the editor's Save is the write.\n {\n slot: 'hostOverlays',\n widgetId: 'ai-create-overlay',\n title: 'Create an overlay with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiCreateOverlayButton,\n },\n {\n slot: 'overlayEditor',\n widgetId: 'ai-overlay-copy',\n title: 'Write overlay copy with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n releaseFlag: 'release_ai_generative',\n Component: AiOverlayEditorCard,\n },\n // A campaign from a brief (AGL-3603), beside Create campaign on the\n // Campaigns section the marketing plugin hosts: the `campaign` job's\n // first console door, or the `email` job's where the plan sends no\n // campaign email. Both write drafts that are aimed at nobody and sent\n // by nobody until a member does.\n {\n slot: 'hostCampaigns',\n widgetId: 'ai-create-campaign',\n title: 'Create a campaign with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiCreateCampaignButton,\n },\n // The figures in words (AGL-3603), in the header of the Conversions\n // section and of one campaign's report: the insight dialog the Assist\n // panel opens, on the Marketing surface, for the site the figures are.\n // It reads and cites; it changes nothing.\n {\n slot: 'marketingInsights',\n widgetId: 'ai-marketing-insight',\n title: 'Ask AI about these numbers',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiMarketingInsightButton,\n },\n ],\n })\n}\n"],"names":["PLATFORM_BRAND_NAME","aiAddonName","registerConsoleExtension","LinearProgress","createElement","AiAssistProviderOnHost","AI_PLUGIN_ID","registerAiDeclarations","lazyWidget","PAGE_LOADING","AiSaveAsComponent","then","m","AiGenerateSectionControl","AiRewriteControl","AssistPanelOnHost","AiCreditsCard","default","AiJobsTopBarIndicator","AiCollaboratorCreditsCell","AiCollaboratorCreditsHeader","AiMemberCreditsCell","AiMemberCreditsHeader","AssistSignalsPage","BillingAssistOverageCard","AiTopUsersCard","AiAllotmentsCard","AiCollaboratorAllotmentCell","AiCollaboratorAllotmentHeader","AiSiteAllotmentCard","MemberAiAllotmentCard","MemberAiUsageCard","AiThemeProposalCard","StaffOrgAiCard","StaffOrgAiConversations","StaffOrgUsageAiCreditsCell","StaffOrgUsageAiOverageCell","StaffOrgUsageAiPool","StaffOrgUsageAssistCell","StaffOrgsAiSpendCell","StaffOrgsAiSpendHeader","StaffUserAiUsageCard","AiSeoAuditCard","AiSiteBatchCard","AiSiteSeoStartCard","AiSiteMemoryCard","AiSiteStartCard","AiSeoFieldsCard","AiDescribeAutomationButton","AiReviseAutomation","AiDescribeOrgAutomationButton","AiInsightHostCard","AiInsightOrgCard","AiLogicCreateButton","AiLogicFixReference","AiLogicFunctionTools","AiFunnelAskButton","AiFunnelCreateButton","AiCrmEmailDraft","AiCrmImportMapping","AiCrmRecordCard","AiDescribePageButton","AiMediaCreateButton","AiDescribeComponentButton","AiDescribeFormButton","AiDescribeLayoutButton","AiDescribeTemplateButton","AiDescribeEmailButton","AiExperimentResultCard","AiExperimentVariantsCard","AiExplainAutomation","AiExplainRunFailure","AiCreateCampaignButton","AiMarketingInsightButton","AiCreateOverlayButton","AiOverlayEditorCard","AiProductCopyCard","AiProductImportOption","AiProductsHubCard","AiCreateProductsButton","AiJobsPage","registerAiConsole","pluginId","displayName","providers","staffPages","id","label","header","title","docsTopic","Component","navItems","href","recordTitle","docsAnchor","unlisted","ownsSubtree","permission","widgets","slot","widgetId","featureFlag","column","align","Header","showWhenNotEntitled","releaseFlag"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,mBAAmB,EAAEC,WAAW,EAAEC,wBAAwB,QAAQ,eAAc;AACzF,SAASC,cAAc,QAAQ,gBAAe;AAC9C,SAASC,aAAa,QAAQ,QAAO;AACrC,SAASC,sBAAsB,QAAQ,uDAAmD;AAC1F,SAASC,YAAY,QAAQ,iBAAa;AAC1C,SAASC,sBAAsB,QAAQ,oBAAgB;AACvD,SAASC,UAAU,QAAQ,mBAAe;AAE1C;;;;;CAKC,GAED,8CAA8C,GAC9C,MAAMC,eAAeL,cAAcD,gBAAgB;IAAE,cAAc;AAAU;AAE7E,MAAMO,oBAAoBF,WAAW,qBAAqB,IACxD,MAAM,CAAC,kDAA+CG,IAAI,CACxD,CAACC,IAAMA,EAAEF,iBAAiB;AAG9B,MAAMG,2BAA2BL,WAAW,4BAA4B,IACtE,MAAM,CAAC,kDAA+CG,IAAI,CACxD,CAACC,IAAMA,EAAEC,wBAAwB;AAGrC,MAAMC,mBAAmBN,WAAW,oBAAoB,IACtD,MAAM,CAAC,kDAA+CG,IAAI,CACxD,CAACC,IAAMA,EAAEE,gBAAgB;AAG7B,MAAMC,oBAAoBP,WAAW,qBAAqB,IACxD,MAAM,CAAC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YACnE,sEAAsE;YACtE,iCAAiC;YACjC;gBACEyB,MAAM;gBACNC,UAAU;gBACVZ,OAAO;gBACPa,aAAa;gBACbJ,YAAY;gBACZQ,qBAAqB;gBACrBC,aAAa;gBACbhB,WAAWnB;YACb;YACA,oEAAoE;YACpE,sEAAsE;YACtE,uEAAuE;YACvE,0CAA0C;YAC1C;gBACE4B,MAAM;gBACNC,UAAU;gBACVZ,OAAO;gBACPa,aAAa;gBACbJ,YAAY;gBACZQ,qBAAqB;gBACrBC,aAAa;gBACbhB,WAAWlB;YACb;SACD;IACH;AACF"}
1
+ {"version":3,"sources":["../../../../../../libs/plugins/ai/src/lib/plugin.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\nimport { PLATFORM_BRAND_NAME, aiAddonName, registerConsoleExtension } from '@aglyn/aglyn'\nimport { LinearProgress } from '@mui/material'\nimport { createElement } from 'react'\nimport { AiAssistProviderOnHost } from './components/ai-assist-provider-on-host.component'\nimport { AI_PLUGIN_ID } from './constants'\nimport { registerAiDeclarations } from './declarations'\nimport { lazyWidget } from './lazy-widget'\n\n/*\n * Every component below is registered by name and loaded the first time the\n * shell draws it (AGL-3649); see `lazyWidget`. The console loads this plugin\n * on every screen, so a static import of a component here is downloaded by\n * every reader of every page, staff cards included.\n */\n\n/** What a page shows while its code arrives. */\nconst PAGE_LOADING = createElement(LinearProgress, { 'aria-label': 'Loading' })\n\nconst AiSaveAsComponent = lazyWidget('AiSaveAsComponent', () =>\n import('./components/ai-save-as-component.component').then(\n (m) => m.AiSaveAsComponent,\n ),\n)\nconst AiGenerateSectionControl = lazyWidget('AiGenerateSectionControl', () =>\n import('./components/besigner-ai-controls.component').then(\n (m) => m.AiGenerateSectionControl,\n ),\n)\nconst AiRewriteControl = lazyWidget('AiRewriteControl', () =>\n import('./components/besigner-ai-controls.component').then(\n (m) => m.AiRewriteControl,\n ),\n)\nconst AssistPanelOnHost = lazyWidget('AssistPanelOnHost', () =>\n import('./components/ai-permissions-on-host.component').then(\n (m) => m.AssistPanelOnHost,\n ),\n)\nconst AiCreditsCard = lazyWidget('AiCreditsCard', () =>\n import('./components/ai-credits-card.component').then((m) => m.default),\n)\nconst AiJobsTopBarIndicator = lazyWidget('AiJobsTopBarIndicator', () =>\n import('./components/ai-jobs-indicator.component').then((m) => m.default),\n)\nconst AiCollaboratorCreditsCell = lazyWidget('AiCollaboratorCreditsCell', () =>\n import('./components/ai-credits-columns.component').then(\n (m) => m.AiCollaboratorCreditsCell,\n ),\n)\nconst AiCollaboratorCreditsHeader = lazyWidget(\n 'AiCollaboratorCreditsHeader',\n () =>\n import('./components/ai-credits-columns.component').then(\n (m) => m.AiCollaboratorCreditsHeader,\n ),\n)\nconst AiMemberCreditsCell = lazyWidget('AiMemberCreditsCell', () =>\n import('./components/ai-credits-columns.component').then(\n (m) => m.AiMemberCreditsCell,\n ),\n)\nconst AiMemberCreditsHeader = lazyWidget('AiMemberCreditsHeader', () =>\n import('./components/ai-credits-columns.component').then(\n (m) => m.AiMemberCreditsHeader,\n ),\n)\nconst AssistSignalsPage = lazyWidget(\n 'AssistSignalsPage',\n () =>\n import('./components/assist-signals-page.component').then(\n (m) => m.AssistSignalsPage,\n ),\n PAGE_LOADING,\n)\nconst BillingAssistOverageCard = lazyWidget('BillingAssistOverageCard', () =>\n import('./components/billing-assist-overage-card.component').then(\n (m) => m.default,\n ),\n)\nconst AiTopUsersCard = lazyWidget('AiTopUsersCard', () =>\n import('./components/billing-ai-top-users.component').then(\n (m) => m.AiTopUsersCard,\n ),\n)\nconst AiAllotmentsCard = lazyWidget('AiAllotmentsCard', () =>\n import('./components/billing-ai-allotments.component').then(\n (m) => m.AiAllotmentsCard,\n ),\n)\nconst AiCollaboratorAllotmentCell = lazyWidget(\n 'AiCollaboratorAllotmentCell',\n () =>\n import('./components/host-ai-allotments.component').then(\n (m) => m.AiCollaboratorAllotmentCell,\n ),\n)\nconst AiCollaboratorAllotmentHeader = lazyWidget(\n 'AiCollaboratorAllotmentHeader',\n () =>\n import('./components/host-ai-allotments.component').then(\n (m) => m.AiCollaboratorAllotmentHeader,\n ),\n)\nconst AiSiteAllotmentCard = lazyWidget('AiSiteAllotmentCard', () =>\n import('./components/host-ai-allotments.component').then(\n (m) => m.AiSiteAllotmentCard,\n ),\n)\nconst MemberAiAllotmentCard = lazyWidget('MemberAiAllotmentCard', () =>\n import('./components/member-ai-allotment-card.component').then(\n (m) => m.default,\n ),\n)\nconst MemberAiUsageCard = lazyWidget('MemberAiUsageCard', () =>\n import('./components/member-ai-usage-card.component').then((m) => m.default),\n)\nconst AiThemeProposalCard = lazyWidget('AiThemeProposalCard', () =>\n import('./components/ai-theme-proposal-card.component').then(\n (m) => m.default,\n ),\n)\nconst StaffOrgAiCard = lazyWidget('StaffOrgAiCard', () =>\n import('./components/staff-org-ai-card.component').then((m) => m.default),\n)\nconst StaffOrgAiConversations = lazyWidget('StaffOrgAiConversations', () =>\n import('./components/staff-org-ai-conversations.component').then((m) => m.default),\n)\nconst StaffOrgUsageAiCreditsCell = lazyWidget(\n 'StaffOrgUsageAiCreditsCell',\n () =>\n import('./components/staff-org-usage-ai-columns.component').then(\n (m) => m.StaffOrgUsageAiCreditsCell,\n ),\n)\nconst StaffOrgUsageAiOverageCell = lazyWidget(\n 'StaffOrgUsageAiOverageCell',\n () =>\n import('./components/staff-org-usage-ai-columns.component').then(\n (m) => m.StaffOrgUsageAiOverageCell,\n ),\n)\nconst StaffOrgUsageAiPool = lazyWidget('StaffOrgUsageAiPool', () =>\n import('./components/staff-org-usage-ai-columns.component').then(\n (m) => m.StaffOrgUsageAiPool,\n ),\n)\nconst StaffOrgUsageAssistCell = lazyWidget('StaffOrgUsageAssistCell', () =>\n import('./components/staff-org-usage-ai-columns.component').then(\n (m) => m.StaffOrgUsageAssistCell,\n ),\n)\nconst StaffOrgsAiSpendCell = lazyWidget('StaffOrgsAiSpendCell', () =>\n import('./components/staff-orgs-ai-spend-column.component').then(\n (m) => m.StaffOrgsAiSpendCell,\n ),\n)\nconst StaffOrgsAiSpendHeader = lazyWidget('StaffOrgsAiSpendHeader', () =>\n import('./components/staff-orgs-ai-spend-column.component').then(\n (m) => m.StaffOrgsAiSpendHeader,\n ),\n)\nconst StaffUserAiUsageCard = lazyWidget('StaffUserAiUsageCard', () =>\n import('./components/staff-user-ai-usage-card.component').then(\n (m) => m.default,\n ),\n)\nconst AiSeoAuditCard = lazyWidget('AiSeoAuditCard', () =>\n import('./components/ai-seo-audit-card.component').then((m) => m.default),\n)\nconst AiSiteBatchCard = lazyWidget('AiSiteBatchCard', () =>\n import('./components/ai-site-batch-card.component').then((m) => m.default),\n)\nconst AiSiteSeoStartCard = lazyWidget('AiSiteSeoStartCard', () =>\n import('./components/ai-site-seo-start-card.component').then(\n (m) => m.default,\n ),\n)\nconst AiSiteMemoryCard = lazyWidget('AiSiteMemoryCard', () =>\n import('./components/ai-site-memory-card.component').then((m) => m.default),\n)\nconst AiSiteStartCard = lazyWidget('AiSiteStartCard', () =>\n import('./components/ai-site-start-card.component').then((m) => m.default),\n)\nconst AiSeoFieldsCard = lazyWidget('AiSeoFieldsCard', () =>\n import('./components/ai-seo-fields-card.component').then((m) => m.default),\n)\nconst AiDescribeAutomationButton = lazyWidget(\n 'AiDescribeAutomationButton',\n () =>\n import('./components/ai-describe-automation.component').then(\n (m) => m.default,\n ),\n)\nconst AiReviseAutomation = lazyWidget('AiReviseAutomation', () =>\n import('./components/ai-revise-automation.component').then((m) => m.default),\n)\nconst AiDescribeOrgAutomationButton = lazyWidget(\n 'AiDescribeOrgAutomationButton',\n () =>\n import('./components/ai-describe-org-automation.component').then(\n (m) => m.default,\n ),\n)\nconst AiInsightHostCard = lazyWidget('AiInsightHostCard', () =>\n import('./components/ai-insight-card.component').then(\n (m) => m.AiInsightHostCard,\n ),\n)\nconst AiInsightOrgCard = lazyWidget('AiInsightOrgCard', () =>\n import('./components/ai-insight-card.component').then(\n (m) => m.AiInsightOrgCard,\n ),\n)\nconst AiLogicCreateButton = lazyWidget('AiLogicCreateButton', () =>\n import('./components/ai-logic.component').then((m) => m.AiLogicCreateButton),\n)\nconst AiLogicFixReference = lazyWidget('AiLogicFixReference', () =>\n import('./components/ai-logic.component').then((m) => m.AiLogicFixReference),\n)\nconst AiLogicFunctionTools = lazyWidget('AiLogicFunctionTools', () =>\n import('./components/ai-logic.component').then((m) => m.AiLogicFunctionTools),\n)\nconst AiFunnelAskButton = lazyWidget('AiFunnelAskButton', () =>\n import('./components/ai-funnel-zones.component').then(\n (m) => m.AiFunnelAskButton,\n ),\n)\nconst AiFunnelCreateButton = lazyWidget('AiFunnelCreateButton', () =>\n import('./components/ai-funnel-zones.component').then(\n (m) => m.AiFunnelCreateButton,\n ),\n)\nconst AiCrmEmailDraft = lazyWidget('AiCrmEmailDraft', () =>\n import('./components/ai-crm-email-draft.component').then((m) => m.default),\n)\nconst AiCrmImportMapping = lazyWidget('AiCrmImportMapping', () =>\n import('./components/ai-crm-import-mapping.component').then((m) => m.default),\n)\nconst AiCrmRecordCard = lazyWidget('AiCrmRecordCard', () =>\n import('./components/ai-crm-record-card.component').then((m) => m.default),\n)\nconst AiDescribePageButton = lazyWidget('AiDescribePageButton', () =>\n import('./components/ai-describe-page.component').then((m) => m.default),\n)\nconst AiMediaCreateButton = lazyWidget('AiMediaCreateButton', () =>\n import('./components/ai-media-create.component').then((m) => m.default),\n)\nconst AiDescribeComponentButton = lazyWidget('AiDescribeComponentButton', () =>\n import('./components/ai-describe-button.component').then(\n (m) => m.AiDescribeComponentButton,\n ),\n)\nconst AiDescribeFormButton = lazyWidget('AiDescribeFormButton', () =>\n import('./components/ai-describe-button.component').then(\n (m) => m.AiDescribeFormButton,\n ),\n)\nconst AiDescribeLayoutButton = lazyWidget('AiDescribeLayoutButton', () =>\n import('./components/ai-describe-button.component').then(\n (m) => m.AiDescribeLayoutButton,\n ),\n)\nconst AiDescribeTemplateButton = lazyWidget('AiDescribeTemplateButton', () =>\n import('./components/ai-describe-button.component').then(\n (m) => m.AiDescribeTemplateButton,\n ),\n)\nconst AiDescribeEmailButton = lazyWidget('AiDescribeEmailButton', () =>\n import('./components/ai-describe-email.component').then(\n (m) => m.AiDescribeEmailButton,\n ),\n)\nconst AiExperimentResultCard = lazyWidget('AiExperimentResultCard', () =>\n import('./components/ai-experiment-cards.component').then(\n (m) => m.AiExperimentResultCard,\n ),\n)\nconst AiExperimentVariantsCard = lazyWidget('AiExperimentVariantsCard', () =>\n import('./components/ai-experiment-cards.component').then(\n (m) => m.AiExperimentVariantsCard,\n ),\n)\nconst AiExplainAutomation = lazyWidget('AiExplainAutomation', () =>\n import('./components/ai-explain-automation.component').then(\n (m) => m.AiExplainAutomation,\n ),\n)\nconst AiExplainRunFailure = lazyWidget('AiExplainRunFailure', () =>\n import('./components/ai-explain-automation.component').then(\n (m) => m.AiExplainRunFailure,\n ),\n)\nconst AiCreateCampaignButton = lazyWidget('AiCreateCampaignButton', () =>\n import('./components/ai-campaign-create.component').then((m) => m.default),\n)\nconst AiMarketingInsightButton = lazyWidget('AiMarketingInsightButton', () =>\n import('./components/ai-marketing-insight.component').then((m) => m.default),\n)\nconst AiCreateOverlayButton = lazyWidget('AiCreateOverlayButton', () =>\n import('./components/ai-overlay-cards.component').then(\n (m) => m.AiCreateOverlayButton,\n ),\n)\nconst AiOverlayEditorCard = lazyWidget('AiOverlayEditorCard', () =>\n import('./components/ai-overlay-cards.component').then(\n (m) => m.AiOverlayEditorCard,\n ),\n)\nconst AiProductCopyCard = lazyWidget('AiProductCopyCard', () =>\n import('./components/ai-product-copy-card.component').then((m) => m.default),\n)\nconst AiProductImportOption = lazyWidget('AiProductImportOption', () =>\n import('./components/ai-product-import-option.component').then(\n (m) => m.default,\n ),\n)\nconst AiProductsHubCard = lazyWidget('AiProductsHubCard', () =>\n import('./components/ai-products-hub-card.component').then((m) => m.default),\n)\nconst AiCreateProductsButton = lazyWidget('AiCreateProductsButton', () =>\n import('./components/ai-products-create-button.component').then(\n (m) => m.default,\n ),\n)\nconst AiJobsPage = lazyWidget(\n 'AiJobsPage',\n () => import('./components/ai-jobs-page.component').then((m) => m.default),\n PAGE_LOADING,\n)\n\n/**\n * The Aglyn AI plugin's console half (AGL-2939): the assistant dock, the\n * besigner copy assistant's provider, the billing, member and staff cards,\n * the member tables' credit columns and the Assist signal staff page — each\n * mounted through a shell-owned zone (AGL-2940) or the staff area's generic\n * route, so no console page imports this plugin.\n *\n * No `featureFlag` on the extension: the plugin's doors are gated one by\n * one — the dock reads the `release_assist` verdict the shell hands it, the\n * generative doors answer 404 behind `release_ai_generative`, the billing\n * cards render only where the plan sells a band — and a flag here would\n * switch off the released doors with the unreleased ones.\n */\nexport function registerAiConsole(): void {\n registerAiDeclarations()\n registerConsoleExtension({\n pluginId: AI_PLUGIN_ID,\n displayName: 'AI',\n // The besigner copy assistant (AGL-89/419): mounted by the shell around\n // every console page, and opened by this plugin's besigner controls.\n providers: [AiAssistProviderOnHost],\n // The Assist docs-gap and cost board (AGL-1860, AGL-2252), at the staff\n // URL and under the tab it has always had.\n staffPages: [\n {\n id: 'assist-signals',\n label: 'Assist signal',\n header: {\n // The configured brand, not ours (AGL-2153/2260): a white-label\n // deployment and a self-host operator both read this header.\n title: `${PLATFORM_BRAND_NAME} Assist Signal`,\n docsTopic: 'assistSignals',\n },\n Component: AssistSignalsPage,\n },\n ],\n // A site's AI jobs (AGL-3596), an address under the site and no tab:\n // `/ai-jobs` lists them, and `/ai-jobs/{jobId}` is one job's page —\n // \"Building your site\" (AGL-3594), where the guided start lands a person\n // and where a site job's notification opens. The `href` is a literal,\n // `AI_SITE_BUILD_HREF`'s value, because the tab-title manifest is read\n // from this source (`ai-jobs-page.spec.tsx` holds the two equal).\n navItems: [\n {\n label: 'AI jobs',\n href: '/ai-jobs',\n recordTitle: 'AI job',\n header: { title: 'AI jobs', docsTopic: 'aiJobsAndActivity', docsAnchor: '#the-ai-jobs-page' },\n unlisted: true,\n ownsSubtree: true,\n permission: 'ai.generate',\n Component: AiJobsPage,\n },\n ],\n widgets: [\n {\n slot: 'consoleDock',\n widgetId: 'ai-assist-dock',\n title: 'Assistant',\n Component: AssistPanelOnHost,\n },\n // The AI jobs indicator (AGL-3593), beside the notifications bell on\n // every page: what the workspace's jobs are doing, and the way to them.\n // Gated as the other generative widgets are; it asks the shell for the\n // release flags of the jobs and of the panel it opens.\n {\n slot: 'consoleTopBar',\n widgetId: 'ai-jobs-indicator',\n title: 'AI jobs',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n Component: AiJobsTopBarIndicator,\n },\n {\n slot: 'orgBillingUsage',\n widgetId: 'ai-credits-meter',\n title: 'AI credits',\n Component: AiCreditsCard,\n },\n {\n slot: 'orgBillingUsage',\n widgetId: 'ai-credits-overage',\n title: 'AI credits overage',\n Component: BillingAssistOverageCard,\n },\n // The per-member usage (AGL-2928): who drew the credits the meter\n // counts, on Billing → Usage, on each member's page, on the staff\n // user page, and as a column of both member tables.\n {\n slot: 'orgBillingUsage',\n widgetId: 'ai-usage-by-member',\n title: 'Who is generating what',\n permission: 'billing.view',\n Component: AiTopUsersCard,\n },\n // The collaborators table's AI toggles (AGL-2927) are the platform's\n // own per-site Permissions dialog now (AGL-4047), which draws every\n // per-site key, these two included; `/api/ai/host-permissions` stays\n // for the native apps.\n // The copy assistant's besigner controls (AGL-89, AGL-169): Generate a\n // section on every editor's toolbar, and Rewrite with AI under the\n // selected element's fields. Each opens the provider's dialog, and is\n // drawn only while the reader holds the door's permission.\n {\n slot: 'besignerToolbar',\n widgetId: 'ai-generate-section',\n title: 'Generate a section with AI',\n Component: AiGenerateSectionControl,\n },\n {\n slot: 'besignerInspector',\n widgetId: 'ai-rewrite-copy',\n title: 'Rewrite with AI',\n Component: AiRewriteControl,\n },\n // Save the selection as a reusable component (AGL-2908): the component\n // job's second entry point, which proposes the properties a section\n // should declare and applies them as the manual promote does.\n {\n slot: 'besignerInspector',\n widgetId: 'ai-save-as-component',\n title: 'Make a reusable component with AI',\n permission: 'ai.generate',\n Component: AiSaveAsComponent,\n },\n {\n slot: 'orgMember',\n widgetId: 'ai-member-usage',\n title: 'AI usage',\n Component: MemberAiUsageCard,\n },\n // The allotments (AGL-2942): a member's or a site's monthly share of\n // the pool, set on Billing → Usage, on each member's page and on a\n // site's collaborators card — each card asks the route what its\n // reader may see and change.\n {\n slot: 'orgBillingUsage',\n widgetId: 'ai-allotments',\n title: 'AI allotments',\n permission: 'billing.view',\n Component: AiAllotmentsCard,\n },\n {\n slot: 'orgMember',\n widgetId: 'ai-member-allotment',\n title: 'AI allotment',\n Component: MemberAiAllotmentCard,\n },\n {\n slot: 'hostMembers',\n widgetId: 'ai-collaborator-allotment',\n title: 'AI allotment',\n column: {\n header: 'AI allotment',\n align: 'right',\n Header: AiCollaboratorAllotmentHeader,\n },\n Component: AiCollaboratorAllotmentCell,\n },\n {\n slot: 'hostMembers',\n widgetId: 'ai-site-allotment',\n title: 'Site AI allotment',\n Component: AiSiteAllotmentCard,\n },\n // Themes by AI (AGL-2938): a brief on the site's Theme section, a\n // proposal previewed before and after, and the editor's own Save to\n // keep it. Generation is sold as `aiGenerative` and held by\n // `ai.generate`, so the shell withholds the card from a plan or a\n // member without either; the card itself asks the route about the\n // release flag before it shows anything.\n {\n slot: 'hostTheme',\n widgetId: 'ai-theme-proposal',\n title: 'Theme assistant',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n Component: AiThemeProposalCard,\n },\n {\n slot: 'staffOrg',\n widgetId: 'ai-org-usage',\n title: 'AI usage',\n Component: StaffOrgAiCard,\n },\n {\n slot: 'staffOrg',\n widgetId: 'ai-org-conversations',\n title: `${PLATFORM_BRAND_NAME} AI requests`,\n Component: StaffOrgAiConversations,\n },\n {\n slot: 'staffUser',\n widgetId: 'ai-account-usage',\n title: 'AI usage across organizations',\n Component: StaffUserAiUsageCard,\n },\n // The same card for one account, across every org it asked in\n // (AGL-3660); the slot passes `uid`, which puts it in account mode.\n {\n slot: 'staffUser',\n widgetId: 'ai-account-requests',\n title: `${PLATFORM_BRAND_NAME} AI requests`,\n Component: StaffOrgAiConversations,\n },\n // The staff tables' AI figures (AGL-2984): the Organizations list's\n // spend column, and the usage table's three columns with the credit\n // pool line the org page draws above it.\n {\n slot: 'staffOrgsListColumn',\n widgetId: 'ai-orgs-spend',\n title: 'AI spend (month)',\n column: {\n header: 'AI spend (month)',\n align: 'right',\n Header: StaffOrgsAiSpendHeader,\n },\n Component: StaffOrgsAiSpendCell,\n },\n {\n slot: 'staffOrgUsageColumn',\n widgetId: 'ai-usage-assist-cost',\n title: 'Assist',\n column: { header: 'Assist', align: 'right' },\n Component: StaffOrgUsageAssistCell,\n },\n {\n slot: 'staffOrgUsageColumn',\n widgetId: 'ai-usage-credits',\n title: 'AI credits used',\n column: { header: 'AI credits used', align: 'right' },\n Component: StaffOrgUsageAiCreditsCell,\n },\n {\n slot: 'staffOrgUsageColumn',\n widgetId: 'ai-usage-overage',\n title: 'AI overage billed ($)',\n column: { header: 'AI overage billed ($)', align: 'right' },\n Component: StaffOrgUsageAiOverageCell,\n },\n {\n slot: 'staffOrgUsageColumn',\n widgetId: 'ai-usage-pool',\n title: 'AI credit pool',\n Component: StaffOrgUsageAiPool,\n },\n {\n slot: 'orgMembersListColumn',\n widgetId: 'ai-member-credits',\n title: 'AI credits (month)',\n column: { header: 'AI credits (month)', align: 'right', Header: AiMemberCreditsHeader },\n Component: AiMemberCreditsCell,\n },\n {\n slot: 'hostMembers',\n widgetId: 'ai-collaborator-credits',\n title: 'AI credits (site, month)',\n column: {\n header: 'AI credits (site, month)',\n align: 'right',\n Header: AiCollaboratorCreditsHeader,\n },\n Component: AiCollaboratorCreditsCell,\n },\n // SEO by AI (AGL-2910): \"Write SEO\" inside every search listing editor\n // — a page's SEO card and a product's listing — and the site audit on\n // the site's SEO section. Generation is sold as `aiGenerative` and held\n // by `ai.generate`, so the shell withholds both from a plan or a member\n // without either; each card asks the jobs route about the release flag\n // before it shows anything, and neither ever writes what it proposes.\n {\n slot: 'seoFields',\n widgetId: 'ai-seo-fields',\n title: 'SEO assistant',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n Component: AiSeoFieldsCard,\n },\n {\n slot: 'hostSeo',\n widgetId: 'ai-seo-audit',\n title: 'SEO audit',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n Component: AiSeoAuditCard,\n },\n // A page from a brief (AGL-2907): \"Create with AI\" beside Templates and\n // Create New Screen. Gated as the other generative widgets are.\n // On a plan that could buy the AI add-on and has not, each \"Create with\n // AI\" entry here is mounted anyway (`showWhenNotEntitled`) and opens\n // the add-on's dialog instead of the brief (AGL-3601). The shell holds\n // each behind `release_ai_generative` too, so an entry draws at once\n // and asks the jobs route nothing until its brief is sent.\n {\n slot: 'hostScreens',\n widgetId: 'ai-describe-page',\n title: 'Describe a page',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiDescribePageButton,\n },\n // The same entry for a page template, a layout and a form (AGL-3043),\n // beside the create action of the page that lists each: the same\n // dialog and the same gates.\n {\n slot: 'hostTemplates',\n widgetId: 'ai-describe-template',\n title: 'Describe a page template',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiDescribeTemplateButton,\n },\n {\n slot: 'hostLayouts',\n widgetId: 'ai-describe-layout',\n title: 'Describe a layout',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiDescribeLayoutButton,\n },\n {\n slot: 'hostForms',\n widgetId: 'ai-describe-form',\n title: 'Describe a form',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiDescribeFormButton,\n },\n // And a reusable component from a brief (AGL-3051), beside Templates\n // and Create Component: the component job's first entry point, which\n // had none in the console.\n // Pictures from a description (AGL-3602): \"Create with AI\" beside Upload\n // media in the media library, and in its empty state. Gated as the\n // other generative widgets are, by the shell alone: it asks nothing of\n // a server until someone creates a picture, and the door decides then.\n // Like every Create with AI entry it is mounted without the add-on too\n // and opens its own upsell there (AGL-3601).\n {\n slot: 'mediaLibrary',\n widgetId: 'ai-media-create',\n title: 'Create images with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiMediaCreateButton,\n },\n {\n slot: 'hostComponents',\n widgetId: 'ai-describe-component',\n title: 'Describe a reusable component',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiDescribeComponentButton,\n },\n // An email design from a brief (AGL-3596), beside New template on a\n // site's email templates — the zone the email plugin hosts. Its dialog\n // also offers the draft campaign that would send it; the Campaigns\n // section's own door is `ai-create-campaign`, below.\n {\n slot: 'hostEmailTemplates',\n widgetId: 'ai-describe-email',\n title: 'Describe an email',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiDescribeEmailButton,\n },\n // Automations by AI (AGL-2919), in the zones the workflows plugin hosts\n // on its Automation page: \"Create with AI\" beside Add action and Recipes,\n // \"Explain it\" in the editor of a saved automation, and \"Why did this\n // fail?\" on a failed run. Gated as the other generative widgets are,\n // the release flag included, by the shell alone (AGL-3601): none asks\n // the jobs route anything until it is used, and none of them changes an\n // automation.\n {\n slot: 'hostAutomations',\n widgetId: 'ai-describe-automation',\n title: 'Describe an automation',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiDescribeAutomationButton,\n },\n // Funnels by AI (AGL-3605), in the zones the funnels plugin hosts on\n // its card: a draft from a description, and its results explained.\n {\n slot: 'funnelsCreate',\n widgetId: 'ai-describe-funnel',\n title: 'Describe a funnel',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiFunnelCreateButton,\n },\n {\n slot: 'funnelInsight',\n widgetId: 'ai-explain-funnel',\n title: 'Ask AI about this funnel',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiFunnelAskButton,\n },\n {\n slot: 'automationEditor',\n widgetId: 'ai-explain-automation',\n title: 'Explain this automation',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n releaseFlag: 'release_ai_generative',\n Component: AiExplainAutomation,\n },\n // \"Change with AI\" and \"Fix with AI\" in a saved action's editor\n // (AGL-3603): a changed copy drafted OFF beside it, never the saved\n // action written in place.\n {\n slot: 'automationEditor',\n widgetId: 'ai-revise-automation',\n title: 'Change this automation with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n releaseFlag: 'release_ai_generative',\n Component: AiReviseAutomation,\n },\n // \"Create with AI\" on the workspace's Org automations (AGL-3603): one\n // of the workspace's automations drafted from a description and opened\n // in that section's editor, unsaved and switched off.\n {\n slot: 'orgAutomations',\n widgetId: 'ai-describe-org-automation',\n title: 'Describe an org automation',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiDescribeOrgAutomationButton,\n },\n // \"Ask AI about these numbers\" (AGL-3603): a tile on a site's\n // dashboard and Analytics page, which both draw `hostDashboard`, and on\n // the workspace's sites page. It opens the insight dialog the Assist\n // panel opens, gated as every generative widget is.\n {\n slot: 'hostDashboard',\n widgetId: 'ai-insight-ask',\n title: 'Ask AI about these numbers',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiInsightHostCard,\n },\n {\n slot: 'orgDashboard',\n widgetId: 'ai-insight-ask',\n title: 'Ask AI about these numbers',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiInsightOrgCard,\n },\n // Logic by AI (AGL-3603), in the zones the logic plugin hosts on its\n // Functions & Variables page: Create with AI in the Functions and\n // Variables card headers, Explain / Change / Fix in a saved function's\n // editor, and Fix with AI on a broken reference an automation holds.\n // Each proposal opens unsaved in the logic editor; none is saved here.\n {\n slot: 'hostLogic',\n widgetId: 'ai-describe-logic',\n title: 'Describe a function or variable',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiLogicCreateButton,\n },\n {\n slot: 'logicFunctionEditor',\n widgetId: 'ai-logic-function',\n title: 'This function with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n releaseFlag: 'release_ai_generative',\n Component: AiLogicFunctionTools,\n },\n {\n slot: 'logicReferenceIssue',\n widgetId: 'ai-logic-fix-reference',\n title: 'Fix this reference with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n releaseFlag: 'release_ai_generative',\n Component: AiLogicFixReference,\n },\n {\n slot: 'automationRun',\n widgetId: 'ai-explain-run-failure',\n title: 'Why did this run fail?',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n releaseFlag: 'release_ai_generative',\n Component: AiExplainRunFailure,\n },\n // CRM by AI (AGL-2917): a record's summary and next step on its page,\n // a draft in the one-to-one composer, and an import's column matches.\n // The CRM hosts each zone, so it is drawn only where the CRM is; the\n // shell holds the plan and `ai.generate`, each card asks the jobs route\n // about the release flag before it shows anything, and none writes what\n // it proposes.\n {\n slot: 'recordInsights',\n widgetId: 'ai-crm-record',\n title: 'AI summary',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n Component: AiCrmRecordCard,\n },\n {\n slot: 'recordEmail',\n widgetId: 'ai-crm-email',\n title: 'Draft with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n Component: AiCrmEmailDraft,\n },\n {\n slot: 'importMapping',\n widgetId: 'ai-crm-import-mapping',\n title: 'Match columns with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n Component: AiCrmImportMapping,\n },\n // The guided start (AGL-2918), on the page a newly created site lands\n // on: a few questions that become a site scaffold. Gated as the other\n // generative widgets are, and it asks the jobs route about the release\n // flag before it shows anything — so a workspace the feature is not\n // released to gets the blank page and nothing else. Skipping is the\n // zone's own `startBlank`, which creates nothing.\n {\n slot: 'hostFirstRun',\n widgetId: 'ai-site-start',\n title: 'Start this site with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n Component: AiSiteStartCard,\n },\n // The listing those answers describe (AGL-2918), on the site's SEO\n // section: the site-wide search title and description the guided start\n // implies, offered where they are edited. The same gates as every\n // generative widget, and it stages into the SEO form rather than\n // writing it — a person's Update is the write, as it is for the audit\n // card beside it.\n {\n slot: 'hostSeo',\n widgetId: 'ai-site-seo-start',\n title: 'The listing your answers describe',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n Component: AiSiteSeoStartCard,\n },\n // What Aglyn AI learned from the site's applied edits (AGL-3661), on\n // Setup → Business profile, where the owner reads and forgets it. No\n // generate permission: reading and clearing what the AI keeps about a\n // site is every editor's, and the rules hold the write to the server.\n {\n slot: 'hostBusinessProfile',\n widgetId: 'ai-site-memory',\n title: `What ${aiAddonName()} learned`,\n featureFlag: 'aiGenerative',\n Component: AiSiteMemoryCard,\n },\n // The agency batch (AGL-2911): one brief across many of the org's\n // sites, from the page that lists them. The card asks the jobs route\n // about the release flag before it shows anything, and its own door\n // holds the plan band and the caller's permission on every site it is\n // pointed at.\n {\n slot: 'orgSites',\n widgetId: 'ai-site-batch',\n title: 'Generate sites with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n Component: AiSiteBatchCard,\n },\n // Commerce by AI (AGL-2916): product copy in the product editor, the\n // catalog, categories and discounts on the products hub, and copy for\n // an import as it lands. The commerce plugin hosts the zones and makes\n // every write. The shell holds the release flag; the products hub card\n // reads its recent proposals before it draws its own controls, but\n // offers the \"Create with AI\" door's brief from the moment it mounts.\n {\n slot: 'productEditor',\n widgetId: 'ai-product-copy',\n title: 'Product copy assistant',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n Component: AiProductCopyCard,\n },\n {\n slot: 'productsHub',\n widgetId: 'ai-products-hub',\n title: 'Build your catalog with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n releaseFlag: 'release_ai_generative',\n Component: AiProductsHubCard,\n },\n // \"Create with AI\" beside Add product and in the empty catalog\n // (AGL-3596): a door to the card's Propose products brief, shown only\n // while that card is on the page to take it.\n {\n slot: 'productsCreate',\n widgetId: 'ai-products-create',\n title: 'Propose products',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiCreateProductsButton,\n },\n {\n slot: 'productImport',\n widgetId: 'ai-product-import',\n title: 'Write imported product copy with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n Component: AiProductImportOption,\n },\n // A/B tests by AI (AGL-2914): variants written in the experiment\n // editor, and one test's result read in plain words below its figures.\n // The A/B testing card hosts both zones, so they are drawn only where\n // that card is and only on a site with A/B testing; the shell holds the\n // plan band, `ai.generate` and the release flag, and neither card asks\n // the jobs route anything until it is used (AGL-3601). Neither writes: the\n // experiment editor's Save is the only write, and an explanation has\n // nothing to apply.\n {\n slot: 'experimentVariants',\n widgetId: 'ai-experiment-variants',\n title: 'Write variants with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n releaseFlag: 'release_ai_generative',\n Component: AiExperimentVariantsCard,\n },\n {\n slot: 'experimentResult',\n widgetId: 'ai-experiment-result',\n title: 'Explain this result with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n releaseFlag: 'release_ai_generative',\n Component: AiExperimentResultCard,\n },\n // Overlays by AI (AGL-3603), in the zones the marketing plugin's\n // overlays list hosts: \"Create with AI\" beside New bar and New popup,\n // and \"Write with AI\" among the overlay editor's fields. Both start a\n // `text` job asked for overlay copy; neither writes — the list saves a\n // created overlay switched off, and the editor's Save is the write.\n {\n slot: 'hostOverlays',\n widgetId: 'ai-create-overlay',\n title: 'Create an overlay with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiCreateOverlayButton,\n },\n {\n slot: 'overlayEditor',\n widgetId: 'ai-overlay-copy',\n title: 'Write overlay copy with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n releaseFlag: 'release_ai_generative',\n Component: AiOverlayEditorCard,\n },\n // A campaign from a brief (AGL-3603), beside Create campaign on the\n // Campaigns section the marketing plugin hosts: the `campaign` job's\n // first console door, or the `email` job's where the plan sends no\n // campaign email. Both write drafts that are aimed at nobody and sent\n // by nobody until a member does.\n {\n slot: 'hostCampaigns',\n widgetId: 'ai-create-campaign',\n title: 'Create a campaign with AI',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiCreateCampaignButton,\n },\n // The figures in words (AGL-3603), in the header of the Conversions\n // section and of one campaign's report: the insight dialog the Assist\n // panel opens, on the Marketing surface, for the site the figures are.\n // It reads and cites; it changes nothing.\n {\n slot: 'marketingInsights',\n widgetId: 'ai-marketing-insight',\n title: 'Ask AI about these numbers',\n featureFlag: 'aiGenerative',\n permission: 'ai.generate',\n showWhenNotEntitled: true,\n releaseFlag: 'release_ai_generative',\n Component: AiMarketingInsightButton,\n },\n ],\n })\n}\n"],"names":["PLATFORM_BRAND_NAME","aiAddonName","registerConsoleExtension","LinearProgress","createElement","AiAssistProviderOnHost","AI_PLUGIN_ID","registerAiDeclarations","lazyWidget","PAGE_LOADING","AiSaveAsComponent","then","m","AiGenerateSectionControl","AiRewriteControl","AssistPanelOnHost","AiCreditsCard","default","AiJobsTopBarIndicator","AiCollaboratorCreditsCell","AiCollaboratorCreditsHeader","AiMemberCreditsCell","AiMemberCreditsHeader","AssistSignalsPage","BillingAssistOverageCard","AiTopUsersCard","AiAllotmentsCard","AiCollaboratorAllotmentCell","AiCollaboratorAllotmentHeader","AiSiteAllotmentCard","MemberAiAllotmentCard","MemberAiUsageCard","AiThemeProposalCard","StaffOrgAiCard","StaffOrgAiConversations","StaffOrgUsageAiCreditsCell","StaffOrgUsageAiOverageCell","StaffOrgUsageAiPool","StaffOrgUsageAssistCell","StaffOrgsAiSpendCell","StaffOrgsAiSpendHeader","StaffUserAiUsageCard","AiSeoAuditCard","AiSiteBatchCard","AiSiteSeoStartCard","AiSiteMemoryCard","AiSiteStartCard","AiSeoFieldsCard","AiDescribeAutomationButton","AiReviseAutomation","AiDescribeOrgAutomationButton","AiInsightHostCard","AiInsightOrgCard","AiLogicCreateButton","AiLogicFixReference","AiLogicFunctionTools","AiFunnelAskButton","AiFunnelCreateButton","AiCrmEmailDraft","AiCrmImportMapping","AiCrmRecordCard","AiDescribePageButton","AiMediaCreateButton","AiDescribeComponentButton","AiDescribeFormButton","AiDescribeLayoutButton","AiDescribeTemplateButton","AiDescribeEmailButton","AiExperimentResultCard","AiExperimentVariantsCard","AiExplainAutomation","AiExplainRunFailure","AiCreateCampaignButton","AiMarketingInsightButton","AiCreateOverlayButton","AiOverlayEditorCard","AiProductCopyCard","AiProductImportOption","AiProductsHubCard","AiCreateProductsButton","AiJobsPage","registerAiConsole","pluginId","displayName","providers","staffPages","id","label","header","title","docsTopic","Component","navItems","href","recordTitle","docsAnchor","unlisted","ownsSubtree","permission","widgets","slot","widgetId","featureFlag","column","align","Header","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;YACb;YACA;gBACEqB,MAAM;gBACNC,UAAU;gBACVZ,OAAO;gBACPa,aAAa;gBACbJ,YAAY;gBACZP,WAAWd;YACb;YACA,iEAAiE;YACjE,uEAAuE;YACvE,sEAAsE;YACtE,wEAAwE;YACxE,uEAAuE;YACvE,2EAA2E;YAC3E,qEAAqE;YACrE,oBAAoB;YACpB;gBACEuB,MAAM;gBACNC,UAAU;gBACVZ,OAAO;gBACPa,aAAa;gBACbJ,YAAY;gBACZS,aAAa;gBACbhB,WAAWtB;YACb;YACA;gBACE+B,MAAM;gBACNC,UAAU;gBACVZ,OAAO;gBACPa,aAAa;gBACbJ,YAAY;gBACZS,aAAa;gBACbhB,WAAWvB;YACb;YACA,iEAAiE;YACjE,sEAAsE;YACtE,sEAAsE;YACtE,uEAAuE;YACvE,oEAAoE;YACpE;gBACEgC,MAAM;gBACNC,UAAU;gBACVZ,OAAO;gBACPa,aAAa;gBACbJ,YAAY;gBACZQ,qBAAqB;gBACrBC,aAAa;gBACbhB,WAAWjB;YACb;YACA;gBACE0B,MAAM;gBACNC,UAAU;gBACVZ,OAAO;gBACPa,aAAa;gBACbJ,YAAY;gBACZS,aAAa;gBACbhB,WAAWhB;YACb;YACA,oEAAoE;YACpE,qEAAqE;YACrE,mEAAmE;YACnE,sEAAsE;YACtE,iCAAiC;YACjC;gBACEyB,MAAM;gBACNC,UAAU;gBACVZ,OAAO;gBACPa,aAAa;gBACbJ,YAAY;gBACZQ,qBAAqB;gBACrBC,aAAa;gBACbhB,WAAWnB;YACb;YACA,oEAAoE;YACpE,sEAAsE;YACtE,uEAAuE;YACvE,0CAA0C;YAC1C;gBACE4B,MAAM;gBACNC,UAAU;gBACVZ,OAAO;gBACPa,aAAa;gBACbJ,YAAY;gBACZQ,qBAAqB;gBACrBC,aAAa;gBACbhB,WAAWlB;YACb;SACD;IACH;AACF"}
@@ -1,3 +1,4 @@
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
1
2
  /**
2
3
  * @license
3
4
  * Copyright 2026 Aglyn LLC
@@ -14,7 +15,7 @@
14
15
  * See the License for the specific language governing permissions and
15
16
  * limitations under the License.
16
17
  */ import { hasPersonalDetails } from "@aglyn/aglyn/plugin-manager/plugin-figures";
17
- import { AI_INSIGHT_GAP_MAX_CHARS, AI_INSIGHT_MAX_CHARS, AI_INSIGHT_MAX_CITED_ROWS, AI_INSIGHT_MAX_CITES, AI_INSIGHT_MAX_INSIGHTS } from "../model/ai-insight.js";
18
+ import { AI_INSIGHT_GAP_MAX_CHARS, AI_INSIGHT_HEADLINE_MAX_CHARS, AI_INSIGHT_MAX_CHARS, AI_INSIGHT_MAX_CITED_ROWS, AI_INSIGHT_MAX_CITES, AI_INSIGHT_MAX_INSIGHTS } from "../model/ai-insight.js";
18
19
  const MARKUP = /<\/?[a-z][^>]*>|```|^#{1,6}\s|\*\*/im;
19
20
  /**
20
21
  * A number as a sentence writes it: an optional sign and currency symbol, the
@@ -157,13 +158,25 @@ const truncate = (value, decimals)=>{
157
158
  if (rise === fall) return null;
158
159
  return rise ? 'rise' : 'fall';
159
160
  }
161
+ /**
162
+ * The headline a person may read. One that runs long is only dropped: the
163
+ * insight keeps its sentence, because length says nothing about whether it is
164
+ * true.
165
+ */ function insightHeadline(insight) {
166
+ const headline = typeof (insight == null ? void 0 : insight.headline) === 'string' ? insight.headline.trim() : '';
167
+ return headline.length <= AI_INSIGHT_HEADLINE_MAX_CHARS ? headline : '';
168
+ }
160
169
  /** One insight's findings against the tables the job read; empty when it traces. */ export function checkAiInsight(insight, tables) {
161
- const text = typeof (insight == null ? void 0 : insight.text) === 'string' ? insight.text.trim() : '';
162
- if (!text) return [
170
+ const sentences = typeof (insight == null ? void 0 : insight.text) === 'string' ? insight.text.trim() : '';
171
+ if (!sentences) return [
163
172
  'insight-empty'
164
173
  ];
165
174
  const findings = [];
166
- if (text.length > AI_INSIGHT_MAX_CHARS) findings.push('insight-too-long');
175
+ if (sentences.length > AI_INSIGHT_MAX_CHARS) findings.push('insight-too-long');
176
+ // The headline is held to everything the sentence is: it is the part a
177
+ // person reads first, and often the only part.
178
+ const headline = insightHeadline(insight);
179
+ const text = headline ? `${headline}. ${sentences}` : sentences;
167
180
  if (MARKUP.test(text)) findings.push('insight-markup');
168
181
  if (hasPersonalDetails(text)) findings.push('insight-personal-details');
169
182
  const cites = Array.isArray(insight.cites) ? insight.cites.slice(0, AI_INSIGHT_MAX_CITES) : [];
@@ -259,13 +272,16 @@ const truncate = (value, decimals)=>{
259
272
  });
260
273
  findings.push(...own);
261
274
  } else {
262
- kept.push({
275
+ const headline = insightHeadline(insight);
276
+ kept.push(_extends({}, headline ? {
277
+ headline
278
+ } : {}, {
263
279
  text: insight.text.trim(),
264
280
  cites: insight.cites.slice(0, AI_INSIGHT_MAX_CITES).map((cite)=>({
265
281
  table: cite.table,
266
282
  rows: cite.rows.slice(0, AI_INSIGHT_MAX_CITED_ROWS)
267
283
  }))
268
- });
284
+ }));
269
285
  }
270
286
  });
271
287
  const gap = aiInsightGap(answer == null ? void 0 : answer.gap);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/runtime/ai-insight-check.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\nimport { hasPersonalDetails } from '@aglyn/aglyn/plugin-manager/plugin-figures'\nimport {\n AI_INSIGHT_GAP_MAX_CHARS,\n AI_INSIGHT_MAX_CHARS,\n AI_INSIGHT_MAX_CITED_ROWS,\n AI_INSIGHT_MAX_CITES,\n AI_INSIGHT_MAX_INSIGHTS,\n type AiInsight,\n type AiInsightAnswer,\n type AiInsightCitation,\n type AiInsightTable,\n} from '../model/ai-insight'\n\n/**\n * THE TRACE (AGL-2915): whether an insight's words agree with the rows it\n * cites.\n *\n * An insight job hands the model tables that code computed, and the model\n * writes sentences about them. Nothing about a sentence makes it true, so each\n * one is read back against the figures before a person sees it:\n *\n * - it cites at least one row, of a table this job actually read;\n * - every number it writes is a figure in a row it cites — as the table has\n * it, or rounded to the decimals written, in the unit written — or the\n * length of a cited window, a date in it, or a count of the rows cited;\n * - a rise or a fall it names agrees with the sign of the change it quotes;\n * - it names nobody: no email address and no phone number.\n *\n * An insight that fails any of these is LEFT OUT, never repaired: a sentence\n * whose number cannot be found is exactly the sentence a person must not act\n * on, and rewriting it would be the model's guess again. The rest of the\n * answer stands. What is left out is counted, so the console can say so.\n */\n\n/** Why an insight was left out, as a finding code. */\nexport type AiInsightFinding =\n | 'insight-empty'\n | 'insight-too-long'\n | 'insight-markup'\n | 'insight-personal-details'\n | 'insight-no-citation'\n | 'insight-unknown-table'\n | 'insight-unknown-row'\n | 'insight-number-untraced'\n | 'insight-direction'\n | 'insight-too-many'\n\nexport interface AiInsightVerdict {\n insight: AiInsight\n findings: string[]\n}\n\nexport interface AiInsightCheck {\n /** The insights a person may read, in the order written. */\n kept: AiInsight[]\n /** The insights left out, each with why. */\n left: AiInsightVerdict[]\n /** The gap sentence, when it is one a person may read. */\n gap: string | null\n /** Every finding, in order, for the eval harness and the logs. */\n findings: string[]\n}\n\nconst MARKUP = /<\\/?[a-z][^>]*>|```|^#{1,6}\\s|\\*\\*/im\n\n/**\n * A number as a sentence writes it: an optional sign and currency symbol, the\n * digits with their thousands separators, the decimals, and a unit.\n */\nconst NUMBER = /(?<![\\p{L}\\p{N}_.])([+\\-−]?)([$€£¥]?)(\\d{1,3}(?:,\\d{3})+|\\d+)(?:\\.(\\d+))?(?:\\s?(%|percent\\b|k\\b|thousand\\b|m\\b|million\\b|seconds?\\b|secs?\\b|s\\b|minutes?\\b|mins?\\b|hours?\\b|hrs?\\b|h\\b))?/giu\n\n/** Minutes and seconds written together (`2m 04s`), read as one figure in seconds. */\nconst DURATION = /(?<![\\p{L}\\p{N}_.])(?:(\\d+)\\s?h(?:ours?|rs?)?\\s+)?(\\d+)\\s?m(?:in(?:utes?)?)?\\s+(\\d{1,2})\\s?s(?:ec(?:onds?)?)?\\b/giu\n\nconst RISING = /\\b(?:rose|rise[sn]?|rising|grew|grow(?:s|n|ing)?|increas(?:e|ed|es|ing)|up|higher|gain(?:ed|s)?|jump(?:ed|s)?|climb(?:ed|s)?|more)\\b/i\nconst FALLING = /\\b(?:fell|fall(?:s|en|ing)?|drop(?:ped|s)?|declin(?:e|ed|es|ing)|decreas(?:e|ed|es|ing)|down|lower|lost|shr[au]nk|less|fewer)\\b/i\n\ninterface WrittenNumber {\n /** The figure as written, unsigned, in the unit's base (a percent, seconds, a plain count). */\n value: number\n decimals: number\n negative: boolean\n unit: 'percent' | 'thousand' | 'million' | 'seconds' | 'minutes' | 'hours' | 'currency' | null\n /** Where in the text it starts, for the words before it. */\n at: number\n raw: string\n}\n\nfunction unitOf(symbol: string, unit: string | undefined): WrittenNumber['unit'] {\n const word = (unit ?? '').toLowerCase()\n if (word === '%' || word === 'percent') return 'percent'\n if (word === 'k' || word === 'thousand') return 'thousand'\n if (word === 'm' || word === 'million') return 'million'\n if (/^(?:seconds?|secs?|s)$/.test(word)) return 'seconds'\n if (/^(?:minutes?|mins?)$/.test(word)) return 'minutes'\n if (/^(?:hours?|hrs?|h)$/.test(word)) return 'hours'\n return symbol ? 'currency' : null\n}\n\n/** Every figure a sentence writes, durations written as minutes and seconds read as one. */\nexport function aiInsightNumbers(text: string): WrittenNumber[] {\n const found: WrittenNumber[] = []\n const covered: Array<[number, number]> = []\n for (const match of text.matchAll(DURATION)) {\n const hours = Number(match[1] ?? 0)\n const seconds = hours * 3_600 + Number(match[2]) * 60 + Number(match[3])\n const at = match.index ?? 0\n covered.push([at, at + match[0].length])\n found.push({ value: seconds, decimals: 0, negative: false, unit: 'seconds', at, raw: match[0] })\n }\n for (const match of text.matchAll(NUMBER)) {\n const at = match.index ?? 0\n if (covered.some(([start, end]) => at >= start && at < end)) continue\n const whole = match[3].replace(/,/g, '')\n const decimals = match[4] ?? ''\n found.push({\n value: Number(decimals ? `${whole}.${decimals}` : whole),\n decimals: decimals.length,\n negative: match[1] === '-' || match[1] === '−',\n unit: unitOf(match[2], match[5]),\n at,\n raw: match[0],\n })\n }\n return found.sort((a, b) => a.at - b.at)\n}\n\nconst round = (value: number, decimals: number) => {\n const scale = 10 ** decimals\n return Math.round(value * scale) / scale\n}\n\nconst truncate = (value: number, decimals: number) => {\n const scale = 10 ** decimals\n return Math.trunc(value * scale) / scale\n}\n\n/** Whether a written figure reads a cell's value, at the decimals written, rounded or cut. */\nfunction reads(written: WrittenNumber, cell: number, scale: number): boolean {\n const base = Math.abs(cell) / scale\n const value = Math.abs(written.value)\n return round(base, written.decimals) === value || truncate(base, written.decimals) === value\n}\n\n/** The scales a unit may read a column's cells at: a percent is not a count, and seconds are not dollars. */\nfunction scalesFor(written: WrittenNumber, kind: AiInsightTable['columns'][number]['kind']): number[] {\n switch (written.unit) {\n case 'percent':\n return kind === 'percent' || kind === 'change' || kind === 'number' ? [1] : []\n case 'currency':\n return kind === 'money' ? [1] : []\n case 'thousand':\n return kind === 'count' || kind === 'number' || kind === 'money' ? [1_000] : []\n case 'million':\n return kind === 'count' || kind === 'number' || kind === 'money'\n ? [1_000_000]\n : kind === 'duration'\n ? [60]\n : []\n case 'seconds':\n return kind === 'duration' ? [1] : []\n case 'minutes':\n return kind === 'duration' ? [60] : []\n case 'hours':\n return kind === 'duration' ? [3_600] : []\n default:\n return kind === 'date' || kind === 'text' ? [] : kind === 'duration' ? [1, 60] : [1]\n }\n}\n\ninterface CitedCell {\n table: AiInsightTable\n kind: AiInsightTable['columns'][number]['kind']\n value: number\n}\n\n/** The numbers a citation vouches for beyond its cells: the window, its dates, and how many rows. */\nfunction framingNumbers(tables: readonly AiInsightTable[], cites: readonly AiInsightCitation[]): Set<number> {\n const numbers = new Set<number>()\n for (const table of tables) {\n if (table.period) {\n numbers.add(table.period.days)\n for (const day of [table.period.from, table.period.to]) {\n const [year, month, date] = day.split('-').map(Number)\n numbers.add(year).add(month).add(date)\n }\n }\n numbers.add(table.rows.length)\n }\n for (const cite of cites) numbers.add(cite.rows.length)\n numbers.add(cites.reduce((total, cite) => total + cite.rows.length, 0))\n return numbers\n}\n\n/** Whether a figure's digits are written inside a cited label: a year in a campaign's name, a path's number. */\nfunction inLabel(written: WrittenNumber, labels: readonly string[]): boolean {\n if (written.unit !== null || written.negative) return false\n const digits = written.raw.replace(/[^\\d.]/g, '')\n return labels.some((label) => new RegExp(`(?<![\\\\d.])${digits.replace('.', '\\\\.')}(?![\\\\d.])`).test(label))\n}\n\n/** The sign the words just before a figure give it, or `null` when they give none. */\nfunction directionBefore(text: string, at: number): 'rise' | 'fall' | null {\n const before = text.slice(Math.max(0, at - 40), at)\n const words = before.split(/\\s+/).slice(-4).join(' ')\n const rise = RISING.test(words)\n const fall = FALLING.test(words)\n if (rise === fall) return null\n return rise ? 'rise' : 'fall'\n}\n\n/** One insight's findings against the tables the job read; empty when it traces. */\nexport function checkAiInsight(insight: AiInsight, tables: readonly AiInsightTable[]): string[] {\n const text = typeof insight?.text === 'string' ? insight.text.trim() : ''\n if (!text) return ['insight-empty']\n const findings: string[] = []\n if (text.length > AI_INSIGHT_MAX_CHARS) findings.push('insight-too-long')\n if (MARKUP.test(text)) findings.push('insight-markup')\n if (hasPersonalDetails(text)) findings.push('insight-personal-details')\n\n const cites = Array.isArray(insight.cites) ? insight.cites.slice(0, AI_INSIGHT_MAX_CITES) : []\n if (!cites.length || cites.every((cite) => !Array.isArray(cite?.rows) || !cite.rows.length)) {\n return [...findings, 'insight-no-citation']\n }\n const cells: CitedCell[] = []\n const labels: string[] = []\n const cited: AiInsightTable[] = []\n for (const cite of cites) {\n const table = tables.find((entry) => entry.ref === cite?.table)\n if (!table) {\n findings.push(`insight-unknown-table:${String(cite?.table)}`)\n continue\n }\n cited.push(table)\n for (const index of (cite.rows ?? []).slice(0, AI_INSIGHT_MAX_CITED_ROWS)) {\n const row = Number.isInteger(index) ? table.rows[index] : undefined\n if (!row) {\n findings.push(`insight-unknown-row:${table.ref}:${String(index)}`)\n continue\n }\n for (const column of table.columns) {\n const value = row[column.key]\n if (typeof value === 'number' && Number.isFinite(value)) {\n cells.push({ table, kind: column.kind, value })\n } else if (typeof value === 'string') {\n labels.push(value)\n if (column.kind === 'date') {\n for (const part of value.split('-').map(Number)) {\n cells.push({ table, kind: 'count', value: part })\n }\n }\n }\n }\n }\n }\n if (findings.some((finding) => finding.startsWith('insight-unknown-'))) return findings\n\n const framing = framingNumbers(cited, cites)\n for (const written of aiInsightNumbers(text)) {\n const matched = cells.filter((cell) =>\n scalesFor(written, cell.kind).some((scale) => reads(written, cell.value, scale)),\n )\n const framed =\n written.unit === null && written.decimals === 0 && !written.negative && framing.has(written.value)\n if (!matched.length && !framed && !inLabel(written, labels)) {\n findings.push(`insight-number-untraced:${written.raw.trim()}`)\n continue\n }\n // A rise or a fall is checked against the change it quotes, and only then:\n // \"down\" beside a count is not a claim about a sign.\n const changes = matched.filter((cell) => cell.kind === 'change' && cell.value !== 0)\n if (!changes.length || changes.length !== matched.length) continue\n const direction = directionBefore(text, written.at)\n if (!direction) continue\n const agrees = changes.some((cell) => (direction === 'rise' ? cell.value > 0 : cell.value < 0))\n if (!agrees) findings.push(`insight-direction:${written.raw.trim()}`)\n }\n return findings\n}\n\n/** The gap sentence a person may read: short, without figures and naming nobody; `null` otherwise. */\nexport function aiInsightGap(gap: unknown): string | null {\n if (typeof gap !== 'string') return null\n const text = gap.replace(/\\s+/g, ' ').trim()\n if (!text || text.length > AI_INSIGHT_GAP_MAX_CHARS || /\\d/.test(text) || MARKUP.test(text)) return null\n return hasPersonalDetails(text) ? null : text\n}\n\n/**\n * An answer held to the trace: the insights that trace kept in the order\n * written, the rest left out with why, and past `AI_INSIGHT_MAX_INSIGHTS`\n * nothing more is read.\n */\nexport function checkAiInsightAnswer(\n answer: Partial<AiInsightAnswer> | null | undefined,\n tables: readonly AiInsightTable[],\n): AiInsightCheck {\n const insights = Array.isArray(answer?.insights) ? answer.insights : []\n const kept: AiInsight[] = []\n const left: AiInsightVerdict[] = []\n const findings: string[] = []\n insights.forEach((insight, index) => {\n const own =\n index >= AI_INSIGHT_MAX_INSIGHTS ? ['insight-too-many'] : checkAiInsight(insight, tables)\n if (own.length) {\n left.push({ insight, findings: own })\n findings.push(...own)\n } else {\n kept.push({\n text: insight.text.trim(),\n cites: insight.cites.slice(0, AI_INSIGHT_MAX_CITES).map((cite) => ({\n table: cite.table,\n rows: cite.rows.slice(0, AI_INSIGHT_MAX_CITED_ROWS),\n })),\n })\n }\n })\n const gap = aiInsightGap(answer?.gap)\n if (answer?.gap && !gap) findings.push('insight-gap-unreadable')\n return { kept, left, gap, findings }\n}\n"],"names":["hasPersonalDetails","AI_INSIGHT_GAP_MAX_CHARS","AI_INSIGHT_MAX_CHARS","AI_INSIGHT_MAX_CITED_ROWS","AI_INSIGHT_MAX_CITES","AI_INSIGHT_MAX_INSIGHTS","MARKUP","NUMBER","DURATION","RISING","FALLING","unitOf","symbol","unit","word","toLowerCase","test","aiInsightNumbers","text","found","covered","match","matchAll","hours","Number","seconds","at","index","push","length","value","decimals","negative","raw","some","start","end","whole","replace","sort","a","b","round","scale","Math","truncate","trunc","reads","written","cell","base","abs","scalesFor","kind","framingNumbers","tables","cites","numbers","Set","table","period","add","days","day","from","to","year","month","date","split","map","rows","cite","reduce","total","inLabel","labels","digits","label","RegExp","directionBefore","before","slice","max","words","join","rise","fall","checkAiInsight","insight","trim","findings","Array","isArray","every","cells","cited","find","entry","ref","String","row","isInteger","undefined","column","columns","key","isFinite","part","finding","startsWith","framing","matched","filter","framed","has","changes","direction","agrees","aiInsightGap","gap","checkAiInsightAnswer","answer","insights","kept","left","forEach","own"],"mappings":"AAAA;;;;;;;;;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AGmF,eAAeC,SAASlC;QACpF,IAAIwE,IAAIlG,MAAM,EAAE;YACdgG,KAAKjG,IAAI,CAAC;gBAAE6D;gBAASE,UAAUoC;YAAI;YACnCpC,SAAS/D,IAAI,IAAImG;QACnB,OAAO;YACLH,KAAKhG,IAAI,CAAC;gBACRV,MAAMuE,QAAQvE,IAAI,CAACwE,IAAI;gBACvBlC,OAAOiC,QAAQjC,KAAK,CAAC0B,KAAK,CAAC,GAAG9E,sBAAsBkE,GAAG,CAAC,CAACE,OAAU,CAAA;wBACjEb,OAAOa,KAAKb,KAAK;wBACjBY,MAAMC,KAAKD,IAAI,CAACW,KAAK,CAAC,GAAG/E;oBAC3B,CAAA;YACF;QACF;IACF;IACA,MAAMqH,MAAMD,aAAaG,0BAAAA,OAAQF,GAAG;IACpC,IAAIE,CAAAA,0BAAAA,OAAQF,GAAG,KAAI,CAACA,KAAK7B,SAAS/D,IAAI,CAAC;IACvC,OAAO;QAAEgG;QAAMC;QAAML;QAAK7B;IAAS;AACrC"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/runtime/ai-insight-check.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\nimport { hasPersonalDetails } from '@aglyn/aglyn/plugin-manager/plugin-figures'\nimport {\n AI_INSIGHT_GAP_MAX_CHARS,\n AI_INSIGHT_HEADLINE_MAX_CHARS,\n AI_INSIGHT_MAX_CHARS,\n AI_INSIGHT_MAX_CITED_ROWS,\n AI_INSIGHT_MAX_CITES,\n AI_INSIGHT_MAX_INSIGHTS,\n type AiInsight,\n type AiInsightAnswer,\n type AiInsightCitation,\n type AiInsightTable,\n} from '../model/ai-insight'\n\n/**\n * THE TRACE (AGL-2915): whether an insight's words agree with the rows it\n * cites.\n *\n * An insight job hands the model tables that code computed, and the model\n * writes sentences about them. Nothing about a sentence makes it true, so each\n * one is read back against the figures before a person sees it:\n *\n * - it cites at least one row, of a table this job actually read;\n * - every number it writes is a figure in a row it cites — as the table has\n * it, or rounded to the decimals written, in the unit written — or the\n * length of a cited window, a date in it, or a count of the rows cited;\n * - a rise or a fall it names agrees with the sign of the change it quotes;\n * - it names nobody: no email address and no phone number.\n *\n * An insight that fails any of these is LEFT OUT, never repaired: a sentence\n * whose number cannot be found is exactly the sentence a person must not act\n * on, and rewriting it would be the model's guess again. The rest of the\n * answer stands. What is left out is counted, so the console can say so.\n */\n\n/** Why an insight was left out, as a finding code. */\nexport type AiInsightFinding =\n | 'insight-empty'\n | 'insight-too-long'\n | 'insight-markup'\n | 'insight-personal-details'\n | 'insight-no-citation'\n | 'insight-unknown-table'\n | 'insight-unknown-row'\n | 'insight-number-untraced'\n | 'insight-direction'\n | 'insight-too-many'\n\nexport interface AiInsightVerdict {\n insight: AiInsight\n findings: string[]\n}\n\nexport interface AiInsightCheck {\n /** The insights a person may read, in the order written. */\n kept: AiInsight[]\n /** The insights left out, each with why. */\n left: AiInsightVerdict[]\n /** The gap sentence, when it is one a person may read. */\n gap: string | null\n /** Every finding, in order, for the eval harness and the logs. */\n findings: string[]\n}\n\nconst MARKUP = /<\\/?[a-z][^>]*>|```|^#{1,6}\\s|\\*\\*/im\n\n/**\n * A number as a sentence writes it: an optional sign and currency symbol, the\n * digits with their thousands separators, the decimals, and a unit.\n */\nconst NUMBER = /(?<![\\p{L}\\p{N}_.])([+\\-−]?)([$€£¥]?)(\\d{1,3}(?:,\\d{3})+|\\d+)(?:\\.(\\d+))?(?:\\s?(%|percent\\b|k\\b|thousand\\b|m\\b|million\\b|seconds?\\b|secs?\\b|s\\b|minutes?\\b|mins?\\b|hours?\\b|hrs?\\b|h\\b))?/giu\n\n/** Minutes and seconds written together (`2m 04s`), read as one figure in seconds. */\nconst DURATION = /(?<![\\p{L}\\p{N}_.])(?:(\\d+)\\s?h(?:ours?|rs?)?\\s+)?(\\d+)\\s?m(?:in(?:utes?)?)?\\s+(\\d{1,2})\\s?s(?:ec(?:onds?)?)?\\b/giu\n\nconst RISING = /\\b(?:rose|rise[sn]?|rising|grew|grow(?:s|n|ing)?|increas(?:e|ed|es|ing)|up|higher|gain(?:ed|s)?|jump(?:ed|s)?|climb(?:ed|s)?|more)\\b/i\nconst FALLING = /\\b(?:fell|fall(?:s|en|ing)?|drop(?:ped|s)?|declin(?:e|ed|es|ing)|decreas(?:e|ed|es|ing)|down|lower|lost|shr[au]nk|less|fewer)\\b/i\n\ninterface WrittenNumber {\n /** The figure as written, unsigned, in the unit's base (a percent, seconds, a plain count). */\n value: number\n decimals: number\n negative: boolean\n unit: 'percent' | 'thousand' | 'million' | 'seconds' | 'minutes' | 'hours' | 'currency' | null\n /** Where in the text it starts, for the words before it. */\n at: number\n raw: string\n}\n\nfunction unitOf(symbol: string, unit: string | undefined): WrittenNumber['unit'] {\n const word = (unit ?? '').toLowerCase()\n if (word === '%' || word === 'percent') return 'percent'\n if (word === 'k' || word === 'thousand') return 'thousand'\n if (word === 'm' || word === 'million') return 'million'\n if (/^(?:seconds?|secs?|s)$/.test(word)) return 'seconds'\n if (/^(?:minutes?|mins?)$/.test(word)) return 'minutes'\n if (/^(?:hours?|hrs?|h)$/.test(word)) return 'hours'\n return symbol ? 'currency' : null\n}\n\n/** Every figure a sentence writes, durations written as minutes and seconds read as one. */\nexport function aiInsightNumbers(text: string): WrittenNumber[] {\n const found: WrittenNumber[] = []\n const covered: Array<[number, number]> = []\n for (const match of text.matchAll(DURATION)) {\n const hours = Number(match[1] ?? 0)\n const seconds = hours * 3_600 + Number(match[2]) * 60 + Number(match[3])\n const at = match.index ?? 0\n covered.push([at, at + match[0].length])\n found.push({ value: seconds, decimals: 0, negative: false, unit: 'seconds', at, raw: match[0] })\n }\n for (const match of text.matchAll(NUMBER)) {\n const at = match.index ?? 0\n if (covered.some(([start, end]) => at >= start && at < end)) continue\n const whole = match[3].replace(/,/g, '')\n const decimals = match[4] ?? ''\n found.push({\n value: Number(decimals ? `${whole}.${decimals}` : whole),\n decimals: decimals.length,\n negative: match[1] === '-' || match[1] === '−',\n unit: unitOf(match[2], match[5]),\n at,\n raw: match[0],\n })\n }\n return found.sort((a, b) => a.at - b.at)\n}\n\nconst round = (value: number, decimals: number) => {\n const scale = 10 ** decimals\n return Math.round(value * scale) / scale\n}\n\nconst truncate = (value: number, decimals: number) => {\n const scale = 10 ** decimals\n return Math.trunc(value * scale) / scale\n}\n\n/** Whether a written figure reads a cell's value, at the decimals written, rounded or cut. */\nfunction reads(written: WrittenNumber, cell: number, scale: number): boolean {\n const base = Math.abs(cell) / scale\n const value = Math.abs(written.value)\n return round(base, written.decimals) === value || truncate(base, written.decimals) === value\n}\n\n/** The scales a unit may read a column's cells at: a percent is not a count, and seconds are not dollars. */\nfunction scalesFor(written: WrittenNumber, kind: AiInsightTable['columns'][number]['kind']): number[] {\n switch (written.unit) {\n case 'percent':\n return kind === 'percent' || kind === 'change' || kind === 'number' ? [1] : []\n case 'currency':\n return kind === 'money' ? [1] : []\n case 'thousand':\n return kind === 'count' || kind === 'number' || kind === 'money' ? [1_000] : []\n case 'million':\n return kind === 'count' || kind === 'number' || kind === 'money'\n ? [1_000_000]\n : kind === 'duration'\n ? [60]\n : []\n case 'seconds':\n return kind === 'duration' ? [1] : []\n case 'minutes':\n return kind === 'duration' ? [60] : []\n case 'hours':\n return kind === 'duration' ? [3_600] : []\n default:\n return kind === 'date' || kind === 'text' ? [] : kind === 'duration' ? [1, 60] : [1]\n }\n}\n\ninterface CitedCell {\n table: AiInsightTable\n kind: AiInsightTable['columns'][number]['kind']\n value: number\n}\n\n/** The numbers a citation vouches for beyond its cells: the window, its dates, and how many rows. */\nfunction framingNumbers(tables: readonly AiInsightTable[], cites: readonly AiInsightCitation[]): Set<number> {\n const numbers = new Set<number>()\n for (const table of tables) {\n if (table.period) {\n numbers.add(table.period.days)\n for (const day of [table.period.from, table.period.to]) {\n const [year, month, date] = day.split('-').map(Number)\n numbers.add(year).add(month).add(date)\n }\n }\n numbers.add(table.rows.length)\n }\n for (const cite of cites) numbers.add(cite.rows.length)\n numbers.add(cites.reduce((total, cite) => total + cite.rows.length, 0))\n return numbers\n}\n\n/** Whether a figure's digits are written inside a cited label: a year in a campaign's name, a path's number. */\nfunction inLabel(written: WrittenNumber, labels: readonly string[]): boolean {\n if (written.unit !== null || written.negative) return false\n const digits = written.raw.replace(/[^\\d.]/g, '')\n return labels.some((label) => new RegExp(`(?<![\\\\d.])${digits.replace('.', '\\\\.')}(?![\\\\d.])`).test(label))\n}\n\n/** The sign the words just before a figure give it, or `null` when they give none. */\nfunction directionBefore(text: string, at: number): 'rise' | 'fall' | null {\n const before = text.slice(Math.max(0, at - 40), at)\n const words = before.split(/\\s+/).slice(-4).join(' ')\n const rise = RISING.test(words)\n const fall = FALLING.test(words)\n if (rise === fall) return null\n return rise ? 'rise' : 'fall'\n}\n\n/**\n * The headline a person may read. One that runs long is only dropped: the\n * insight keeps its sentence, because length says nothing about whether it is\n * true.\n */\nfunction insightHeadline(insight: AiInsight): string {\n const headline = typeof insight?.headline === 'string' ? insight.headline.trim() : ''\n return headline.length <= AI_INSIGHT_HEADLINE_MAX_CHARS ? headline : ''\n}\n\n/** One insight's findings against the tables the job read; empty when it traces. */\nexport function checkAiInsight(insight: AiInsight, tables: readonly AiInsightTable[]): string[] {\n const sentences = typeof insight?.text === 'string' ? insight.text.trim() : ''\n if (!sentences) return ['insight-empty']\n const findings: string[] = []\n if (sentences.length > AI_INSIGHT_MAX_CHARS) findings.push('insight-too-long')\n // The headline is held to everything the sentence is: it is the part a\n // person reads first, and often the only part.\n const headline = insightHeadline(insight)\n const text = headline ? `${headline}. ${sentences}` : sentences\n if (MARKUP.test(text)) findings.push('insight-markup')\n if (hasPersonalDetails(text)) findings.push('insight-personal-details')\n\n const cites = Array.isArray(insight.cites) ? insight.cites.slice(0, AI_INSIGHT_MAX_CITES) : []\n if (!cites.length || cites.every((cite) => !Array.isArray(cite?.rows) || !cite.rows.length)) {\n return [...findings, 'insight-no-citation']\n }\n const cells: CitedCell[] = []\n const labels: string[] = []\n const cited: AiInsightTable[] = []\n for (const cite of cites) {\n const table = tables.find((entry) => entry.ref === cite?.table)\n if (!table) {\n findings.push(`insight-unknown-table:${String(cite?.table)}`)\n continue\n }\n cited.push(table)\n for (const index of (cite.rows ?? []).slice(0, AI_INSIGHT_MAX_CITED_ROWS)) {\n const row = Number.isInteger(index) ? table.rows[index] : undefined\n if (!row) {\n findings.push(`insight-unknown-row:${table.ref}:${String(index)}`)\n continue\n }\n for (const column of table.columns) {\n const value = row[column.key]\n if (typeof value === 'number' && Number.isFinite(value)) {\n cells.push({ table, kind: column.kind, value })\n } else if (typeof value === 'string') {\n labels.push(value)\n if (column.kind === 'date') {\n for (const part of value.split('-').map(Number)) {\n cells.push({ table, kind: 'count', value: part })\n }\n }\n }\n }\n }\n }\n if (findings.some((finding) => finding.startsWith('insight-unknown-'))) return findings\n\n const framing = framingNumbers(cited, cites)\n for (const written of aiInsightNumbers(text)) {\n const matched = cells.filter((cell) =>\n scalesFor(written, cell.kind).some((scale) => reads(written, cell.value, scale)),\n )\n const framed =\n written.unit === null && written.decimals === 0 && !written.negative && framing.has(written.value)\n if (!matched.length && !framed && !inLabel(written, labels)) {\n findings.push(`insight-number-untraced:${written.raw.trim()}`)\n continue\n }\n // A rise or a fall is checked against the change it quotes, and only then:\n // \"down\" beside a count is not a claim about a sign.\n const changes = matched.filter((cell) => cell.kind === 'change' && cell.value !== 0)\n if (!changes.length || changes.length !== matched.length) continue\n const direction = directionBefore(text, written.at)\n if (!direction) continue\n const agrees = changes.some((cell) => (direction === 'rise' ? cell.value > 0 : cell.value < 0))\n if (!agrees) findings.push(`insight-direction:${written.raw.trim()}`)\n }\n return findings\n}\n\n/** The gap sentence a person may read: short, without figures and naming nobody; `null` otherwise. */\nexport function aiInsightGap(gap: unknown): string | null {\n if (typeof gap !== 'string') return null\n const text = gap.replace(/\\s+/g, ' ').trim()\n if (!text || text.length > AI_INSIGHT_GAP_MAX_CHARS || /\\d/.test(text) || MARKUP.test(text)) return null\n return hasPersonalDetails(text) ? null : text\n}\n\n/**\n * An answer held to the trace: the insights that trace kept in the order\n * written, the rest left out with why, and past `AI_INSIGHT_MAX_INSIGHTS`\n * nothing more is read.\n */\nexport function checkAiInsightAnswer(\n answer: Partial<AiInsightAnswer> | null | undefined,\n tables: readonly AiInsightTable[],\n): AiInsightCheck {\n const insights = Array.isArray(answer?.insights) ? answer.insights : []\n const kept: AiInsight[] = []\n const left: AiInsightVerdict[] = []\n const findings: string[] = []\n insights.forEach((insight, index) => {\n const own =\n index >= AI_INSIGHT_MAX_INSIGHTS ? ['insight-too-many'] : checkAiInsight(insight, tables)\n if (own.length) {\n left.push({ insight, findings: own })\n findings.push(...own)\n } else {\n const headline = insightHeadline(insight)\n kept.push({\n ...(headline ? { headline } : {}),\n text: insight.text.trim(),\n cites: insight.cites.slice(0, AI_INSIGHT_MAX_CITES).map((cite) => ({\n table: cite.table,\n rows: cite.rows.slice(0, AI_INSIGHT_MAX_CITED_ROWS),\n })),\n })\n }\n })\n const gap = aiInsightGap(answer?.gap)\n if (answer?.gap && !gap) findings.push('insight-gap-unreadable')\n return { kept, left, gap, findings }\n}\n"],"names":["hasPersonalDetails","AI_INSIGHT_GAP_MAX_CHARS","AI_INSIGHT_HEADLINE_MAX_CHARS","AI_INSIGHT_MAX_CHARS","AI_INSIGHT_MAX_CITED_ROWS","AI_INSIGHT_MAX_CITES","AI_INSIGHT_MAX_INSIGHTS","MARKUP","NUMBER","DURATION","RISING","FALLING","unitOf","symbol","unit","word","toLowerCase","test","aiInsightNumbers","text","found","covered","match","matchAll","hours","Number","seconds","at","index","push","length","value","decimals","negative","raw","some","start","end","whole","replace","sort","a","b","round","scale","Math","truncate","trunc","reads","written","cell","base","abs","scalesFor","kind","framingNumbers","tables","cites","numbers","Set","table","period","add","days","day","from","to","year","month","date","split","map","rows","cite","reduce","total","inLabel","labels","digits","label","RegExp","directionBefore","before","slice","max","words","join","rise","fall","insightHeadline","insight","headline","trim","checkAiInsight","sentences","findings","Array","isArray","every","cells","cited","find","entry","ref","String","row","isInteger","undefined","column","columns","key","isFinite","part","finding","startsWith","framing","matched","filter","framed","has","changes","direction","agrees","aiInsightGap","gap","checkAiInsightAnswer","answer","insights","kept","left","forEach","own"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,kBAAkB,QAAQ,6CAA4C;AAC/E,SACEC,wBAAwB,EACxBC,6BAA6B,EAC7BC,oBAAoB,EACpBC,yBAAyB,EACzBC,oBAAoB,EACpBC,uBAAuB,QAKlB,yBAAqB;AAoD5B,MAAMC,SAAS;AAEf;;;CAGC,GACD,MAAMC,SAAS;AAEf,oFAAoF,GACpF,MAAMC,WAAW;AAEjB,MAAMC,SAAS;AACf,MAAMC,UAAU;AAahB,SAASC,OAAOC,MAAc,EAAEC,IAAwB;IACtD,MAAMC,OAAO,CAACD,eAAAA,OAAQ,IAAIE,WAAW;IACrC,IAAID,SAAS,OAAOA,SAAS,WAAW,OAAO;IAC/C,IAAIA,SAAS,OAAOA,SAAS,YAAY,OAAO;IAChD,IAAIA,SAAS,OAAOA,SAAS,WAAW,OAAO;IAC/C,IAAI,yBAAyBE,IAAI,CAACF,OAAO,OAAO;IAChD,IAAI,uBAAuBE,IAAI,CAACF,OAAO,OAAO;IAC9C,IAAI,sBAAsBE,IAAI,CAACF,OAAO,OAAO;IAC7C,OAAOF,SAAS,aAAa;AAC/B;AAEA,0FAA0F,GAC1F,OAAO,SAASK,iBAAiBC,IAAY;IAC3C,MAAMC,QAAyB,EAAE;IACjC,MAAMC,UAAmC,EAAE;IAC3C,KAAK,MAAMC,SAASH,KAAKI,QAAQ,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;oBAC3B,CAAA;;QAEJ;IACF;IACA,MAAMwH,MAAMD,aAAaG,0BAAAA,OAAQF,GAAG;IACpC,IAAIE,CAAAA,0BAAAA,OAAQF,GAAG,KAAI,CAACA,KAAK7B,SAASlE,IAAI,CAAC;IACvC,OAAO;QAAEmG;QAAMC;QAAML;QAAK7B;IAAS;AACrC"}
@@ -28,6 +28,7 @@ import { notifyUsers } from "@aglyn/tenant-data-admin/server/notifications";
28
28
  import { renderSystemEmailContent, systemEmailBrand } from "@aglyn/tenant-data-admin/server/render-system-email";
29
29
  import { listOrgMembers, memberHasPermissionOnHost } from "@aglyn/tenant-data-admin/server/organizations";
30
30
  import { getServerReleaseFlagValues } from "@aglyn/tenant-data-admin/server/release-flags";
31
+ import { weeklySummaryEmailColors } from "@aglyn/tenant-data-admin/server/weekly-summary";
31
32
  import { safeEqual } from "@aglyn/tenant-data-admin/server/safe-equal";
32
33
  import { runAiInsightDigestSweep } from "../insights/ai-insight-digest.js";
33
34
  /**
@@ -150,7 +151,8 @@ import { runAiInsightDigestSweep } from "../insights/ai-insight-digest.js";
150
151
  },
151
152
  // An email link must be absolute; with no console URL configured the
152
153
  // digest says where to look without one.
153
- consoleOrigin: ((_process_env_NEXT_PUBLIC_CONSOLE_URL = process.env.NEXT_PUBLIC_CONSOLE_URL) != null ? _process_env_NEXT_PUBLIC_CONSOLE_URL : '').trim().replace(/\/+$/, '')
154
+ consoleOrigin: ((_process_env_NEXT_PUBLIC_CONSOLE_URL = process.env.NEXT_PUBLIC_CONSOLE_URL) != null ? _process_env_NEXT_PUBLIC_CONSOLE_URL : '').trim().replace(/\/+$/, ''),
155
+ colors: weeklySummaryEmailColors
154
156
  };
155
157
  const report = await runAiInsightDigestSweep(deps, {
156
158
  cursor
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/server/ai-insight-digest-route.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// lockdown-423: exempt — server-internal cron (x-cron-secret) with no user\n// caller; it asks each workspace's ai-generate pause before it creates a job,\n// and the jobs it creates are held by the same pause on the beat.\n\nimport { writeCronBeat } from '@aglyn/aglyn/app-utils/health-report'\nimport { rateLimitedRetryAtMs, sendEmail } from '@aglyn/shared-util-email'\nimport { withoutMailWithheldAccounts } from '@aglyn/tenant-data-admin/server/account-mail'\nimport { filterSuppressedEmails } from '@aglyn/tenant-data-admin/server/email-suppression'\nimport { meterPlatformEmail } from '@aglyn/tenant-data-admin/server/email-metering'\nimport { firebaseAdmin } from '@aglyn/tenant-data-admin/server/firebase-admin'\nimport { featureLockdownRefusal } from '@aglyn/tenant-data-admin/server/lockdown'\nimport { notifyUsers } from '@aglyn/tenant-data-admin/server/notifications'\nimport {\n renderSystemEmailContent,\n systemEmailBrand,\n} from '@aglyn/tenant-data-admin/server/render-system-email'\nimport { listOrgMembers, memberHasPermissionOnHost } from '@aglyn/tenant-data-admin/server/organizations'\nimport { getServerReleaseFlagValues } from '@aglyn/tenant-data-admin/server/release-flags'\nimport { safeEqual } from '@aglyn/tenant-data-admin/server/safe-equal'\nimport {\n AI_INSIGHTS_DIGEST_CRON_ID,\n runAiInsightDigestSweep,\n type AiInsightDigestDeps,\n} from '../insights/ai-insight-digest'\n\n/**\n * The weekly insights' scheduled route (AGL-2915):\n * `POST /api/admin/ai-insights-digest`.\n *\n * Cloud Scheduler calls it at 06:00 and 14:00 UTC through\n * `consoleAiInsightsDigest` in `cloud/functions`, on the console's\n * `CRON_SECRET`: 501 while the secret is unset, 401 without it. Monday's\n * first run makes the week's digests, which the AI jobs beat then writes, and\n * every run after it delivers what is written — see `ai-insight-digest.ts`.\n * `/api/admin/` is the path because the console's edge lets the cron secret's\n * header through there. It stamps `ai-insights-digest` for\n * `/api/health/crons` on every authorized call.\n */\nexport async function POST(request: Request): Promise<Response> {\n if (request.method !== 'POST') {\n return Response.json({ error: 'Method not allowed' }, { status: 405 })\n }\n const secret = process.env.CRON_SECRET\n if (!secret) {\n return Response.json({ error: 'The weekly insights are not configured (CRON_SECRET).' }, { status: 501 })\n }\n if (\n !safeEqual(request.headers.get('x-cron-secret'), secret) &&\n !safeEqual(request.headers.get('authorization'), `Bearer ${secret}`)\n ) {\n return Response.json({ error: 'Unauthenticated' }, { status: 401 })\n }\n const firestore = firebaseAdmin.app().firestore()\n // The inventory row's id, written out: `cron-beat-wiring.spec.ts` finds a\n // job's stamp by the quoted id beside the call.\n await writeCronBeat(firestore, 'ai-insights-digest' satisfies typeof AI_INSIGHTS_DIGEST_CRON_ID)\n\n let cursor: string | null = null\n try {\n const body = (await request.json()) as { cursor?: unknown } | null\n const raw = body?.cursor\n cursor = typeof raw === 'string' && raw && !raw.includes('/') ? raw : null\n } catch {\n // A bodyless POST is the first call of a run.\n }\n\n try {\n // The platform switch holds the whole run, as it holds the jobs beat.\n if (await featureLockdownRefusal({ feature: 'ai-generate' })) {\n return Response.json({ held: true, done: true, nextCursor: null }, { status: 200 })\n }\n const flags = await getServerReleaseFlagValues()\n const deps: AiInsightDigestDeps = {\n firestore,\n now: new Date(),\n flagValue: flags['release_ai_generative'],\n // The digest's audience: a locked or disabled account is not told\n // (AGL-3418).\n listMembers: async (orgId) => {\n const members = await listOrgMembers(orgId)\n const reachable = new Set(\n await withoutMailWithheldAccounts(members.map((member) => member.$id)),\n )\n return members.filter((member) => reachable.has(member.$id))\n },\n mayGenerate: (orgId, hostId, member) => memberHasPermissionOnHost(orgId, hostId, member, 'ai.generate'),\n paused: async (orgId) => Boolean(await featureLockdownRefusal({ feature: 'ai-generate', orgId })),\n notify: (uid, payload) => notifyUsers([uid], { type: 'content.insightsDigest', ...payload }),\n send: async (email) => {\n const recipients = await filterSuppressedEmails([email.to], firestore)\n if (!recipients.length) return { sent: false, rateLimited: false }\n // The `ai-insights-digest` system email (AGL-3367), in the org's brand.\n const content = await renderSystemEmailContent(\n 'ai-insights-digest',\n { 'site.name': email.siteName, 'digest.body': email.text, ...email.merge },\n systemEmailBrand(email.org),\n { subject: email.subject, text: email.text },\n )\n const result = await sendEmail({\n to: recipients,\n ...content,\n fromName: email.fromName,\n context: 'ai-insights-digest',\n priority: 'bulk',\n })\n if (result.sent) {\n await meterPlatformEmail().catch(() => undefined)\n return { sent: true, rateLimited: false }\n }\n return { sent: false, rateLimited: rateLimitedRetryAtMs(result) !== null }\n },\n // An email link must be absolute; with no console URL configured the\n // digest says where to look without one.\n consoleOrigin: (process.env.NEXT_PUBLIC_CONSOLE_URL ?? '').trim().replace(/\\/+$/, ''),\n }\n const report = await runAiInsightDigestSweep(deps, { cursor })\n return Response.json(report, { status: 200 })\n } catch (error) {\n console.error('ai insights digest run failed', error)\n return Response.json({ error: 'The weekly insights run failed' }, { status: 500 })\n }\n}\n"],"names":["writeCronBeat","rateLimitedRetryAtMs","sendEmail","withoutMailWithheldAccounts","filterSuppressedEmails","meterPlatformEmail","firebaseAdmin","featureLockdownRefusal","notifyUsers","renderSystemEmailContent","systemEmailBrand","listOrgMembers","memberHasPermissionOnHost","getServerReleaseFlagValues","safeEqual","runAiInsightDigestSweep","POST","request","method","Response","json","error","status","secret","process","env","CRON_SECRET","headers","get","firestore","app","cursor","body","raw","includes","feature","held","done","nextCursor","flags","deps","now","Date","flagValue","listMembers","orgId","members","reachable","Set","map","member","$id","filter","has","mayGenerate","hostId","paused","Boolean","notify","uid","payload","type","send","email","recipients","to","length","sent","rateLimited","content","siteName","text","merge","org","subject","result","fromName","context","priority","catch","undefined","consoleOrigin","NEXT_PUBLIC_CONSOLE_URL","trim","replace","report","console"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GA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oBAAOC,aAAa;gBAAM;gBACjE,wEAAwE;gBACxE,MAAMC,UAAU,MAAM5D,yBACpB,sBACA;oBAAE,aAAasD,MAAMO,QAAQ;oBAAE,eAAeP,MAAMQ,IAAI;mBAAKR,MAAMS,KAAK,GACxE9D,iBAAiBqD,MAAMU,GAAG,GAC1B;oBAAEC,SAASX,MAAMW,OAAO;oBAAEH,MAAMR,MAAMQ,IAAI;gBAAC;gBAE7C,MAAMI,SAAS,MAAMzE,UAAU;oBAC7B+D,IAAID;mBACDK;oBACHO,UAAUb,MAAMa,QAAQ;oBACxBC,SAAS;oBACTC,UAAU;;gBAEZ,IAAIH,OAAOR,IAAI,EAAE;oBACf,MAAM9D,qBAAqB0E,KAAK,CAAC,IAAMC;oBACvC,OAAO;wBAAEb,MAAM;wBAAMC,aAAa;oBAAM;gBAC1C;gBACA,OAAO;oBAAED,MAAM;oBAAOC,aAAanE,qBAAqB0E,YAAY;gBAAK;YAC3E;YACA,qEAAqE;YACrE,yCAAyC;YACzCM,eAAe,EAACzD,uCAAAA,QAAQC,GAAG,CAACyD,uBAAuB,YAAnC1D,uCAAuC,IAAI2D,IAAI,GAAGC,OAAO,CAAC,QAAQ;QACpF;QACA,MAAMC,SAAS,MAAMtE,wBAAwByB,MAAM;YAAET;QAAO;QAC5D,OAAOZ,SAASC,IAAI,CAACiE,QAAQ;YAAE/D,QAAQ;QAAI;IAC7C,EAAE,OAAOD,OAAO;QACdiE,QAAQjE,KAAK,CAAC,iCAAiCA;QAC/C,OAAOF,SAASC,IAAI,CAAC;YAAEC,OAAO;QAAiC,GAAG;YAAEC,QAAQ;QAAI;IAClF;AACF"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/server/ai-insight-digest-route.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// lockdown-423: exempt — server-internal cron (x-cron-secret) with no user\n// caller; it asks each workspace's ai-generate pause before it creates a job,\n// and the jobs it creates are held by the same pause on the beat.\n\nimport { writeCronBeat } from '@aglyn/aglyn/app-utils/health-report'\nimport { rateLimitedRetryAtMs, sendEmail } from '@aglyn/shared-util-email'\nimport { withoutMailWithheldAccounts } from '@aglyn/tenant-data-admin/server/account-mail'\nimport { filterSuppressedEmails } from '@aglyn/tenant-data-admin/server/email-suppression'\nimport { meterPlatformEmail } from '@aglyn/tenant-data-admin/server/email-metering'\nimport { firebaseAdmin } from '@aglyn/tenant-data-admin/server/firebase-admin'\nimport { featureLockdownRefusal } from '@aglyn/tenant-data-admin/server/lockdown'\nimport { notifyUsers } from '@aglyn/tenant-data-admin/server/notifications'\nimport {\n renderSystemEmailContent,\n systemEmailBrand,\n} from '@aglyn/tenant-data-admin/server/render-system-email'\nimport { listOrgMembers, memberHasPermissionOnHost } from '@aglyn/tenant-data-admin/server/organizations'\nimport { getServerReleaseFlagValues } from '@aglyn/tenant-data-admin/server/release-flags'\nimport { weeklySummaryEmailColors } from '@aglyn/tenant-data-admin/server/weekly-summary'\nimport { safeEqual } from '@aglyn/tenant-data-admin/server/safe-equal'\nimport {\n AI_INSIGHTS_DIGEST_CRON_ID,\n runAiInsightDigestSweep,\n type AiInsightDigestDeps,\n} from '../insights/ai-insight-digest'\n\n/**\n * The weekly insights' scheduled route (AGL-2915):\n * `POST /api/admin/ai-insights-digest`.\n *\n * Cloud Scheduler calls it at 06:00 and 14:00 UTC through\n * `consoleAiInsightsDigest` in `cloud/functions`, on the console's\n * `CRON_SECRET`: 501 while the secret is unset, 401 without it. Monday's\n * first run makes the week's digests, which the AI jobs beat then writes, and\n * every run after it delivers what is written — see `ai-insight-digest.ts`.\n * `/api/admin/` is the path because the console's edge lets the cron secret's\n * header through there. It stamps `ai-insights-digest` for\n * `/api/health/crons` on every authorized call.\n */\nexport async function POST(request: Request): Promise<Response> {\n if (request.method !== 'POST') {\n return Response.json({ error: 'Method not allowed' }, { status: 405 })\n }\n const secret = process.env.CRON_SECRET\n if (!secret) {\n return Response.json({ error: 'The weekly insights are not configured (CRON_SECRET).' }, { status: 501 })\n }\n if (\n !safeEqual(request.headers.get('x-cron-secret'), secret) &&\n !safeEqual(request.headers.get('authorization'), `Bearer ${secret}`)\n ) {\n return Response.json({ error: 'Unauthenticated' }, { status: 401 })\n }\n const firestore = firebaseAdmin.app().firestore()\n // The inventory row's id, written out: `cron-beat-wiring.spec.ts` finds a\n // job's stamp by the quoted id beside the call.\n await writeCronBeat(firestore, 'ai-insights-digest' satisfies typeof AI_INSIGHTS_DIGEST_CRON_ID)\n\n let cursor: string | null = null\n try {\n const body = (await request.json()) as { cursor?: unknown } | null\n const raw = body?.cursor\n cursor = typeof raw === 'string' && raw && !raw.includes('/') ? raw : null\n } catch {\n // A bodyless POST is the first call of a run.\n }\n\n try {\n // The platform switch holds the whole run, as it holds the jobs beat.\n if (await featureLockdownRefusal({ feature: 'ai-generate' })) {\n return Response.json({ held: true, done: true, nextCursor: null }, { status: 200 })\n }\n const flags = await getServerReleaseFlagValues()\n const deps: AiInsightDigestDeps = {\n firestore,\n now: new Date(),\n flagValue: flags['release_ai_generative'],\n // The digest's audience: a locked or disabled account is not told\n // (AGL-3418).\n listMembers: async (orgId) => {\n const members = await listOrgMembers(orgId)\n const reachable = new Set(\n await withoutMailWithheldAccounts(members.map((member) => member.$id)),\n )\n return members.filter((member) => reachable.has(member.$id))\n },\n mayGenerate: (orgId, hostId, member) => memberHasPermissionOnHost(orgId, hostId, member, 'ai.generate'),\n paused: async (orgId) => Boolean(await featureLockdownRefusal({ feature: 'ai-generate', orgId })),\n notify: (uid, payload) => notifyUsers([uid], { type: 'content.insightsDigest', ...payload }),\n send: async (email) => {\n const recipients = await filterSuppressedEmails([email.to], firestore)\n if (!recipients.length) return { sent: false, rateLimited: false }\n // The `ai-insights-digest` system email (AGL-3367), in the org's brand.\n const content = await renderSystemEmailContent(\n 'ai-insights-digest',\n { 'site.name': email.siteName, 'digest.body': email.text, ...email.merge },\n systemEmailBrand(email.org),\n { subject: email.subject, text: email.text },\n )\n const result = await sendEmail({\n to: recipients,\n ...content,\n fromName: email.fromName,\n context: 'ai-insights-digest',\n priority: 'bulk',\n })\n if (result.sent) {\n await meterPlatformEmail().catch(() => undefined)\n return { sent: true, rateLimited: false }\n }\n return { sent: false, rateLimited: rateLimitedRetryAtMs(result) !== null }\n },\n // An email link must be absolute; with no console URL configured the\n // digest says where to look without one.\n consoleOrigin: (process.env.NEXT_PUBLIC_CONSOLE_URL ?? '').trim().replace(/\\/+$/, ''),\n colors: weeklySummaryEmailColors,\n }\n const report = await runAiInsightDigestSweep(deps, { cursor })\n return Response.json(report, { status: 200 })\n } catch (error) {\n console.error('ai insights digest run failed', error)\n return Response.json({ error: 'The weekly insights run failed' }, { status: 500 })\n }\n}\n"],"names":["writeCronBeat","rateLimitedRetryAtMs","sendEmail","withoutMailWithheldAccounts","filterSuppressedEmails","meterPlatformEmail","firebaseAdmin","featureLockdownRefusal","notifyUsers","renderSystemEmailContent","systemEmailBrand","listOrgMembers","memberHasPermissionOnHost","getServerReleaseFlagValues","weeklySummaryEmailColors","safeEqual","runAiInsightDigestSweep","POST","request","method","Response","json","error","status","secret","process","env","CRON_SECRET","headers","get","firestore","app","cursor","body","raw","includes","feature","held","done","nextCursor","flags","deps","now","Date","flagValue","listMembers","orgId","members","reachable","Set","map","member","$id","filter","has","mayGenerate","hostId","paused","Boolean","notify","uid","payload","type","send","email","recipients","to","length","sent","rateLimited","content","siteName","text","merge","org","subject","result","fromName","context","priority","catch","undefined","consoleOrigin","NEXT_PUBLIC_CONSOLE_URL","trim","replace","colors","report","console"],"mappings":";AAAA;;;;;;;;;;;;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,CAACmC,WAAWE,MAAM,EAAE,OAAO;oBAAEC,MAAM;oBAAOC,aAAa;gBAAM;gBACjE,wEAAwE;gBACxE,MAAMC,UAAU,MAAM7D,yBACpB,sBACA;oBAAE,aAAauD,MAAMO,QAAQ;oBAAE,eAAeP,MAAMQ,IAAI;mBAAKR,MAAMS,KAAK,GACxE/D,iBAAiBsD,MAAMU,GAAG,GAC1B;oBAAEC,SAASX,MAAMW,OAAO;oBAAEH,MAAMR,MAAMQ,IAAI;gBAAC;gBAE7C,MAAMI,SAAS,MAAM1E,UAAU;oBAC7BgE,IAAID;mBACDK;oBACHO,UAAUb,MAAMa,QAAQ;oBACxBC,SAAS;oBACTC,UAAU;;gBAEZ,IAAIH,OAAOR,IAAI,EAAE;oBACf,MAAM/D,qBAAqB2E,KAAK,CAAC,IAAMC;oBACvC,OAAO;wBAAEb,MAAM;wBAAMC,aAAa;oBAAM;gBAC1C;gBACA,OAAO;oBAAED,MAAM;oBAAOC,aAAapE,qBAAqB2E,YAAY;gBAAK;YAC3E;YACA,qEAAqE;YACrE,yCAAyC;YACzCM,eAAe,EAACzD,uCAAAA,QAAQC,GAAG,CAACyD,uBAAuB,YAAnC1D,uCAAuC,IAAI2D,IAAI,GAAGC,OAAO,CAAC,QAAQ;YAClFC,QAAQxE;QACV;QACA,MAAMyE,SAAS,MAAMvE,wBAAwByB,MAAM;YAAET;QAAO;QAC5D,OAAOZ,SAASC,IAAI,CAACkE,QAAQ;YAAEhE,QAAQ;QAAI;IAC7C,EAAE,OAAOD,OAAO;QACdkE,QAAQlE,KAAK,CAAC,iCAAiCA;QAC/C,OAAOF,SAASC,IAAI,CAAC;YAAEC,OAAO;QAAiC,GAAG;YAAEC,QAAQ;QAAI;IAClF;AACF"}
@@ -30,6 +30,10 @@ export declare const SITE_LAYOUT_PAGES: {
30
30
  readonly file: "aglyn-pricing.html";
31
31
  readonly url: "https://aglyn.com/pricing";
32
32
  };
33
+ readonly livePricing: {
34
+ readonly file: "aglyn-pricing-2026-11.html";
35
+ readonly url: "https://aglyn.com/pricing";
36
+ };
33
37
  readonly contact: {
34
38
  readonly file: "aglyn-contact.html";
35
39
  readonly url: "https://aglyn.com/contact";