@aglyn/plugins-ai 1.0.0-beta.285 → 1.0.0-beta.288

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 (228) hide show
  1. package/package.json +17 -17
  2. package/src/lib/assets/site-styles/nonprofit.webp +0 -0
  3. package/src/lib/assets/site-styles/professional.webp +0 -0
  4. package/src/lib/assets/site-styles/store.webp +0 -0
  5. package/src/lib/assets/site-styles/trades.webp +0 -0
  6. package/src/lib/components/ai-theme-proposal-card.component.js +12 -3
  7. package/src/lib/components/ai-theme-proposal-card.component.js.map +1 -1
  8. package/src/lib/declarations.js +5 -2
  9. package/src/lib/declarations.js.map +1 -1
  10. package/src/lib/declarations.server.js +12 -0
  11. package/src/lib/declarations.server.js.map +1 -1
  12. package/src/lib/jobs/ai-build-capabilities.d.ts +3 -1
  13. package/src/lib/jobs/ai-build-capabilities.js +27 -2
  14. package/src/lib/jobs/ai-build-capabilities.js.map +1 -1
  15. package/src/lib/jobs/ai-business-profile-prefill.js +6 -3
  16. package/src/lib/jobs/ai-business-profile-prefill.js.map +1 -1
  17. package/src/lib/jobs/ai-image-reads.d.ts +59 -0
  18. package/src/lib/jobs/ai-image-reads.js +138 -0
  19. package/src/lib/jobs/ai-image-reads.js.map +1 -0
  20. package/src/lib/jobs/ai-job-build-step.d.ts +29 -0
  21. package/src/lib/jobs/ai-job-build-step.js +83 -12
  22. package/src/lib/jobs/ai-job-build-step.js.map +1 -1
  23. package/src/lib/jobs/ai-job-duplicate-step.d.ts +2 -1
  24. package/src/lib/jobs/ai-job-duplicate-step.js +6 -6
  25. package/src/lib/jobs/ai-job-duplicate-step.js.map +1 -1
  26. package/src/lib/jobs/ai-job-import-step.d.ts +4 -2
  27. package/src/lib/jobs/ai-job-import-step.js +15 -11
  28. package/src/lib/jobs/ai-job-import-step.js.map +1 -1
  29. package/src/lib/jobs/ai-job-insight-step.d.ts +10 -0
  30. package/src/lib/jobs/ai-job-insight-step.js +23 -5
  31. package/src/lib/jobs/ai-job-insight-step.js.map +1 -1
  32. package/src/lib/jobs/ai-job-layout-language.js +2 -1
  33. package/src/lib/jobs/ai-job-layout-language.js.map +1 -1
  34. package/src/lib/jobs/ai-job-media-step.d.ts +2 -1
  35. package/src/lib/jobs/ai-job-media-step.js +6 -8
  36. package/src/lib/jobs/ai-job-media-step.js.map +1 -1
  37. package/src/lib/jobs/ai-job-navigation-step.d.ts +2 -1
  38. package/src/lib/jobs/ai-job-navigation-step.js +7 -9
  39. package/src/lib/jobs/ai-job-navigation-step.js.map +1 -1
  40. package/src/lib/jobs/ai-job-page-language.js +7 -1
  41. package/src/lib/jobs/ai-job-page-language.js.map +1 -1
  42. package/src/lib/jobs/ai-job-page-sections.js +16 -3
  43. package/src/lib/jobs/ai-job-page-sections.js.map +1 -1
  44. package/src/lib/jobs/ai-job-page-step.js +9 -1
  45. package/src/lib/jobs/ai-job-page-step.js.map +1 -1
  46. package/src/lib/jobs/ai-job-plan-step.d.ts +30 -8
  47. package/src/lib/jobs/ai-job-plan-step.js +78 -13
  48. package/src/lib/jobs/ai-job-plan-step.js.map +1 -1
  49. package/src/lib/jobs/ai-job-privacy-step.d.ts +4 -2
  50. package/src/lib/jobs/ai-job-privacy-step.js +14 -15
  51. package/src/lib/jobs/ai-job-privacy-step.js.map +1 -1
  52. package/src/lib/jobs/ai-job-products-step.js +5 -3
  53. package/src/lib/jobs/ai-job-products-step.js.map +1 -1
  54. package/src/lib/jobs/ai-job-settings-step.d.ts +2 -1
  55. package/src/lib/jobs/ai-job-settings-step.js +7 -8
  56. package/src/lib/jobs/ai-job-settings-step.js.map +1 -1
  57. package/src/lib/jobs/ai-job-site-content.d.ts +34 -1
  58. package/src/lib/jobs/ai-job-site-content.js +67 -8
  59. package/src/lib/jobs/ai-job-site-content.js.map +1 -1
  60. package/src/lib/jobs/ai-job-site-datasets.d.ts +53 -3
  61. package/src/lib/jobs/ai-job-site-datasets.js +300 -30
  62. package/src/lib/jobs/ai-job-site-datasets.js.map +1 -1
  63. package/src/lib/jobs/ai-job-site-step.js +6 -3
  64. package/src/lib/jobs/ai-job-site-step.js.map +1 -1
  65. package/src/lib/jobs/ai-job-site-store-pages.js +3 -3
  66. package/src/lib/jobs/ai-job-site-store-pages.js.map +1 -1
  67. package/src/lib/jobs/ai-job-text-step.js +2 -1
  68. package/src/lib/jobs/ai-job-text-step.js.map +1 -1
  69. package/src/lib/jobs/ai-job-tracking-step.d.ts +2 -1
  70. package/src/lib/jobs/ai-job-tracking-step.js +7 -8
  71. package/src/lib/jobs/ai-job-tracking-step.js.map +1 -1
  72. package/src/lib/jobs/ai-jobs-beat.d.ts +11 -7
  73. package/src/lib/jobs/ai-jobs-beat.js +18 -8
  74. package/src/lib/jobs/ai-jobs-beat.js.map +1 -1
  75. package/src/lib/jobs/ai-jobs-notify.d.ts +66 -1
  76. package/src/lib/jobs/ai-jobs-notify.js +136 -3
  77. package/src/lib/jobs/ai-jobs-notify.js.map +1 -1
  78. package/src/lib/jobs/ai-layout-stock-photos.d.ts +155 -7
  79. package/src/lib/jobs/ai-layout-stock-photos.js +1517 -220
  80. package/src/lib/jobs/ai-layout-stock-photos.js.map +1 -1
  81. package/src/lib/jobs/ai-product-image.d.ts +14 -0
  82. package/src/lib/jobs/ai-product-image.js +73 -21
  83. package/src/lib/jobs/ai-product-image.js.map +1 -1
  84. package/src/lib/jobs/ai-theme-brand-inputs.d.ts +9 -1
  85. package/src/lib/jobs/ai-theme-brand-inputs.js +28 -2
  86. package/src/lib/jobs/ai-theme-brand-inputs.js.map +1 -1
  87. package/src/lib/jobs/fixtures/ai-site-agl4065-datasets.d.ts +175 -0
  88. package/src/lib/jobs/fixtures/ai-site-agl4065-datasets.js +601 -0
  89. package/src/lib/jobs/fixtures/ai-site-agl4065-datasets.js.map +1 -0
  90. package/src/lib/jobs/fixtures/ai-site-agl4065-pages.d.ts +46 -0
  91. package/src/lib/jobs/fixtures/ai-site-agl4065-pages.js +2862 -0
  92. package/src/lib/jobs/fixtures/ai-site-agl4065-pages.js.map +1 -0
  93. package/src/lib/jobs/fixtures/ai-site-agl4065-plans.d.ts +74 -0
  94. package/src/lib/jobs/fixtures/ai-site-agl4065-plans.js +888 -0
  95. package/src/lib/jobs/fixtures/ai-site-agl4065-plans.js.map +1 -0
  96. package/src/lib/jobs/fixtures/ai-site-agl4092-datasets.d.ts +120 -0
  97. package/src/lib/jobs/fixtures/ai-site-agl4092-datasets.js +410 -0
  98. package/src/lib/jobs/fixtures/ai-site-agl4092-datasets.js.map +1 -0
  99. package/src/lib/jobs/fixtures/ai-stock-photo-agl4065-judge.d.ts +29 -0
  100. package/src/lib/jobs/fixtures/ai-stock-photo-agl4065-judge.js +81 -0
  101. package/src/lib/jobs/fixtures/ai-stock-photo-agl4065-judge.js.map +1 -0
  102. package/src/lib/jobs/fixtures/ai-stock-photo-agl4065-recordings.d.ts +87 -0
  103. package/src/lib/jobs/fixtures/ai-stock-photo-agl4065-recordings.js +225 -0
  104. package/src/lib/jobs/fixtures/ai-stock-photo-agl4065-recordings.js.map +1 -0
  105. package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-recordings.d.ts +26 -0
  106. package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-recordings.js +714 -0
  107. package/src/lib/jobs/fixtures/ai-stock-photo-agl4092-recordings.js.map +1 -0
  108. package/src/lib/layout-language/ai-layout-compiler.d.ts +11 -0
  109. package/src/lib/layout-language/ai-layout-compiler.js +194 -18
  110. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  111. package/src/lib/layout-language/ai-layout-copy.d.ts +37 -0
  112. package/src/lib/layout-language/ai-layout-copy.js +383 -3
  113. package/src/lib/layout-language/ai-layout-copy.js.map +1 -1
  114. package/src/lib/layout-language/ai-layout-design.d.ts +19 -0
  115. package/src/lib/layout-language/ai-layout-design.js +31 -11
  116. package/src/lib/layout-language/ai-layout-design.js.map +1 -1
  117. package/src/lib/layout-language/ai-layout-listings.d.ts +7 -1
  118. package/src/lib/layout-language/ai-layout-listings.js +9 -1
  119. package/src/lib/layout-language/ai-layout-listings.js.map +1 -1
  120. package/src/lib/layout-language/ai-layout-pictures.d.ts +39 -1
  121. package/src/lib/layout-language/ai-layout-pictures.js +141 -4
  122. package/src/lib/layout-language/ai-layout-pictures.js.map +1 -1
  123. package/src/lib/layout-language/ai-layout-storefront.d.ts +18 -4
  124. package/src/lib/layout-language/ai-layout-storefront.js +100 -20
  125. package/src/lib/layout-language/ai-layout-storefront.js.map +1 -1
  126. package/src/lib/model/ai-build-job.d.ts +7 -0
  127. package/src/lib/model/ai-build-job.js +36 -7
  128. package/src/lib/model/ai-build-job.js.map +1 -1
  129. package/src/lib/model/ai-build-plan.d.ts +28 -4
  130. package/src/lib/model/ai-build-plan.js +49 -9
  131. package/src/lib/model/ai-build-plan.js.map +1 -1
  132. package/src/lib/model/ai-build-progress.js +3 -1
  133. package/src/lib/model/ai-build-progress.js.map +1 -1
  134. package/src/lib/model/ai-job-notice.d.ts +8 -0
  135. package/src/lib/model/ai-job-notice.js +33 -0
  136. package/src/lib/model/ai-job-notice.js.map +1 -1
  137. package/src/lib/model/ai-job-plan-lines.d.ts +2 -1
  138. package/src/lib/model/ai-job-plan-lines.js +6 -1
  139. package/src/lib/model/ai-job-plan-lines.js.map +1 -1
  140. package/src/lib/model/ai-jobs.types.d.ts +8 -0
  141. package/src/lib/model/ai-jobs.types.js.map +1 -1
  142. package/src/lib/model/ai-permissions.d.ts +13 -0
  143. package/src/lib/model/ai-permissions.js +29 -1
  144. package/src/lib/model/ai-permissions.js.map +1 -1
  145. package/src/lib/model/ai-plan-said-sections.d.ts +12 -3
  146. package/src/lib/model/ai-plan-said-sections.js +22 -5
  147. package/src/lib/model/ai-plan-said-sections.js.map +1 -1
  148. package/src/lib/model/ai-products.d.ts +18 -0
  149. package/src/lib/model/ai-products.js +32 -0
  150. package/src/lib/model/ai-products.js.map +1 -1
  151. package/src/lib/model/ai-site-context.d.ts +6 -2
  152. package/src/lib/model/ai-site-context.js +8 -2
  153. package/src/lib/model/ai-site-context.js.map +1 -1
  154. package/src/lib/model/ai-site-inspiration.d.ts +3 -2
  155. package/src/lib/model/ai-site-inspiration.js +3 -2
  156. package/src/lib/model/ai-site-inspiration.js.map +1 -1
  157. package/src/lib/plugin.js +4 -13
  158. package/src/lib/plugin.js.map +1 -1
  159. package/src/lib/providers/anthropic.js +9 -2
  160. package/src/lib/providers/anthropic.js.map +1 -1
  161. package/src/lib/providers/catalog.js +14 -5
  162. package/src/lib/providers/catalog.js.map +1 -1
  163. package/src/lib/providers/contract.d.ts +24 -1
  164. package/src/lib/providers/contract.js.map +1 -1
  165. package/src/lib/providers/routing.js +5 -2
  166. package/src/lib/providers/routing.js.map +1 -1
  167. package/src/lib/runtime/ai-dataset-generation.d.ts +120 -1
  168. package/src/lib/runtime/ai-dataset-generation.js +352 -3
  169. package/src/lib/runtime/ai-dataset-generation.js.map +1 -1
  170. package/src/lib/runtime/ai-dev-replay.d.ts +1 -0
  171. package/src/lib/runtime/ai-dev-replay.js +4 -2
  172. package/src/lib/runtime/ai-dev-replay.js.map +1 -1
  173. package/src/lib/runtime/ai-doctrine-validators.d.ts +47 -3
  174. package/src/lib/runtime/ai-doctrine-validators.js +345 -28
  175. package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
  176. package/src/lib/runtime/ai-doctrine.d.ts +5 -4
  177. package/src/lib/runtime/ai-doctrine.js +10 -3
  178. package/src/lib/runtime/ai-doctrine.js.map +1 -1
  179. package/src/lib/runtime/ai-icon-library.d.ts +27 -1
  180. package/src/lib/runtime/ai-icon-library.js +30 -3
  181. package/src/lib/runtime/ai-icon-library.js.map +1 -1
  182. package/src/lib/runtime/ai-products-generation.d.ts +11 -1
  183. package/src/lib/runtime/ai-products-generation.js +51 -4
  184. package/src/lib/runtime/ai-products-generation.js.map +1 -1
  185. package/src/lib/runtime/assist-answer-cache.d.ts +2 -0
  186. package/src/lib/runtime/assist-answer-cache.js +5 -2
  187. package/src/lib/runtime/assist-answer-cache.js.map +1 -1
  188. package/src/lib/server/ai-allotments.js +7 -2
  189. package/src/lib/server/ai-allotments.js.map +1 -1
  190. package/src/lib/server/ai-experiment-versions.js +5 -5
  191. package/src/lib/server/ai-experiment-versions.js.map +1 -1
  192. package/src/lib/server/ai-host-permissions-roster.d.ts +25 -0
  193. package/src/lib/server/ai-host-permissions-roster.js +33 -0
  194. package/src/lib/server/ai-host-permissions-roster.js.map +1 -0
  195. package/src/lib/server/ai-host-permissions.js +8 -6
  196. package/src/lib/server/ai-host-permissions.js.map +1 -1
  197. package/src/lib/server/ai-image-reads-route.d.ts +17 -0
  198. package/src/lib/server/ai-image-reads-route.js +106 -0
  199. package/src/lib/server/ai-image-reads-route.js.map +1 -0
  200. package/src/lib/server/ai-seo-apply.js +5 -5
  201. package/src/lib/server/ai-seo-apply.js.map +1 -1
  202. package/src/lib/server/ai-site-import-route.js +7 -4
  203. package/src/lib/server/ai-site-import-route.js.map +1 -1
  204. package/src/lib/server/assist-build.d.ts +15 -1
  205. package/src/lib/server/assist-build.js +30 -3
  206. package/src/lib/server/assist-build.js.map +1 -1
  207. package/src/lib/server/assist-chat.d.ts +11 -7
  208. package/src/lib/server/assist-chat.js +185 -48
  209. package/src/lib/server/assist-chat.js.map +1 -1
  210. package/src/lib/server/assist-docs-query.d.ts +51 -0
  211. package/src/lib/server/assist-docs-query.js +57 -0
  212. package/src/lib/server/assist-docs-query.js.map +1 -0
  213. package/src/lib/server/assist-jobs-context.d.ts +102 -0
  214. package/src/lib/server/assist-jobs-context.js +227 -0
  215. package/src/lib/server/assist-jobs-context.js.map +1 -0
  216. package/src/lib/server/assist-view-context.d.ts +8 -4
  217. package/src/lib/server/assist-view-context.js +12 -7
  218. package/src/lib/server/assist-view-context.js.map +1 -1
  219. package/src/lib/server.js +12 -0
  220. package/src/lib/server.js.map +1 -1
  221. package/src/lib/tools/ai-dataset-tool.d.ts +11 -1
  222. package/src/lib/tools/ai-dataset-tool.js +24 -7
  223. package/src/lib/tools/ai-dataset-tool.js.map +1 -1
  224. package/src/lib/tools/ai-duplicate-resource-tool.js +5 -6
  225. package/src/lib/tools/ai-duplicate-resource-tool.js.map +1 -1
  226. package/src/lib/components/ai-collaborator-permissions-column.component.d.ts +0 -32
  227. package/src/lib/components/ai-collaborator-permissions-column.component.js +0 -132
  228. package/src/lib/components/ai-collaborator-permissions-column.component.js.map +0 -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 AiCollaboratorPermissionsCell = lazyWidget(\n 'AiCollaboratorPermissionsCell',\n () =>\n import('./components/ai-collaborator-permissions-column.component').then(\n (m) => m.AiCollaboratorPermissionsCell,\n ),\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 column (AGL-2927): whether each person\n // may open the AI doors on the site, per site, ahead of the columns\n // that report what they drew.\n {\n slot: 'hostMembers',\n widgetId: 'ai-collaborator-permissions',\n title: 'AI',\n column: { header: 'AI' },\n Component: AiCollaboratorPermissionsCell,\n },\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","AiCollaboratorPermissionsCell","then","m","AiSaveAsComponent","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,gCAAgCF,WACpC,iCACA,IACE,MAAM,CAAC,gEAA6DG,IAAI,CACtE,CAACC,IAAMA,EAAEF,6BAA6B;AAG5C,MAAMG,oBAAoBL,WAAW,qBAAqB,IACxD,MAAM,CAAC,kDAA+CG,IAAI,CACxD,CAACC,IAAMA,EAAEC,iBAAiB;AAG9B,MAAMC,2BAA2BN,WAAW,4BAA4B,IACtE,MAAM,CAAC,kDAA+CG,IAAI,CACxD,CAACC,IAAMA,EAAEE,wBAAwB;AAGrC,MAAMC,mBAAmBP,WAAW,oBAAoB,IACtD,MAAM,CAAC,kDAA+CG,IAAI,CACxD,CAACC,IAAMA,EAAEG,gBAAgB;AAG7B,MAAMC,oBAAoBR,WAAW,qBAAqB,IACxD,MAAM,CAAC,oDAAiDG,IAAI,CAC1D,CAACC,IAAMA,EAAEI,iBAAiB;AAG9B,MAAMC,gBAAgBT,WAAW,iBAAiB,IAChD,MAAM,CAAC,6CAA0CG,IAAI,CAAC,CAACC,IAAMA,EAAEM,OAAO;AAExE,MAAMC,wBAAwBX,WAAW,yBAAyB,IAChE,MAAM,CAAC,+CAA4CG,IAAI,CAAC,CAACC,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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: '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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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"}
@@ -146,7 +146,7 @@ const ANTHROPIC_VERSION = '2023-06-01';
146
146
  * itself refuses.
147
147
  */ export function buildAnthropicRequestBody(input) {
148
148
  var _input_effort, _ANTHROPIC_THINKING_OFF_input_model;
149
- var _input_tools, _aiCatalogEntry;
149
+ var _input_tools, _aiCatalogEntry, _aiCatalogEntry1;
150
150
  const conversation = Boolean(input.cacheConversation) && input.messages.length > 0;
151
151
  const breakpoints = input.system.filter((block)=>block.cacheBreakpoint).length + (conversation ? 1 : 0);
152
152
  if (breakpoints > ANTHROPIC_MAX_CACHE_BREAKPOINTS) {
@@ -182,6 +182,10 @@ const ANTHROPIC_VERSION = '2023-06-01';
182
182
  const thinking = settable ? input.thinking : undefined;
183
183
  const effort = settable ? (_input_effort = input.effort) != null ? _input_effort : ANTHROPIC_DEFAULT_EFFORT[input.model] : undefined;
184
184
  const thinkingOff = (_ANTHROPIC_THINKING_OFF_input_model = ANTHROPIC_THINKING_OFF[input.model]) != null ? _ANTHROPIC_THINKING_OFF_input_model : 'disabled';
185
+ // A named tool is forced only where the model takes a forced choice and
186
+ // thinking is sent off, which the API requires of one (AGL-4076); every
187
+ // other request, a named one on Claude Sonnet 5.5 included, chooses for itself.
188
+ const forced = input.toolChoice && (tools == null ? void 0 : tools.some((tool)=>tool.name === input.toolChoice)) && ((_aiCatalogEntry1 = aiCatalogEntry(input.model)) == null ? void 0 : _aiCatalogEntry1.capabilities.forcedToolChoice) === true && thinking === 'off' && thinkingOff === 'disabled' ? input.toolChoice : null;
185
189
  return _extends({
186
190
  model: input.model,
187
191
  max_tokens: input.maxTokens
@@ -208,7 +212,10 @@ const ANTHROPIC_VERSION = '2023-06-01';
208
212
  }))
209
213
  }, (tools == null ? void 0 : tools.length) ? {
210
214
  tools,
211
- tool_choice: {
215
+ tool_choice: forced ? {
216
+ type: 'tool',
217
+ name: forced
218
+ } : {
212
219
  type: 'auto'
213
220
  }
214
221
  } : {});
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/providers/anthropic.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 { aiBilledRatesForModel, aiCatalogEntry, aiModelIdsForProvider, estimateAiBilledUsd } from './catalog'\nimport { aiCacheWriteHourSurchargeUsd } from './cache-write-hour'\nimport {\n AiBatchUnfinishedError,\n AiUpstreamError,\n aiCacheMarkerTtls,\n type AiAccountProblem,\n type AiBatchOptions,\n type AiCacheTtl,\n type AiEffort,\n aiRawOutputOf,\n aiStoppedAtCeiling,\n aiTokenCount,\n aiToolInputOf,\n type AiMessage,\n type AiModelDescriptor,\n type AiProvider,\n type AiProviderRequest,\n type AiResult,\n type AiStreamEvent,\n type AiToolSchemaLimits,\n type AiToolUse,\n type AiUsage,\n} from './contract'\n\n/**\n * The Anthropic adapter (AGL-2903, behind the contract since AGL-2939):\n * the Messages API over raw `fetch`. No provider SDK is installed, and the\n * meter prices by model id from the catalog, so nothing an SDK would add\n * is used here. This file and the catalog are the only places in the\n * plugin that name the vendor's URL, header or model ids.\n *\n * ── Errors (AGL-2815) ─────────────────────────────────────────────────────\n *\n * Provider error text describes OUR account with the vendor — a key, a rate\n * limit, a balance — and names the vendor to a white-label org's users. It\n * never leaves this module as a message: a non-2xx answer becomes an\n * `AiUpstreamError` carrying the status, whether the failure is retryable\n * and a fixed customer-safe sentence; the provider's body goes to\n * `console.error` beside the request id, where an operator can find it.\n * A `refusal` stop is not an error at all — the tokens were spent and the\n * model answered — so it comes back as a typed `AiRefusal` result.\n */\n\nexport const ANTHROPIC_PROVIDER_ID = 'anthropic'\nexport const ANTHROPIC_API_KEY_ENV = 'ANTHROPIC_API_KEY'\nconst ANTHROPIC_HOST = 'api.anthropic.com'\nconst ANTHROPIC_URL = `https://${ANTHROPIC_HOST}/v1/messages`\nconst ANTHROPIC_BATCHES_URL = `https://${ANTHROPIC_HOST}/v1/messages/batches`\nconst ANTHROPIC_VERSION = '2023-06-01'\n\n/** The Messages API accepts at most this many `cache_control` markers. */\nexport const ANTHROPIC_MAX_CACHE_BREAKPOINTS = 4\n\n/**\n * What the Messages API compiles of one request's strict schemas, as its\n * structured-outputs documentation states the limits: 20 strict tools, 24\n * optional parameters and 16 parameters with union types, each a total over\n * every strict schema the request carries. Past any of them the request is\n * refused with a 400 before the model runs.\n *\n * `compiledSchemaBytes` is not one of those. The API also refuses a request\n * whose schemas compile to too large a grammar — \"Simplify your tool schemas\n * or reduce the number of strict tools\" — and states no size for it, so this\n * bound is measured rather than read (AGL-3096). Its evidence is two live\n * requests for the automation draft, the largest strict schema anything here\n * sends:\n *\n * - 8,757 bytes, refused for grammar size (`req_011CfC6Fif9iJvmKPTRgtLdp`,\n * 2026-09-19), with 1 strict tool, 0 optional parameters and 2 unions:\n * every published count was green;\n * - 3,807 bytes, served (`req_011CfELn62WVLeaNzwK4TWgb`, 2026-09-20), the\n * same tool with the guard lifted out of the steps' union and one variant\n * per set of fields.\n *\n * Everything else the plugin sends is smaller still, the next largest being\n * the theme tool at 2,410 bytes. The bound sits at what has been served, so a\n * schema that grows past it has to be proved live before the bound moves.\n */\nexport const ANTHROPIC_TOOL_SCHEMA_LIMITS: AiToolSchemaLimits = {\n strictTools: 20,\n optionalParameters: 24,\n unionParameters: 16,\n compiledSchemaBytes: 3_807,\n}\n\n/**\n * Whether a provider failure is the kind that clears on its own. Matched on\n * the status AND the error type, because the in-stream `error` event has no\n * status to go by.\n */\nexport function anthropicFailureIsRetryable(\n status: number | null,\n errorType: string | undefined,\n): boolean {\n return (\n status === 429 ||\n status === 529 ||\n errorType === 'rate_limit_error' ||\n errorType === 'overloaded_error'\n )\n}\n\n/**\n * Whether a failure is about the platform's Anthropic account rather than the\n * request (AGL-3377): a refused key, or a balance too low to answer.\n */\nexport function anthropicAccountProblem(\n status: number | null,\n error: { type?: string; message?: string } | null | undefined,\n): AiAccountProblem | null {\n if (status === 401 || status === 403) return 'credentials'\n if (error?.type === 'authentication_error' || error?.type === 'permission_error') {\n return 'credentials'\n }\n if (error?.type === 'billing_error' || /credit balance/i.test(error?.message ?? '')) {\n return 'credit'\n }\n return null\n}\n\n/** Anthropic's `usage` object, in the meter's shape. Missing fields read 0. */\nexport function anthropicUsageFrom(usage: unknown): AiUsage {\n const record = (usage ?? {}) as Record<string, unknown>\n // Part of `output_tokens`, and carried only where the response breaks them\n // down, so an answer that reports none says nothing rather than zero.\n const details = record['output_tokens_details']\n const thinking =\n details && typeof details === 'object'\n ? (details as Record<string, unknown>)['thinking_tokens']\n : undefined\n // The writes split by lifetime (AGL-3830). Only an hour-long write is kept,\n // because it is the one billed above the rate table's write rate, and only\n // where there was one, so every five-minute exchange keeps its shape.\n const creation = record['cache_creation']\n const hour =\n creation && typeof creation === 'object'\n ? aiTokenCount((creation as Record<string, unknown>)['ephemeral_1h_input_tokens'])\n : 0\n return {\n inputTokens: aiTokenCount(record['input_tokens']),\n outputTokens: aiTokenCount(record['output_tokens']),\n cacheReadTokens: aiTokenCount(record['cache_read_input_tokens']),\n cacheWriteTokens: aiTokenCount(record['cache_creation_input_tokens']),\n ...(hour > 0 ? { cacheWriteHourTokens: hour } : {}),\n ...(thinking === undefined ? {} : { thinkingTokens: aiTokenCount(thinking) }),\n }\n}\n\n/** What an exchange draws, its hour-long cache writes included (AGL-3830). */\nfunction anthropicBilledUsd(usage: AiUsage, model: string): number {\n const usd = estimateAiBilledUsd(usage, model) + aiCacheWriteHourSurchargeUsd(usage, aiBilledRatesForModel(model))\n return Math.round(usd * 1_000_000) / 1_000_000\n}\n\n/**\n * How \"thinking off\" is said to a model that refuses `{type: \"disabled\"}`.\n * Claude Sonnet 5.5 turns it off only through `between_tools` (accepted at\n * effort high or below, which is every effort the contract names); Claude\n * Opus 5.5 cannot turn it off at all, so the field is left out and the\n * model's adaptive thinking runs. Every other model takes `disabled`.\n */\nconst ANTHROPIC_THINKING_OFF: Readonly<Record<string, 'between_tools' | 'omit'>> = {\n 'claude-sonnet-5-5': 'between_tools',\n 'claude-opus-5-5': 'omit',\n}\n\n/**\n * The effort a request that names none is sent, for a model whose own\n * default is lower than its siblings': Claude Opus 5.5 defaults to medium,\n * where Claude Opus 5 defaults to high.\n */\nconst ANTHROPIC_DEFAULT_EFFORT: Readonly<Record<string, AiEffort>> = {\n 'claude-opus-5-5': 'high',\n}\n\n/**\n * The Messages API body for a request. Exported so a spec can assert the\n * wire shape without a network. The cache-prefix rule is enforced by the\n * runtime before the request reaches any adapter; this maps the surviving\n * breakpoints onto `cache_control` and refuses only the count the API\n * itself refuses.\n */\nexport function buildAnthropicRequestBody(\n input: Omit<AiProviderRequest, 'apiKey' | 'signal'> & { stream: boolean },\n): Record<string, unknown> {\n const conversation = Boolean(input.cacheConversation) && input.messages.length > 0\n const breakpoints = input.system.filter((block) => block.cacheBreakpoint).length + (conversation ? 1 : 0)\n if (breakpoints > ANTHROPIC_MAX_CACHE_BREAKPOINTS) {\n throw new Error(\n `${breakpoints} cache breakpoints; the Messages API allows ${ANTHROPIC_MAX_CACHE_BREAKPOINTS}`,\n )\n }\n // A lifetime per breakpoint (AGL-4050): the shared prompt's markers at the\n // route's lifetime, a site's block and the conversation at five minutes,\n // and never an hour after five minutes, which the API refuses.\n const ttls = aiCacheMarkerTtls({ ...input, cacheConversation: conversation })\n const system = input.system.map((block, index) => {\n const ttl = ttls.system[index]\n return { type: 'text', text: block.text, ...(ttl ? { cache_control: anthropicCacheControl(ttl) } : {}) }\n })\n const tools = input.tools?.map((tool) => ({\n name: tool.name,\n description: tool.description,\n input_schema: { ...tool.inputSchema, additionalProperties: false },\n strict: true,\n }))\n // A model that rejects an explicit thinking setting gets none, whatever\n // the door asked for, and no effort either: effort rides the same rule\n // (see the contract), and the catalog says which models those are.\n const settable = aiCatalogEntry(input.model)?.capabilities.thinking !== false\n const thinking = settable ? input.thinking : undefined\n const effort = settable ? (input.effort ?? ANTHROPIC_DEFAULT_EFFORT[input.model]) : undefined\n const thinkingOff = ANTHROPIC_THINKING_OFF[input.model] ?? 'disabled'\n return {\n model: input.model,\n max_tokens: input.maxTokens,\n ...(input.stream ? { stream: true } : {}),\n ...(thinking === 'off'\n ? thinkingOff === 'omit'\n ? {}\n : { thinking: { type: thinkingOff } }\n : thinking === 'adaptive'\n ? { thinking: { type: 'adaptive' } }\n : {}),\n ...(effort ? { output_config: { effort } } : {}),\n ...(system.length ? { system } : {}),\n messages: input.messages.map((message, index) => ({\n role: message.role,\n content: conversation\n ? anthropicBlocksOf(\n message,\n index === input.messages.length - 1 && ttls.conversation ? anthropicCacheControl(ttls.conversation) : null,\n )\n : anthropicContentOf(message),\n })),\n ...(tools?.length ? { tools, tool_choice: { type: 'auto' } } : {}),\n }\n}\n\n/** One marker's `cache_control`: the five minutes are the API's default, so only the hour is named. */\nfunction anthropicCacheControl(ttl: AiCacheTtl): Record<string, unknown> {\n return ttl === '1h' ? { type: 'ephemeral', ttl: '1h' } : { type: 'ephemeral' }\n}\n\n/**\n * A turn's content in the Messages API's shape: a text-only turn as the\n * string it is, and a turn with pictures as content blocks in order, each\n * picture a base64 image block (AGL-2916).\n */\nfunction anthropicContentOf(message: AiMessage): string | Array<Record<string, unknown>> {\n if (typeof message.content === 'string') return message.content\n return message.content.map((part) =>\n part.type === 'image'\n ? { type: 'image', source: { type: 'base64', media_type: part.mediaType, data: part.data } }\n : { type: 'text', text: part.text },\n )\n}\n\n/**\n * A turn as content blocks whatever its shape, the last block carrying the\n * conversation's breakpoint when it is the request's last turn (AGL-3809).\n * Every turn of a request that caches its conversation is sent as blocks, so\n * a turn reads the same on the call that marked it and on every call after,\n * where it is no longer last.\n */\nfunction anthropicBlocksOf(\n message: AiMessage,\n cacheControl: Record<string, unknown> | null,\n): Array<Record<string, unknown>> {\n const content = anthropicContentOf(message)\n const blocks = typeof content === 'string' ? [{ type: 'text', text: content }] : content\n if (!cacheControl || !blocks.length) return blocks\n const last = blocks.length - 1\n return blocks.map((block, index) => (index === last ? { ...block, cache_control: cacheControl } : block))\n}\n\n/** The provider's request id, when it sent one — the log's join key. */\nfunction requestIdOf(response: Response): string | null {\n return response.headers?.get?.('request-id') ?? null\n}\n\nasync function send(\n input: AiProviderRequest,\n stream: boolean,\n): Promise<Response> {\n const body = buildAnthropicRequestBody({ ...input, stream })\n const response = await fetch(ANTHROPIC_URL, {\n method: 'POST',\n headers: {\n 'x-api-key': input.apiKey,\n 'anthropic-version': ANTHROPIC_VERSION,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body),\n ...(input.signal ? { signal: input.signal } : {}),\n })\n if (!response.ok || (stream && !response.body)) {\n const requestId = requestIdOf(response)\n const payload = (await response.json().catch(() => null)) as {\n error?: { type?: string; message?: string }\n } | null\n console.error('ai upstream error', {\n provider: ANTHROPIC_PROVIDER_ID,\n status: response.status,\n requestId,\n model: input.model,\n error: payload?.error ?? null,\n })\n throw new AiUpstreamError(\n response.status,\n anthropicFailureIsRetryable(response.status, payload?.error?.type),\n requestId,\n anthropicAccountProblem(response.status, payload?.error),\n )\n }\n return response\n}\n\nasync function complete(input: AiProviderRequest): Promise<AiResult> {\n const response = await send(input, false)\n return anthropicResultFrom(await response.json(), input.model)\n}\n\n/**\n * A Messages API answer as the contract's result: the shape `complete` reads\n * off the wire and a batch's succeeded entry carries. `priceFactor` is what a\n * discount leaves of the price (a batch's half).\n */\nexport function anthropicResultFrom(raw: unknown, model: string, priceFactor = 1): AiResult {\n const payload = raw as {\n content?: Array<Record<string, unknown>>\n stop_reason?: unknown\n usage?: unknown\n } | null\n const blocks = Array.isArray(payload?.content) ? payload.content : []\n const text = blocks\n .filter((block) => block?.['type'] === 'text')\n .map((block) => String(block['text'] ?? ''))\n .join('')\n const toolUse: AiToolUse[] = blocks\n .filter((block) => block?.['type'] === 'tool_use')\n .map((block) => ({\n name: String(block['name'] ?? ''),\n input: aiToolInputOf(block['input']),\n }))\n const usage = anthropicUsageFrom(payload?.usage)\n const estCostUsd = Math.round(anthropicBilledUsd(usage, model) * priceFactor * 1_000_000) / 1_000_000\n const stopReason =\n typeof payload?.stop_reason === 'string' && payload.stop_reason\n ? payload.stop_reason\n : null\n if (stopReason === 'refusal') {\n return { kind: 'refusal', text, usage, estCostUsd, stopReason }\n }\n return {\n kind: 'completion',\n text,\n toolUse,\n usage,\n estCostUsd,\n stopReason,\n // The blocks as the provider answered them, for a call its ceiling cut\n // off (AGL-3143): `toolUse` holds only what still parsed out of them.\n ...(aiStoppedAtCeiling(stopReason) ? { rawOutput: aiRawOutputOf(blocks) } : {}),\n }\n}\n\nasync function stream(input: AiProviderRequest): Promise<AsyncIterable<AiStreamEvent>> {\n const response = await send(input, true)\n return streamEvents(\n response.body as ReadableStream<Uint8Array>,\n input.model,\n requestIdOf(response),\n )\n}\n\n/**\n * Anthropic's SSE stream as contract events. Usage is taken from\n * `message_start` (input and cache figures) and `message_delta` (the\n * output count, and any cumulative input figures a newer API sends); the\n * `done` event carries whatever was known when the body ended, so a stream\n * cut short still meters what it cost.\n */\nasync function* streamEvents(\n body: ReadableStream<Uint8Array>,\n model: string,\n requestId: string | null,\n): AsyncGenerator<AiStreamEvent> {\n const decoder = new TextDecoder()\n const reader = body.getReader()\n const usage: AiUsage = {\n inputTokens: 0,\n outputTokens: 0,\n cacheReadTokens: 0,\n cacheWriteTokens: 0,\n }\n let stopReason: string | null = null\n /** Tool-use blocks in flight, by content index; input arrives in pieces. */\n const tools = new Map<number, { name: string; json: string }>()\n /**\n * What each tool call was actually written in, in the order its block\n * opened (AGL-3143). The `tool` events below carry only as much of these\n * as `aiToolInputOf` could still parse, so for a call the ceiling cut off\n * this is the one place the emitted bytes survive.\n */\n const written: string[] = []\n let buffer = ''\n let drained = false\n try {\n for (;;) {\n const { done, value } = await reader.read()\n if (done) {\n drained = true\n break\n }\n buffer += decoder.decode(value, { stream: true })\n const lines = buffer.split('\\n')\n buffer = lines.pop() ?? ''\n for (const line of lines) {\n if (!line.startsWith('data: ')) continue\n let event: Record<string, unknown>\n try {\n event = JSON.parse(line.slice('data: '.length))\n } catch {\n continue\n }\n const index = Number(event['index'])\n switch (event['type']) {\n case 'message_start': {\n const start = anthropicUsageFrom(\n (event['message'] as { usage?: unknown } | undefined)?.usage,\n )\n usage.inputTokens = start.inputTokens\n usage.cacheReadTokens = start.cacheReadTokens\n usage.cacheWriteTokens = start.cacheWriteTokens\n if (start.cacheWriteHourTokens) usage.cacheWriteHourTokens = start.cacheWriteHourTokens\n break\n }\n case 'content_block_start': {\n const block = event['content_block'] as\n | { type?: string; name?: string }\n | undefined\n if (block?.type === 'tool_use') {\n tools.set(index, { name: String(block.name ?? ''), json: '' })\n }\n break\n }\n case 'content_block_delta': {\n const delta = event['delta'] as\n | { type?: string; text?: string; partial_json?: string }\n | undefined\n if (delta?.type === 'text_delta' && delta.text) {\n yield { type: 'delta', text: delta.text }\n } else if (delta?.type === 'input_json_delta') {\n const tool = tools.get(index)\n if (tool) tool.json += delta.partial_json ?? ''\n }\n break\n }\n case 'content_block_stop': {\n const tool = tools.get(index)\n if (tool) {\n tools.delete(index)\n written.push(tool.json)\n yield { type: 'tool', name: tool.name, input: aiToolInputOf(tool.json) }\n }\n break\n }\n case 'message_delta': {\n const delta = anthropicUsageFrom(event['usage'])\n usage.outputTokens = delta.outputTokens || usage.outputTokens\n usage.inputTokens = delta.inputTokens || usage.inputTokens\n usage.cacheReadTokens = delta.cacheReadTokens || usage.cacheReadTokens\n usage.cacheWriteTokens = delta.cacheWriteTokens || usage.cacheWriteTokens\n // Kept where the breakdown is reported and left absent where it\n // is not (AGL-3143), never set to a zero the provider did not\n // send. A stream needs it for the reason a completion does: it\n // is the figure that accounts for a spent ceiling first, and it\n // arrives in the same usage object as the four above.\n if (delta.thinkingTokens !== undefined) usage.thinkingTokens = delta.thinkingTokens\n const reason = (event['delta'] as { stop_reason?: unknown } | undefined)\n ?.stop_reason\n if (typeof reason === 'string' && reason) stopReason = reason\n break\n }\n case 'error': {\n const error = event['error'] as\n | { type?: string; message?: string }\n | undefined\n console.error('ai upstream stream error', {\n provider: ANTHROPIC_PROVIDER_ID,\n requestId,\n model,\n error: error ?? null,\n })\n yield { type: 'error', retryable: anthropicFailureIsRetryable(null, error?.type) }\n break\n }\n default:\n break\n }\n }\n }\n } finally {\n // A consumer that stops iterating early — a client that hung up — must\n // not leave the provider generating into a socket nobody reads: cancel\n // tells the upstream to stop, and the tokens it has already produced are\n // the only ones billed.\n if (!drained) await reader.cancel().catch(() => undefined)\n reader.releaseLock()\n }\n // A message the ceiling ends mid-block never reaches that block's stop\n // event, so what it had written is still held in flight.\n for (const tool of tools.values()) written.push(tool.json)\n yield {\n type: 'done',\n usage,\n estCostUsd: anthropicBilledUsd(usage, model),\n stopReason,\n // What the model emitted into its tool calls, for a stream its ceiling\n // cut off (AGL-3143): the `tool` events carry only what parsed out.\n ...(aiStoppedAtCeiling(stopReason) ? { rawOutput: aiRawOutputOf(written.join('')) } : {}),\n }\n}\n\n/** What a batch's discount leaves of a request's price. */\nexport const ANTHROPIC_BATCH_PRICE_FACTOR = 0.5\n\nfunction batchHeaders(apiKey: string): Record<string, string> {\n return {\n 'x-api-key': apiKey,\n 'anthropic-version': ANTHROPIC_VERSION,\n 'Content-Type': 'application/json',\n }\n}\n\n/** A batch call that did not answer 2xx, as the contract's error. */\nasync function batchFailure(response: Response, model: string): Promise<AiUpstreamError> {\n const requestId = requestIdOf(response)\n const payload = (await response.json().catch(() => null)) as {\n error?: { type?: string; message?: string }\n } | null\n console.error('ai upstream batch error', {\n provider: ANTHROPIC_PROVIDER_ID,\n status: response.status,\n requestId,\n model,\n error: payload?.error ?? null,\n })\n return new AiUpstreamError(\n response.status,\n anthropicFailureIsRetryable(response.status, payload?.error?.type),\n requestId,\n anthropicAccountProblem(response.status, payload?.error),\n )\n}\n\n/** The batch as its create and poll calls describe it. */\ninterface AnthropicBatch {\n id: string\n processing_status?: string\n results_url?: string | null\n}\n\n/** Results a batch can end a request with that answer nothing yet: asked again, not failed (AGL-3781). */\nconst ANTHROPIC_BATCH_UNFINISHED = new Set(['canceled', 'expired'])\n\n/**\n * Many requests through the Message Batches API (AGL-3660): created as one\n * batch, polled until it has ended, its results read by `custom_id` — they\n * come back in any order — and each turned into the result `complete` would\n * have returned, at half the price. Development only: the live evals' batch\n * mode is the one caller, and no door waits minutes for an answer.\n *\n * A batch still processing when its wait runs out is canceled, and read once\n * the cancel has ended it (AGL-3781): a cancel keeps every answer the batch\n * already has, so those come back as results, and only the requests it never\n * reached come back as `AiBatchUnfinishedError`, for the caller to ask on\n * their own. Throwing away a round's paid-for answers because one batch was\n * slow is how a whole golden run lost its grades.\n */\nasync function completeBatch(\n requests: readonly AiProviderRequest[],\n options: AiBatchOptions = {},\n): Promise<Array<AiResult | Error>> {\n if (!requests.length) return []\n const apiKey = requests[0].apiKey\n const model = requests[0].model\n const pollMs = options.pollMs ?? 10_000\n const timeoutMs = options.timeoutMs ?? 60 * 60_000\n const cancelGraceMs = options.cancelGraceMs ?? 10 * 60_000\n const unfinished = (id: string, reason: string) => requests.map(() => new AiBatchUnfinishedError(id, reason))\n const created = await fetch(ANTHROPIC_BATCHES_URL, {\n method: 'POST',\n headers: batchHeaders(apiKey),\n body: JSON.stringify({\n requests: requests.map((request, index) => {\n const { apiKey: _key, signal: _signal, ...rest } = request\n return { custom_id: `r${index}`, params: buildAnthropicRequestBody({ ...rest, stream: false }) }\n }),\n }),\n })\n if (!created.ok) throw await batchFailure(created, model)\n let batch = (await created.json()) as AnthropicBatch\n const deadline = Date.now() + timeoutMs\n let cancelDeadline: number | null = null\n while (batch.processing_status !== 'ended') {\n if (cancelDeadline === null && Date.now() >= deadline) {\n console.warn(`[ai] batch ${batch.id} has not ended after ${timeoutMs} ms; canceling it to read what it answered`)\n await fetch(`${ANTHROPIC_BATCHES_URL}/${batch.id}/cancel`, { method: 'POST', headers: batchHeaders(apiKey) }).catch(\n () => undefined,\n )\n cancelDeadline = Date.now() + cancelGraceMs\n }\n // A cancel that never ends leaves no results to read; every request goes back unanswered.\n if (cancelDeadline !== null && Date.now() >= cancelDeadline) return unfinished(batch.id, 'cancel did not end')\n await new Promise((resolve) => setTimeout(resolve, pollMs))\n const polled = await fetch(`${ANTHROPIC_BATCHES_URL}/${batch.id}`, { headers: batchHeaders(apiKey) })\n if (!polled.ok) throw await batchFailure(polled, model)\n batch = (await polled.json()) as AnthropicBatch\n }\n if (!batch.results_url) {\n if (cancelDeadline !== null) return unfinished(batch.id, 'canceled with no results')\n throw new Error(`batch ${batch.id} ended with no results`)\n }\n const results = await fetch(batch.results_url, { headers: batchHeaders(apiKey) })\n if (!results.ok) throw await batchFailure(results, model)\n const byId = new Map<string, { type?: string; message?: unknown; error?: unknown }>()\n for (const line of (await results.text()).split('\\n')) {\n if (!line.trim()) continue\n const entry = JSON.parse(line) as { custom_id: string; result?: { type?: string; message?: unknown; error?: unknown } }\n byId.set(entry.custom_id, entry.result ?? {})\n }\n return requests.map((request, index) => {\n const result = byId.get(`r${index}`)\n if (result?.type === 'succeeded') {\n return anthropicResultFrom(result.message, request.model, ANTHROPIC_BATCH_PRICE_FACTOR)\n }\n const type = result?.type ?? 'missing'\n if (ANTHROPIC_BATCH_UNFINISHED.has(type) || type === 'missing') return new AiBatchUnfinishedError(batch.id, type)\n console.error('ai batch request not answered', {\n provider: ANTHROPIC_PROVIDER_ID,\n batchId: batch.id,\n customId: `r${index}`,\n result: type,\n error: result?.error ?? null,\n })\n return new AiUpstreamError(null, type === 'errored', batch.id, null)\n })\n}\n\nexport const anthropicProvider: AiProvider = {\n id: ANTHROPIC_PROVIDER_ID,\n label: 'Anthropic',\n apiKeyEnv: ANTHROPIC_API_KEY_ENV,\n readApiKey: () => process.env.ANTHROPIC_API_KEY?.trim() || undefined,\n endpointHost: ANTHROPIC_HOST,\n toolSchemaLimits: ANTHROPIC_TOOL_SCHEMA_LIMITS,\n models(): readonly AiModelDescriptor[] {\n return aiModelIdsForProvider(ANTHROPIC_PROVIDER_ID)\n .map((id) => aiCatalogEntry(id))\n .filter((entry): entry is NonNullable<typeof entry> => Boolean(entry))\n },\n complete,\n stream,\n completeBatch,\n}\n"],"names":["aiBilledRatesForModel","aiCatalogEntry","aiModelIdsForProvider","estimateAiBilledUsd","aiCacheWriteHourSurchargeUsd","AiBatchUnfinishedError","AiUpstreamError","aiCacheMarkerTtls","aiRawOutputOf","aiStoppedAtCeiling","aiTokenCount","aiToolInputOf","ANTHROPIC_PROVIDER_ID","ANTHROPIC_API_KEY_ENV","ANTHROPIC_HOST","ANTHROPIC_URL","ANTHROPIC_BATCHES_URL","ANTHROPIC_VERSION","ANTHROPIC_MAX_CACHE_BREAKPOINTS","ANTHROPIC_TOOL_SCHEMA_LIMITS","strictTools","optionalParameters","unionParameters","compiledSchemaBytes","anthropicFailureIsRetryable","status","errorType","anthropicAccountProblem","error","type","test","message","anthropicUsageFrom","usage","record","details","thinking","undefined","creation","hour","inputTokens","outputTokens","cacheReadTokens","cacheWriteTokens","cacheWriteHourTokens","thinkingTokens","anthropicBilledUsd","model","usd","Math","round","ANTHROPIC_THINKING_OFF","ANTHROPIC_DEFAULT_EFFORT","buildAnthropicRequestBody","input","conversation","Boolean","cacheConversation","messages","length","breakpoints","system","filter","block","cacheBreakpoint","Error","ttls","map","index","ttl","text","cache_control","anthropicCacheControl","tools","tool","name","description","input_schema","inputSchema","additionalProperties","strict","settable","capabilities","effort","thinkingOff","max_tokens","maxTokens","stream","output_config","role","content","anthropicBlocksOf","anthropicContentOf","tool_choice","part","source","media_type","mediaType","data","cacheControl","blocks","last","requestIdOf","response","headers","get","send","body","fetch","method","apiKey","JSON","stringify","signal","ok","payload","requestId","json","catch","console","provider","complete","anthropicResultFrom","raw","priceFactor","Array","isArray","String","join","toolUse","estCostUsd","stopReason","stop_reason","kind","rawOutput","streamEvents","decoder","TextDecoder","reader","getReader","Map","written","buffer","drained","lines","done","value","read","decode","split","pop","line","startsWith","event","parse","slice","Number","start","set","delta","partial_json","delete","push","reason","retryable","cancel","releaseLock","values","ANTHROPIC_BATCH_PRICE_FACTOR","batchHeaders","batchFailure","ANTHROPIC_BATCH_UNFINISHED","Set","completeBatch","requests","options","pollMs","timeoutMs","cancelGraceMs","unfinished","id","created","request","_key","_signal","rest","custom_id","params","batch","deadline","Date","now","cancelDeadline","processing_status","warn","Promise","resolve","setTimeout","polled","results_url","results","byId","entry","trim","result","has","batchId","customId","anthropicProvider","label","apiKeyEnv","readApiKey","process","env","ANTHROPIC_API_KEY","endpointHost","toolSchemaLimits","models"],"mappings":";;;;AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,qBAAqB,EAAEC,cAAc,EAAEC,qBAAqB,EAAEC,mBAAmB,QAAQ,eAAW;AAC7G,SAASC,4BAA4B,QAAQ,wBAAoB;AACjE,SACEC,sBAAsB,EACtBC,eAAe,EACfC,iBAAiB,EAKjBC,aAAa,EACbC,kBAAkB,EAClBC,YAAY,EACZC,aAAa,QAUR,gBAAY;AAEnB;;;;;;;;;;;;;;;;;CAiBC,GAED,OAAO,MAAMC,wBAAwB,YAAW;AAChD,OAAO,MAAMC,wBAAwB,oBAAmB;AACxD,MAAMC,iBAAiB;AACvB,MAAMC,gBAAgB,CAAC,QAAQ,EAAED,eAAe,YAAY,CAAC;AAC7D,MAAME,wBAAwB,CAAC,QAAQ,EAAEF,eAAe,oBAAoB,CAAC;AAC7E,MAAMG,oBAAoB;AAE1B,wEAAwE,GACxE,OAAO,MAAMC,kCAAkC,EAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;CAwBC,GACD,OAAO,MAAMC,+BAAmD;IAC9DC,aAAa;IACbC,oBAAoB;IACpBC,iBAAiB;IACjBC,qBAAqB;AACvB,EAAC;AAED;;;;CAIC,GACD,OAAO,SAASC,4BACdC,MAAqB,EACrBC,SAA6B;IAE7B,OACED,WAAW,OACXA,WAAW,OACXC,cAAc,sBACdA,cAAc;AAElB;AAEA;;;CAGC,GACD,OAAO,SAASC,wBACdF,MAAqB,EACrBG,KAA6D;;IAE7D,IAAIH,WAAW,OAAOA,WAAW,KAAK,OAAO;IAC7C,IAAIG,CAAAA,yBAAAA,MAAOC,IAAI,MAAK,0BAA0BD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,IAAI,OAAMtK;;IAC3DkL,cAAczM;IACd0M,kBAAkBrM;IAClBsM;QACE,OAAOvN,sBAAsBU,uBAC1BuD,GAAG,CAAC,CAACiH,KAAOnL,eAAemL,KAC3BtH,MAAM,CAAC,CAAC4I,QAA8ClJ,QAAQkJ;IACnE;IACAjF;IACAlC;IACAsF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/providers/anthropic.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 { aiBilledRatesForModel, aiCatalogEntry, aiModelIdsForProvider, estimateAiBilledUsd } from './catalog'\nimport { aiCacheWriteHourSurchargeUsd } from './cache-write-hour'\nimport {\n AiBatchUnfinishedError,\n AiUpstreamError,\n aiCacheMarkerTtls,\n type AiAccountProblem,\n type AiBatchOptions,\n type AiCacheTtl,\n type AiEffort,\n aiRawOutputOf,\n aiStoppedAtCeiling,\n aiTokenCount,\n aiToolInputOf,\n type AiMessage,\n type AiModelDescriptor,\n type AiProvider,\n type AiProviderRequest,\n type AiResult,\n type AiStreamEvent,\n type AiToolSchemaLimits,\n type AiToolUse,\n type AiUsage,\n} from './contract'\n\n/**\n * The Anthropic adapter (AGL-2903, behind the contract since AGL-2939):\n * the Messages API over raw `fetch`. No provider SDK is installed, and the\n * meter prices by model id from the catalog, so nothing an SDK would add\n * is used here. This file and the catalog are the only places in the\n * plugin that name the vendor's URL, header or model ids.\n *\n * ── Errors (AGL-2815) ─────────────────────────────────────────────────────\n *\n * Provider error text describes OUR account with the vendor — a key, a rate\n * limit, a balance — and names the vendor to a white-label org's users. It\n * never leaves this module as a message: a non-2xx answer becomes an\n * `AiUpstreamError` carrying the status, whether the failure is retryable\n * and a fixed customer-safe sentence; the provider's body goes to\n * `console.error` beside the request id, where an operator can find it.\n * A `refusal` stop is not an error at all — the tokens were spent and the\n * model answered — so it comes back as a typed `AiRefusal` result.\n */\n\nexport const ANTHROPIC_PROVIDER_ID = 'anthropic'\nexport const ANTHROPIC_API_KEY_ENV = 'ANTHROPIC_API_KEY'\nconst ANTHROPIC_HOST = 'api.anthropic.com'\nconst ANTHROPIC_URL = `https://${ANTHROPIC_HOST}/v1/messages`\nconst ANTHROPIC_BATCHES_URL = `https://${ANTHROPIC_HOST}/v1/messages/batches`\nconst ANTHROPIC_VERSION = '2023-06-01'\n\n/** The Messages API accepts at most this many `cache_control` markers. */\nexport const ANTHROPIC_MAX_CACHE_BREAKPOINTS = 4\n\n/**\n * What the Messages API compiles of one request's strict schemas, as its\n * structured-outputs documentation states the limits: 20 strict tools, 24\n * optional parameters and 16 parameters with union types, each a total over\n * every strict schema the request carries. Past any of them the request is\n * refused with a 400 before the model runs.\n *\n * `compiledSchemaBytes` is not one of those. The API also refuses a request\n * whose schemas compile to too large a grammar — \"Simplify your tool schemas\n * or reduce the number of strict tools\" — and states no size for it, so this\n * bound is measured rather than read (AGL-3096). Its evidence is two live\n * requests for the automation draft, the largest strict schema anything here\n * sends:\n *\n * - 8,757 bytes, refused for grammar size (`req_011CfC6Fif9iJvmKPTRgtLdp`,\n * 2026-09-19), with 1 strict tool, 0 optional parameters and 2 unions:\n * every published count was green;\n * - 3,807 bytes, served (`req_011CfELn62WVLeaNzwK4TWgb`, 2026-09-20), the\n * same tool with the guard lifted out of the steps' union and one variant\n * per set of fields.\n *\n * Everything else the plugin sends is smaller still, the next largest being\n * the theme tool at 2,410 bytes. The bound sits at what has been served, so a\n * schema that grows past it has to be proved live before the bound moves.\n */\nexport const ANTHROPIC_TOOL_SCHEMA_LIMITS: AiToolSchemaLimits = {\n strictTools: 20,\n optionalParameters: 24,\n unionParameters: 16,\n compiledSchemaBytes: 3_807,\n}\n\n/**\n * Whether a provider failure is the kind that clears on its own. Matched on\n * the status AND the error type, because the in-stream `error` event has no\n * status to go by.\n */\nexport function anthropicFailureIsRetryable(\n status: number | null,\n errorType: string | undefined,\n): boolean {\n return (\n status === 429 ||\n status === 529 ||\n errorType === 'rate_limit_error' ||\n errorType === 'overloaded_error'\n )\n}\n\n/**\n * Whether a failure is about the platform's Anthropic account rather than the\n * request (AGL-3377): a refused key, or a balance too low to answer.\n */\nexport function anthropicAccountProblem(\n status: number | null,\n error: { type?: string; message?: string } | null | undefined,\n): AiAccountProblem | null {\n if (status === 401 || status === 403) return 'credentials'\n if (error?.type === 'authentication_error' || error?.type === 'permission_error') {\n return 'credentials'\n }\n if (error?.type === 'billing_error' || /credit balance/i.test(error?.message ?? '')) {\n return 'credit'\n }\n return null\n}\n\n/** Anthropic's `usage` object, in the meter's shape. Missing fields read 0. */\nexport function anthropicUsageFrom(usage: unknown): AiUsage {\n const record = (usage ?? {}) as Record<string, unknown>\n // Part of `output_tokens`, and carried only where the response breaks them\n // down, so an answer that reports none says nothing rather than zero.\n const details = record['output_tokens_details']\n const thinking =\n details && typeof details === 'object'\n ? (details as Record<string, unknown>)['thinking_tokens']\n : undefined\n // The writes split by lifetime (AGL-3830). Only an hour-long write is kept,\n // because it is the one billed above the rate table's write rate, and only\n // where there was one, so every five-minute exchange keeps its shape.\n const creation = record['cache_creation']\n const hour =\n creation && typeof creation === 'object'\n ? aiTokenCount((creation as Record<string, unknown>)['ephemeral_1h_input_tokens'])\n : 0\n return {\n inputTokens: aiTokenCount(record['input_tokens']),\n outputTokens: aiTokenCount(record['output_tokens']),\n cacheReadTokens: aiTokenCount(record['cache_read_input_tokens']),\n cacheWriteTokens: aiTokenCount(record['cache_creation_input_tokens']),\n ...(hour > 0 ? { cacheWriteHourTokens: hour } : {}),\n ...(thinking === undefined ? {} : { thinkingTokens: aiTokenCount(thinking) }),\n }\n}\n\n/** What an exchange draws, its hour-long cache writes included (AGL-3830). */\nfunction anthropicBilledUsd(usage: AiUsage, model: string): number {\n const usd = estimateAiBilledUsd(usage, model) + aiCacheWriteHourSurchargeUsd(usage, aiBilledRatesForModel(model))\n return Math.round(usd * 1_000_000) / 1_000_000\n}\n\n/**\n * How \"thinking off\" is said to a model that refuses `{type: \"disabled\"}`.\n * Claude Sonnet 5.5 turns it off only through `between_tools` (accepted at\n * effort high or below, which is every effort the contract names); Claude\n * Opus 5.5 cannot turn it off at all, so the field is left out and the\n * model's adaptive thinking runs. Every other model takes `disabled`.\n */\nconst ANTHROPIC_THINKING_OFF: Readonly<Record<string, 'between_tools' | 'omit'>> = {\n 'claude-sonnet-5-5': 'between_tools',\n 'claude-opus-5-5': 'omit',\n}\n\n/**\n * The effort a request that names none is sent, for a model whose own\n * default is lower than its siblings': Claude Opus 5.5 defaults to medium,\n * where Claude Opus 5 defaults to high.\n */\nconst ANTHROPIC_DEFAULT_EFFORT: Readonly<Record<string, AiEffort>> = {\n 'claude-opus-5-5': 'high',\n}\n\n/**\n * The Messages API body for a request. Exported so a spec can assert the\n * wire shape without a network. The cache-prefix rule is enforced by the\n * runtime before the request reaches any adapter; this maps the surviving\n * breakpoints onto `cache_control` and refuses only the count the API\n * itself refuses.\n */\nexport function buildAnthropicRequestBody(\n input: Omit<AiProviderRequest, 'apiKey' | 'signal'> & { stream: boolean },\n): Record<string, unknown> {\n const conversation = Boolean(input.cacheConversation) && input.messages.length > 0\n const breakpoints = input.system.filter((block) => block.cacheBreakpoint).length + (conversation ? 1 : 0)\n if (breakpoints > ANTHROPIC_MAX_CACHE_BREAKPOINTS) {\n throw new Error(\n `${breakpoints} cache breakpoints; the Messages API allows ${ANTHROPIC_MAX_CACHE_BREAKPOINTS}`,\n )\n }\n // A lifetime per breakpoint (AGL-4050): the shared prompt's markers at the\n // route's lifetime, a site's block and the conversation at five minutes,\n // and never an hour after five minutes, which the API refuses.\n const ttls = aiCacheMarkerTtls({ ...input, cacheConversation: conversation })\n const system = input.system.map((block, index) => {\n const ttl = ttls.system[index]\n return { type: 'text', text: block.text, ...(ttl ? { cache_control: anthropicCacheControl(ttl) } : {}) }\n })\n const tools = input.tools?.map((tool) => ({\n name: tool.name,\n description: tool.description,\n input_schema: { ...tool.inputSchema, additionalProperties: false },\n strict: true,\n }))\n // A model that rejects an explicit thinking setting gets none, whatever\n // the door asked for, and no effort either: effort rides the same rule\n // (see the contract), and the catalog says which models those are.\n const settable = aiCatalogEntry(input.model)?.capabilities.thinking !== false\n const thinking = settable ? input.thinking : undefined\n const effort = settable ? (input.effort ?? ANTHROPIC_DEFAULT_EFFORT[input.model]) : undefined\n const thinkingOff = ANTHROPIC_THINKING_OFF[input.model] ?? 'disabled'\n // A named tool is forced only where the model takes a forced choice and\n // thinking is sent off, which the API requires of one (AGL-4076); every\n // other request, a named one on Claude Sonnet 5.5 included, chooses for itself.\n const forced =\n input.toolChoice &&\n tools?.some((tool) => tool.name === input.toolChoice) &&\n aiCatalogEntry(input.model)?.capabilities.forcedToolChoice === true &&\n thinking === 'off' &&\n thinkingOff === 'disabled'\n ? input.toolChoice\n : null\n return {\n model: input.model,\n max_tokens: input.maxTokens,\n ...(input.stream ? { stream: true } : {}),\n ...(thinking === 'off'\n ? thinkingOff === 'omit'\n ? {}\n : { thinking: { type: thinkingOff } }\n : thinking === 'adaptive'\n ? { thinking: { type: 'adaptive' } }\n : {}),\n ...(effort ? { output_config: { effort } } : {}),\n ...(system.length ? { system } : {}),\n messages: input.messages.map((message, index) => ({\n role: message.role,\n content: conversation\n ? anthropicBlocksOf(\n message,\n index === input.messages.length - 1 && ttls.conversation ? anthropicCacheControl(ttls.conversation) : null,\n )\n : anthropicContentOf(message),\n })),\n ...(tools?.length ? { tools, tool_choice: forced ? { type: 'tool', name: forced } : { type: 'auto' } } : {}),\n }\n}\n\n/** One marker's `cache_control`: the five minutes are the API's default, so only the hour is named. */\nfunction anthropicCacheControl(ttl: AiCacheTtl): Record<string, unknown> {\n return ttl === '1h' ? { type: 'ephemeral', ttl: '1h' } : { type: 'ephemeral' }\n}\n\n/**\n * A turn's content in the Messages API's shape: a text-only turn as the\n * string it is, and a turn with pictures as content blocks in order, each\n * picture a base64 image block (AGL-2916).\n */\nfunction anthropicContentOf(message: AiMessage): string | Array<Record<string, unknown>> {\n if (typeof message.content === 'string') return message.content\n return message.content.map((part) =>\n part.type === 'image'\n ? { type: 'image', source: { type: 'base64', media_type: part.mediaType, data: part.data } }\n : { type: 'text', text: part.text },\n )\n}\n\n/**\n * A turn as content blocks whatever its shape, the last block carrying the\n * conversation's breakpoint when it is the request's last turn (AGL-3809).\n * Every turn of a request that caches its conversation is sent as blocks, so\n * a turn reads the same on the call that marked it and on every call after,\n * where it is no longer last.\n */\nfunction anthropicBlocksOf(\n message: AiMessage,\n cacheControl: Record<string, unknown> | null,\n): Array<Record<string, unknown>> {\n const content = anthropicContentOf(message)\n const blocks = typeof content === 'string' ? [{ type: 'text', text: content }] : content\n if (!cacheControl || !blocks.length) return blocks\n const last = blocks.length - 1\n return blocks.map((block, index) => (index === last ? { ...block, cache_control: cacheControl } : block))\n}\n\n/** The provider's request id, when it sent one — the log's join key. */\nfunction requestIdOf(response: Response): string | null {\n return response.headers?.get?.('request-id') ?? null\n}\n\nasync function send(\n input: AiProviderRequest,\n stream: boolean,\n): Promise<Response> {\n const body = buildAnthropicRequestBody({ ...input, stream })\n const response = await fetch(ANTHROPIC_URL, {\n method: 'POST',\n headers: {\n 'x-api-key': input.apiKey,\n 'anthropic-version': ANTHROPIC_VERSION,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body),\n ...(input.signal ? { signal: input.signal } : {}),\n })\n if (!response.ok || (stream && !response.body)) {\n const requestId = requestIdOf(response)\n const payload = (await response.json().catch(() => null)) as {\n error?: { type?: string; message?: string }\n } | null\n console.error('ai upstream error', {\n provider: ANTHROPIC_PROVIDER_ID,\n status: response.status,\n requestId,\n model: input.model,\n error: payload?.error ?? null,\n })\n throw new AiUpstreamError(\n response.status,\n anthropicFailureIsRetryable(response.status, payload?.error?.type),\n requestId,\n anthropicAccountProblem(response.status, payload?.error),\n )\n }\n return response\n}\n\nasync function complete(input: AiProviderRequest): Promise<AiResult> {\n const response = await send(input, false)\n return anthropicResultFrom(await response.json(), input.model)\n}\n\n/**\n * A Messages API answer as the contract's result: the shape `complete` reads\n * off the wire and a batch's succeeded entry carries. `priceFactor` is what a\n * discount leaves of the price (a batch's half).\n */\nexport function anthropicResultFrom(raw: unknown, model: string, priceFactor = 1): AiResult {\n const payload = raw as {\n content?: Array<Record<string, unknown>>\n stop_reason?: unknown\n usage?: unknown\n } | null\n const blocks = Array.isArray(payload?.content) ? payload.content : []\n const text = blocks\n .filter((block) => block?.['type'] === 'text')\n .map((block) => String(block['text'] ?? ''))\n .join('')\n const toolUse: AiToolUse[] = blocks\n .filter((block) => block?.['type'] === 'tool_use')\n .map((block) => ({\n name: String(block['name'] ?? ''),\n input: aiToolInputOf(block['input']),\n }))\n const usage = anthropicUsageFrom(payload?.usage)\n const estCostUsd = Math.round(anthropicBilledUsd(usage, model) * priceFactor * 1_000_000) / 1_000_000\n const stopReason =\n typeof payload?.stop_reason === 'string' && payload.stop_reason\n ? payload.stop_reason\n : null\n if (stopReason === 'refusal') {\n return { kind: 'refusal', text, usage, estCostUsd, stopReason }\n }\n return {\n kind: 'completion',\n text,\n toolUse,\n usage,\n estCostUsd,\n stopReason,\n // The blocks as the provider answered them, for a call its ceiling cut\n // off (AGL-3143): `toolUse` holds only what still parsed out of them.\n ...(aiStoppedAtCeiling(stopReason) ? { rawOutput: aiRawOutputOf(blocks) } : {}),\n }\n}\n\nasync function stream(input: AiProviderRequest): Promise<AsyncIterable<AiStreamEvent>> {\n const response = await send(input, true)\n return streamEvents(\n response.body as ReadableStream<Uint8Array>,\n input.model,\n requestIdOf(response),\n )\n}\n\n/**\n * Anthropic's SSE stream as contract events. Usage is taken from\n * `message_start` (input and cache figures) and `message_delta` (the\n * output count, and any cumulative input figures a newer API sends); the\n * `done` event carries whatever was known when the body ended, so a stream\n * cut short still meters what it cost.\n */\nasync function* streamEvents(\n body: ReadableStream<Uint8Array>,\n model: string,\n requestId: string | null,\n): AsyncGenerator<AiStreamEvent> {\n const decoder = new TextDecoder()\n const reader = body.getReader()\n const usage: AiUsage = {\n inputTokens: 0,\n outputTokens: 0,\n cacheReadTokens: 0,\n cacheWriteTokens: 0,\n }\n let stopReason: string | null = null\n /** Tool-use blocks in flight, by content index; input arrives in pieces. */\n const tools = new Map<number, { name: string; json: string }>()\n /**\n * What each tool call was actually written in, in the order its block\n * opened (AGL-3143). The `tool` events below carry only as much of these\n * as `aiToolInputOf` could still parse, so for a call the ceiling cut off\n * this is the one place the emitted bytes survive.\n */\n const written: string[] = []\n let buffer = ''\n let drained = false\n try {\n for (;;) {\n const { done, value } = await reader.read()\n if (done) {\n drained = true\n break\n }\n buffer += decoder.decode(value, { stream: true })\n const lines = buffer.split('\\n')\n buffer = lines.pop() ?? ''\n for (const line of lines) {\n if (!line.startsWith('data: ')) continue\n let event: Record<string, unknown>\n try {\n event = JSON.parse(line.slice('data: '.length))\n } catch {\n continue\n }\n const index = Number(event['index'])\n switch (event['type']) {\n case 'message_start': {\n const start = anthropicUsageFrom(\n (event['message'] as { usage?: unknown } | undefined)?.usage,\n )\n usage.inputTokens = start.inputTokens\n usage.cacheReadTokens = start.cacheReadTokens\n usage.cacheWriteTokens = start.cacheWriteTokens\n if (start.cacheWriteHourTokens) usage.cacheWriteHourTokens = start.cacheWriteHourTokens\n break\n }\n case 'content_block_start': {\n const block = event['content_block'] as\n | { type?: string; name?: string }\n | undefined\n if (block?.type === 'tool_use') {\n tools.set(index, { name: String(block.name ?? ''), json: '' })\n }\n break\n }\n case 'content_block_delta': {\n const delta = event['delta'] as\n | { type?: string; text?: string; partial_json?: string }\n | undefined\n if (delta?.type === 'text_delta' && delta.text) {\n yield { type: 'delta', text: delta.text }\n } else if (delta?.type === 'input_json_delta') {\n const tool = tools.get(index)\n if (tool) tool.json += delta.partial_json ?? ''\n }\n break\n }\n case 'content_block_stop': {\n const tool = tools.get(index)\n if (tool) {\n tools.delete(index)\n written.push(tool.json)\n yield { type: 'tool', name: tool.name, input: aiToolInputOf(tool.json) }\n }\n break\n }\n case 'message_delta': {\n const delta = anthropicUsageFrom(event['usage'])\n usage.outputTokens = delta.outputTokens || usage.outputTokens\n usage.inputTokens = delta.inputTokens || usage.inputTokens\n usage.cacheReadTokens = delta.cacheReadTokens || usage.cacheReadTokens\n usage.cacheWriteTokens = delta.cacheWriteTokens || usage.cacheWriteTokens\n // Kept where the breakdown is reported and left absent where it\n // is not (AGL-3143), never set to a zero the provider did not\n // send. A stream needs it for the reason a completion does: it\n // is the figure that accounts for a spent ceiling first, and it\n // arrives in the same usage object as the four above.\n if (delta.thinkingTokens !== undefined) usage.thinkingTokens = delta.thinkingTokens\n const reason = (event['delta'] as { stop_reason?: unknown } | undefined)\n ?.stop_reason\n if (typeof reason === 'string' && reason) stopReason = reason\n break\n }\n case 'error': {\n const error = event['error'] as\n | { type?: string; message?: string }\n | undefined\n console.error('ai upstream stream error', {\n provider: ANTHROPIC_PROVIDER_ID,\n requestId,\n model,\n error: error ?? null,\n })\n yield { type: 'error', retryable: anthropicFailureIsRetryable(null, error?.type) }\n break\n }\n default:\n break\n }\n }\n }\n } finally {\n // A consumer that stops iterating early — a client that hung up — must\n // not leave the provider generating into a socket nobody reads: cancel\n // tells the upstream to stop, and the tokens it has already produced are\n // the only ones billed.\n if (!drained) await reader.cancel().catch(() => undefined)\n reader.releaseLock()\n }\n // A message the ceiling ends mid-block never reaches that block's stop\n // event, so what it had written is still held in flight.\n for (const tool of tools.values()) written.push(tool.json)\n yield {\n type: 'done',\n usage,\n estCostUsd: anthropicBilledUsd(usage, model),\n stopReason,\n // What the model emitted into its tool calls, for a stream its ceiling\n // cut off (AGL-3143): the `tool` events carry only what parsed out.\n ...(aiStoppedAtCeiling(stopReason) ? { rawOutput: aiRawOutputOf(written.join('')) } : {}),\n }\n}\n\n/** What a batch's discount leaves of a request's price. */\nexport const ANTHROPIC_BATCH_PRICE_FACTOR = 0.5\n\nfunction batchHeaders(apiKey: string): Record<string, string> {\n return {\n 'x-api-key': apiKey,\n 'anthropic-version': ANTHROPIC_VERSION,\n 'Content-Type': 'application/json',\n }\n}\n\n/** A batch call that did not answer 2xx, as the contract's error. */\nasync function batchFailure(response: Response, model: string): Promise<AiUpstreamError> {\n const requestId = requestIdOf(response)\n const payload = (await response.json().catch(() => null)) as {\n error?: { type?: string; message?: string }\n } | null\n console.error('ai upstream batch error', {\n provider: ANTHROPIC_PROVIDER_ID,\n status: response.status,\n requestId,\n model,\n error: payload?.error ?? null,\n })\n return new AiUpstreamError(\n response.status,\n anthropicFailureIsRetryable(response.status, payload?.error?.type),\n requestId,\n anthropicAccountProblem(response.status, payload?.error),\n )\n}\n\n/** The batch as its create and poll calls describe it. */\ninterface AnthropicBatch {\n id: string\n processing_status?: string\n results_url?: string | null\n}\n\n/** Results a batch can end a request with that answer nothing yet: asked again, not failed (AGL-3781). */\nconst ANTHROPIC_BATCH_UNFINISHED = new Set(['canceled', 'expired'])\n\n/**\n * Many requests through the Message Batches API (AGL-3660): created as one\n * batch, polled until it has ended, its results read by `custom_id` — they\n * come back in any order — and each turned into the result `complete` would\n * have returned, at half the price. Development only: the live evals' batch\n * mode is the one caller, and no door waits minutes for an answer.\n *\n * A batch still processing when its wait runs out is canceled, and read once\n * the cancel has ended it (AGL-3781): a cancel keeps every answer the batch\n * already has, so those come back as results, and only the requests it never\n * reached come back as `AiBatchUnfinishedError`, for the caller to ask on\n * their own. Throwing away a round's paid-for answers because one batch was\n * slow is how a whole golden run lost its grades.\n */\nasync function completeBatch(\n requests: readonly AiProviderRequest[],\n options: AiBatchOptions = {},\n): Promise<Array<AiResult | Error>> {\n if (!requests.length) return []\n const apiKey = requests[0].apiKey\n const model = requests[0].model\n const pollMs = options.pollMs ?? 10_000\n const timeoutMs = options.timeoutMs ?? 60 * 60_000\n const cancelGraceMs = options.cancelGraceMs ?? 10 * 60_000\n const unfinished = (id: string, reason: string) => requests.map(() => new AiBatchUnfinishedError(id, reason))\n const created = await fetch(ANTHROPIC_BATCHES_URL, {\n method: 'POST',\n headers: batchHeaders(apiKey),\n body: JSON.stringify({\n requests: requests.map((request, index) => {\n const { apiKey: _key, signal: _signal, ...rest } = request\n return { custom_id: `r${index}`, params: buildAnthropicRequestBody({ ...rest, stream: false }) }\n }),\n }),\n })\n if (!created.ok) throw await batchFailure(created, model)\n let batch = (await created.json()) as AnthropicBatch\n const deadline = Date.now() + timeoutMs\n let cancelDeadline: number | null = null\n while (batch.processing_status !== 'ended') {\n if (cancelDeadline === null && Date.now() >= deadline) {\n console.warn(`[ai] batch ${batch.id} has not ended after ${timeoutMs} ms; canceling it to read what it answered`)\n await fetch(`${ANTHROPIC_BATCHES_URL}/${batch.id}/cancel`, { method: 'POST', headers: batchHeaders(apiKey) }).catch(\n () => undefined,\n )\n cancelDeadline = Date.now() + cancelGraceMs\n }\n // A cancel that never ends leaves no results to read; every request goes back unanswered.\n if (cancelDeadline !== null && Date.now() >= cancelDeadline) return unfinished(batch.id, 'cancel did not end')\n await new Promise((resolve) => setTimeout(resolve, pollMs))\n const polled = await fetch(`${ANTHROPIC_BATCHES_URL}/${batch.id}`, { headers: batchHeaders(apiKey) })\n if (!polled.ok) throw await batchFailure(polled, model)\n batch = (await polled.json()) as AnthropicBatch\n }\n if (!batch.results_url) {\n if (cancelDeadline !== null) return unfinished(batch.id, 'canceled with no results')\n throw new Error(`batch ${batch.id} ended with no results`)\n }\n const results = await fetch(batch.results_url, { headers: batchHeaders(apiKey) })\n if (!results.ok) throw await batchFailure(results, model)\n const byId = new Map<string, { type?: string; message?: unknown; error?: unknown }>()\n for (const line of (await results.text()).split('\\n')) {\n if (!line.trim()) continue\n const entry = JSON.parse(line) as { custom_id: string; result?: { type?: string; message?: unknown; error?: unknown } }\n byId.set(entry.custom_id, entry.result ?? {})\n }\n return requests.map((request, index) => {\n const result = byId.get(`r${index}`)\n if (result?.type === 'succeeded') {\n return anthropicResultFrom(result.message, request.model, ANTHROPIC_BATCH_PRICE_FACTOR)\n }\n const type = result?.type ?? 'missing'\n if (ANTHROPIC_BATCH_UNFINISHED.has(type) || type === 'missing') return new AiBatchUnfinishedError(batch.id, type)\n console.error('ai batch request not answered', {\n provider: ANTHROPIC_PROVIDER_ID,\n batchId: batch.id,\n customId: `r${index}`,\n result: type,\n error: result?.error ?? null,\n })\n return new AiUpstreamError(null, type === 'errored', batch.id, null)\n })\n}\n\nexport const anthropicProvider: AiProvider = {\n id: ANTHROPIC_PROVIDER_ID,\n label: 'Anthropic',\n apiKeyEnv: ANTHROPIC_API_KEY_ENV,\n readApiKey: () => process.env.ANTHROPIC_API_KEY?.trim() || undefined,\n endpointHost: ANTHROPIC_HOST,\n toolSchemaLimits: ANTHROPIC_TOOL_SCHEMA_LIMITS,\n models(): readonly AiModelDescriptor[] {\n return aiModelIdsForProvider(ANTHROPIC_PROVIDER_ID)\n .map((id) => aiCatalogEntry(id))\n .filter((entry): entry is NonNullable<typeof entry> => Boolean(entry))\n },\n complete,\n stream,\n completeBatch,\n}\n"],"names":["aiBilledRatesForModel","aiCatalogEntry","aiModelIdsForProvider","estimateAiBilledUsd","aiCacheWriteHourSurchargeUsd","AiBatchUnfinishedError","AiUpstreamError","aiCacheMarkerTtls","aiRawOutputOf","aiStoppedAtCeiling","aiTokenCount","aiToolInputOf","ANTHROPIC_PROVIDER_ID","ANTHROPIC_API_KEY_ENV","ANTHROPIC_HOST","ANTHROPIC_URL","ANTHROPIC_BATCHES_URL","ANTHROPIC_VERSION","ANTHROPIC_MAX_CACHE_BREAKPOINTS","ANTHROPIC_TOOL_SCHEMA_LIMITS","strictTools","optionalParameters","unionParameters","compiledSchemaBytes","anthropicFailureIsRetryable","status","errorType","anthropicAccountProblem","error","type","test","message","anthropicUsageFrom","usage","record","details","thinking","undefined","creation","hour","inputTokens","outputTokens","cacheReadTokens","cacheWriteTokens","cacheWriteHourTokens","thinkingTokens","anthropicBilledUsd","model","usd","Math","round","ANTHROPIC_THINKING_OFF","ANTHROPIC_DEFAULT_EFFORT","buildAnthropicRequestBody","input","conversation","Boolean","cacheConversation","messages","length","breakpoints","system","filter","block","cacheBreakpoint","Error","ttls","map","index","ttl","text","cache_control","anthropicCacheControl","tools","tool","name","description","input_schema","inputSchema","additionalProperties","strict","settable","capabilities","effort","thinkingOff","forced","toolChoice","some","forcedToolChoice","max_tokens","maxTokens","stream","output_config","role","content","anthropicBlocksOf","anthropicContentOf","tool_choice","part","source","media_type","mediaType","data","cacheControl","blocks","last","requestIdOf","response","headers","get","send","body","fetch","method","apiKey","JSON","stringify","signal","ok","payload","requestId","json","catch","console","provider","complete","anthropicResultFrom","raw","priceFactor","Array","isArray","String","join","toolUse","estCostUsd","stopReason","stop_reason","kind","rawOutput","streamEvents","decoder","TextDecoder","reader","getReader","Map","written","buffer","drained","lines","done","value","read","decode","split","pop","line","startsWith","event","parse","slice","Number","start","set","delta","partial_json","delete","push","reason","retryable","cancel","releaseLock","values","ANTHROPIC_BATCH_PRICE_FACTOR","batchHeaders","batchFailure","ANTHROPIC_BATCH_UNFINISHED","Set","completeBatch","requests","options","pollMs","timeoutMs","cancelGraceMs","unfinished","id","created","request","_key","_signal","rest","custom_id","params","batch","deadline","Date","now","cancelDeadline","processing_status","warn","Promise","resolve","setTimeout","polled","results_url","results","byId","entry","trim","result","has","batchId","customId","anthropicProvider","label","apiKeyEnv","readApiKey","process","env","ANTHROPIC_API_KEY","endpointHost","toolSchemaLimits","models"],"mappings":";;;;AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,qBAAqB,EAAEC,cAAc,EAAEC,qBAAqB,EAAEC,mBAAmB,QAAQ,eAAW;AAC7G,SAASC,4BAA4B,QAAQ,wBAAoB;AACjE,SACEC,sBAAsB,EACtBC,eAAe,EACfC,iBAAiB,EAKjBC,aAAa,EACbC,kBAAkB,EAClBC,YAAY,EACZ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