@aglyn/plugins-ai 1.0.0-beta.143

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 (717) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +25 -0
  3. package/package.json +60 -0
  4. package/src/index.d.ts +21 -0
  5. package/src/index.js +22 -0
  6. package/src/index.js.map +1 -0
  7. package/src/lib/activity/ai-activity-actions.d.ts +106 -0
  8. package/src/lib/activity/ai-activity-actions.js +209 -0
  9. package/src/lib/activity/ai-activity-actions.js.map +1 -0
  10. package/src/lib/activity/ai-activity.d.ts +219 -0
  11. package/src/lib/activity/ai-activity.js +251 -0
  12. package/src/lib/activity/ai-activity.js.map +1 -0
  13. package/src/lib/billing/ai-overage-charge.d.ts +102 -0
  14. package/src/lib/billing/ai-overage-charge.js +258 -0
  15. package/src/lib/billing/ai-overage-charge.js.map +1 -0
  16. package/src/lib/billing/ai-overage-close.d.ts +62 -0
  17. package/src/lib/billing/ai-overage-close.js +129 -0
  18. package/src/lib/billing/ai-overage-close.js.map +1 -0
  19. package/src/lib/billing/ai-overage-cutover.d.ts +63 -0
  20. package/src/lib/billing/ai-overage-cutover.js +114 -0
  21. package/src/lib/billing/ai-overage-cutover.js.map +1 -0
  22. package/src/lib/billing/ai-overage-events.d.ts +77 -0
  23. package/src/lib/billing/ai-overage-events.js +174 -0
  24. package/src/lib/billing/ai-overage-events.js.map +1 -0
  25. package/src/lib/billing/ai-overage-gate.d.ts +147 -0
  26. package/src/lib/billing/ai-overage-gate.js +177 -0
  27. package/src/lib/billing/ai-overage-gate.js.map +1 -0
  28. package/src/lib/billing/ai-overage-ledger.d.ts +135 -0
  29. package/src/lib/billing/ai-overage-ledger.js +278 -0
  30. package/src/lib/billing/ai-overage-ledger.js.map +1 -0
  31. package/src/lib/billing/ai-overage-standing-writes.d.ts +110 -0
  32. package/src/lib/billing/ai-overage-standing-writes.js +205 -0
  33. package/src/lib/billing/ai-overage-standing-writes.js.map +1 -0
  34. package/src/lib/billing/ai-overage-standing.d.ts +168 -0
  35. package/src/lib/billing/ai-overage-standing.js +215 -0
  36. package/src/lib/billing/ai-overage-standing.js.map +1 -0
  37. package/src/lib/billing/ai-overage-trigger.d.ts +30 -0
  38. package/src/lib/billing/ai-overage-trigger.js +76 -0
  39. package/src/lib/billing/ai-overage-trigger.js.map +1 -0
  40. package/src/lib/components/ai-allotment-editor.component.d.ts +40 -0
  41. package/src/lib/components/ai-allotment-editor.component.js +213 -0
  42. package/src/lib/components/ai-allotment-editor.component.js.map +1 -0
  43. package/src/lib/components/ai-assist-actions-context.d.ts +13 -0
  44. package/src/lib/components/ai-assist-actions-context.js +21 -0
  45. package/src/lib/components/ai-assist-actions-context.js.map +1 -0
  46. package/src/lib/components/ai-assist-provider.component.d.ts +51 -0
  47. package/src/lib/components/ai-assist-provider.component.js +519 -0
  48. package/src/lib/components/ai-assist-provider.component.js.map +1 -0
  49. package/src/lib/components/ai-brief-dialog.component.d.ts +56 -0
  50. package/src/lib/components/ai-brief-dialog.component.js +319 -0
  51. package/src/lib/components/ai-brief-dialog.component.js.map +1 -0
  52. package/src/lib/components/ai-collaborator-permissions-column.component.d.ts +32 -0
  53. package/src/lib/components/ai-collaborator-permissions-column.component.js +132 -0
  54. package/src/lib/components/ai-collaborator-permissions-column.component.js.map +1 -0
  55. package/src/lib/components/ai-credits-card.component.d.ts +34 -0
  56. package/src/lib/components/ai-credits-card.component.js +131 -0
  57. package/src/lib/components/ai-credits-card.component.js.map +1 -0
  58. package/src/lib/components/ai-credits-columns.component.d.ts +56 -0
  59. package/src/lib/components/ai-credits-columns.component.js +118 -0
  60. package/src/lib/components/ai-credits-columns.component.js.map +1 -0
  61. package/src/lib/components/ai-crm-email-draft.component.d.ts +17 -0
  62. package/src/lib/components/ai-crm-email-draft.component.js +159 -0
  63. package/src/lib/components/ai-crm-email-draft.component.js.map +1 -0
  64. package/src/lib/components/ai-crm-import-mapping.component.d.ts +20 -0
  65. package/src/lib/components/ai-crm-import-mapping.component.js +167 -0
  66. package/src/lib/components/ai-crm-import-mapping.component.js.map +1 -0
  67. package/src/lib/components/ai-crm-record-card.component.d.ts +27 -0
  68. package/src/lib/components/ai-crm-record-card.component.js +263 -0
  69. package/src/lib/components/ai-crm-record-card.component.js.map +1 -0
  70. package/src/lib/components/ai-describe-automation.component.d.ts +31 -0
  71. package/src/lib/components/ai-describe-automation.component.js +226 -0
  72. package/src/lib/components/ai-describe-automation.component.js.map +1 -0
  73. package/src/lib/components/ai-describe-button.component.d.ts +39 -0
  74. package/src/lib/components/ai-describe-button.component.js +87 -0
  75. package/src/lib/components/ai-describe-button.component.js.map +1 -0
  76. package/src/lib/components/ai-describe-page.component.d.ts +26 -0
  77. package/src/lib/components/ai-describe-page.component.js +18 -0
  78. package/src/lib/components/ai-describe-page.component.js.map +1 -0
  79. package/src/lib/components/ai-experiment-cards.component.d.ts +75 -0
  80. package/src/lib/components/ai-experiment-cards.component.js +573 -0
  81. package/src/lib/components/ai-experiment-cards.component.js.map +1 -0
  82. package/src/lib/components/ai-explain-automation.component.d.ts +31 -0
  83. package/src/lib/components/ai-explain-automation.component.js +265 -0
  84. package/src/lib/components/ai-explain-automation.component.js.map +1 -0
  85. package/src/lib/components/ai-insight-dialog.component.d.ts +37 -0
  86. package/src/lib/components/ai-insight-dialog.component.js +441 -0
  87. package/src/lib/components/ai-insight-dialog.component.js.map +1 -0
  88. package/src/lib/components/ai-job-plan.component.d.ts +46 -0
  89. package/src/lib/components/ai-job-plan.component.js +192 -0
  90. package/src/lib/components/ai-job-plan.component.js.map +1 -0
  91. package/src/lib/components/ai-model-selector.component.d.ts +21 -0
  92. package/src/lib/components/ai-model-selector.component.js +109 -0
  93. package/src/lib/components/ai-model-selector.component.js.map +1 -0
  94. package/src/lib/components/ai-page-brief-dialog.component.d.ts +29 -0
  95. package/src/lib/components/ai-page-brief-dialog.component.js +27 -0
  96. package/src/lib/components/ai-page-brief-dialog.component.js.map +1 -0
  97. package/src/lib/components/ai-permissions-on-host.component.d.ts +55 -0
  98. package/src/lib/components/ai-permissions-on-host.component.js +91 -0
  99. package/src/lib/components/ai-permissions-on-host.component.js.map +1 -0
  100. package/src/lib/components/ai-product-copy-card.component.d.ts +25 -0
  101. package/src/lib/components/ai-product-copy-card.component.js +328 -0
  102. package/src/lib/components/ai-product-copy-card.component.js.map +1 -0
  103. package/src/lib/components/ai-product-import-option.component.d.ts +14 -0
  104. package/src/lib/components/ai-product-import-option.component.js +58 -0
  105. package/src/lib/components/ai-product-import-option.component.js.map +1 -0
  106. package/src/lib/components/ai-products-hub-card.component.d.ts +15 -0
  107. package/src/lib/components/ai-products-hub-card.component.js +418 -0
  108. package/src/lib/components/ai-products-hub-card.component.js.map +1 -0
  109. package/src/lib/components/ai-products-proposals.component.d.ts +19 -0
  110. package/src/lib/components/ai-products-proposals.component.js +547 -0
  111. package/src/lib/components/ai-products-proposals.component.js.map +1 -0
  112. package/src/lib/components/ai-save-as-component.component.d.ts +38 -0
  113. package/src/lib/components/ai-save-as-component.component.js +231 -0
  114. package/src/lib/components/ai-save-as-component.component.js.map +1 -0
  115. package/src/lib/components/ai-seo-audit-card.component.d.ts +9 -0
  116. package/src/lib/components/ai-seo-audit-card.component.js +620 -0
  117. package/src/lib/components/ai-seo-audit-card.component.js.map +1 -0
  118. package/src/lib/components/ai-seo-fields-card.component.d.ts +10 -0
  119. package/src/lib/components/ai-seo-fields-card.component.js +453 -0
  120. package/src/lib/components/ai-seo-fields-card.component.js.map +1 -0
  121. package/src/lib/components/ai-site-batch-card.component.d.ts +32 -0
  122. package/src/lib/components/ai-site-batch-card.component.js +531 -0
  123. package/src/lib/components/ai-site-batch-card.component.js.map +1 -0
  124. package/src/lib/components/ai-site-seo-start-card.component.d.ts +26 -0
  125. package/src/lib/components/ai-site-seo-start-card.component.js +178 -0
  126. package/src/lib/components/ai-site-seo-start-card.component.js.map +1 -0
  127. package/src/lib/components/ai-site-start-card.component.d.ts +19 -0
  128. package/src/lib/components/ai-site-start-card.component.js +348 -0
  129. package/src/lib/components/ai-site-start-card.component.js.map +1 -0
  130. package/src/lib/components/ai-template-collection-field.component.d.ts +32 -0
  131. package/src/lib/components/ai-template-collection-field.component.js +63 -0
  132. package/src/lib/components/ai-template-collection-field.component.js.map +1 -0
  133. package/src/lib/components/ai-theme-proposal-card.component.d.ts +6 -0
  134. package/src/lib/components/ai-theme-proposal-card.component.js +619 -0
  135. package/src/lib/components/ai-theme-proposal-card.component.js.map +1 -0
  136. package/src/lib/components/ai-usage-strip.component.d.ts +27 -0
  137. package/src/lib/components/ai-usage-strip.component.js +145 -0
  138. package/src/lib/components/ai-usage-strip.component.js.map +1 -0
  139. package/src/lib/components/assist-edit-canvas.d.ts +169 -0
  140. package/src/lib/components/assist-edit-canvas.js +636 -0
  141. package/src/lib/components/assist-edit-canvas.js.map +1 -0
  142. package/src/lib/components/assist-edit-card.component.d.ts +16 -0
  143. package/src/lib/components/assist-edit-card.component.js +181 -0
  144. package/src/lib/components/assist-edit-card.component.js.map +1 -0
  145. package/src/lib/components/assist-jobs-drawer.component.d.ts +72 -0
  146. package/src/lib/components/assist-jobs-drawer.component.js +626 -0
  147. package/src/lib/components/assist-jobs-drawer.component.js.map +1 -0
  148. package/src/lib/components/assist-panel.component.d.ts +136 -0
  149. package/src/lib/components/assist-panel.component.js +1099 -0
  150. package/src/lib/components/assist-panel.component.js.map +1 -0
  151. package/src/lib/components/assist-signals-page.component.d.ts +3 -0
  152. package/src/lib/components/assist-signals-page.component.js +1017 -0
  153. package/src/lib/components/assist-signals-page.component.js.map +1 -0
  154. package/src/lib/components/besigner-ai-controls.component.d.ts +29 -0
  155. package/src/lib/components/besigner-ai-controls.component.js +81 -0
  156. package/src/lib/components/besigner-ai-controls.component.js.map +1 -0
  157. package/src/lib/components/billing-ai-allotments.component.d.ts +36 -0
  158. package/src/lib/components/billing-ai-allotments.component.js +486 -0
  159. package/src/lib/components/billing-ai-allotments.component.js.map +1 -0
  160. package/src/lib/components/billing-ai-top-users.component.d.ts +44 -0
  161. package/src/lib/components/billing-ai-top-users.component.js +304 -0
  162. package/src/lib/components/billing-ai-top-users.component.js.map +1 -0
  163. package/src/lib/components/billing-assist-overage-card.component.d.ts +69 -0
  164. package/src/lib/components/billing-assist-overage-card.component.js +437 -0
  165. package/src/lib/components/billing-assist-overage-card.component.js.map +1 -0
  166. package/src/lib/components/host-ai-allotments.component.d.ts +40 -0
  167. package/src/lib/components/host-ai-allotments.component.js +239 -0
  168. package/src/lib/components/host-ai-allotments.component.js.map +1 -0
  169. package/src/lib/components/member-ai-allotment-card.component.d.ts +28 -0
  170. package/src/lib/components/member-ai-allotment-card.component.js +172 -0
  171. package/src/lib/components/member-ai-allotment-card.component.js.map +1 -0
  172. package/src/lib/components/member-ai-usage-card.component.d.ts +28 -0
  173. package/src/lib/components/member-ai-usage-card.component.js +240 -0
  174. package/src/lib/components/member-ai-usage-card.component.js.map +1 -0
  175. package/src/lib/components/staff-org-ai-card.component.d.ts +17 -0
  176. package/src/lib/components/staff-org-ai-card.component.js +739 -0
  177. package/src/lib/components/staff-org-ai-card.component.js.map +1 -0
  178. package/src/lib/components/staff-org-usage-ai-columns.component.d.ts +41 -0
  179. package/src/lib/components/staff-org-usage-ai-columns.component.js +65 -0
  180. package/src/lib/components/staff-org-usage-ai-columns.component.js.map +1 -0
  181. package/src/lib/components/staff-orgs-ai-spend-column.component.d.ts +28 -0
  182. package/src/lib/components/staff-orgs-ai-spend-column.component.js +89 -0
  183. package/src/lib/components/staff-orgs-ai-spend-column.component.js.map +1 -0
  184. package/src/lib/components/staff-user-ai-usage-card.component.d.ts +27 -0
  185. package/src/lib/components/staff-user-ai-usage-card.component.js +183 -0
  186. package/src/lib/components/staff-user-ai-usage-card.component.js.map +1 -0
  187. package/src/lib/components/use-ai-allotments.d.ts +49 -0
  188. package/src/lib/components/use-ai-allotments.js +171 -0
  189. package/src/lib/components/use-ai-allotments.js.map +1 -0
  190. package/src/lib/components/use-ai-crm-answer.d.ts +50 -0
  191. package/src/lib/components/use-ai-crm-answer.js +220 -0
  192. package/src/lib/components/use-ai-crm-answer.js.map +1 -0
  193. package/src/lib/components/use-ai-job-run.d.ts +51 -0
  194. package/src/lib/components/use-ai-job-run.js +176 -0
  195. package/src/lib/components/use-ai-job-run.js.map +1 -0
  196. package/src/lib/components/use-ai-model-choice.d.ts +47 -0
  197. package/src/lib/components/use-ai-model-choice.js +150 -0
  198. package/src/lib/components/use-ai-model-choice.js.map +1 -0
  199. package/src/lib/components/use-ai-products-jobs.d.ts +36 -0
  200. package/src/lib/components/use-ai-products-jobs.js +190 -0
  201. package/src/lib/components/use-ai-products-jobs.js.map +1 -0
  202. package/src/lib/components/use-ai-usage-meter.d.ts +11 -0
  203. package/src/lib/components/use-ai-usage-meter.js +96 -0
  204. package/src/lib/components/use-ai-usage-meter.js.map +1 -0
  205. package/src/lib/components/use-org-ai-usage.d.ts +42 -0
  206. package/src/lib/components/use-org-ai-usage.js +181 -0
  207. package/src/lib/components/use-org-ai-usage.js.map +1 -0
  208. package/src/lib/components/use-staff-orgs-ai-spend.d.ts +18 -0
  209. package/src/lib/components/use-staff-orgs-ai-spend.js +127 -0
  210. package/src/lib/components/use-staff-orgs-ai-spend.js.map +1 -0
  211. package/src/lib/constants.d.ts +24 -0
  212. package/src/lib/constants.js +23 -0
  213. package/src/lib/constants.js.map +1 -0
  214. package/src/lib/declarations.d.ts +48 -0
  215. package/src/lib/declarations.js +129 -0
  216. package/src/lib/declarations.js.map +1 -0
  217. package/src/lib/declarations.server.d.ts +35 -0
  218. package/src/lib/declarations.server.js +138 -0
  219. package/src/lib/declarations.server.js.map +1 -0
  220. package/src/lib/insights/ai-figure-readers.d.ts +90 -0
  221. package/src/lib/insights/ai-figure-readers.js +863 -0
  222. package/src/lib/insights/ai-figure-readers.js.map +1 -0
  223. package/src/lib/insights/ai-insight-digest.d.ts +165 -0
  224. package/src/lib/insights/ai-insight-digest.js +363 -0
  225. package/src/lib/insights/ai-insight-digest.js.map +1 -0
  226. package/src/lib/insights/ai-insight-readers.d.ts +71 -0
  227. package/src/lib/insights/ai-insight-readers.js +141 -0
  228. package/src/lib/insights/ai-insight-readers.js.map +1 -0
  229. package/src/lib/jobs/ai-crm-access.d.ts +61 -0
  230. package/src/lib/jobs/ai-crm-access.js +94 -0
  231. package/src/lib/jobs/ai-crm-access.js.map +1 -0
  232. package/src/lib/jobs/ai-email-bindings.d.ts +97 -0
  233. package/src/lib/jobs/ai-email-bindings.js +147 -0
  234. package/src/lib/jobs/ai-email-bindings.js.map +1 -0
  235. package/src/lib/jobs/ai-job-admission.d.ts +82 -0
  236. package/src/lib/jobs/ai-job-admission.js +45 -0
  237. package/src/lib/jobs/ai-job-admission.js.map +1 -0
  238. package/src/lib/jobs/ai-job-budget.d.ts +167 -0
  239. package/src/lib/jobs/ai-job-budget.js +161 -0
  240. package/src/lib/jobs/ai-job-budget.js.map +1 -0
  241. package/src/lib/jobs/ai-job-campaign-step.d.ts +108 -0
  242. package/src/lib/jobs/ai-job-campaign-step.js +340 -0
  243. package/src/lib/jobs/ai-job-campaign-step.js.map +1 -0
  244. package/src/lib/jobs/ai-job-component-checks.d.ts +74 -0
  245. package/src/lib/jobs/ai-job-component-checks.js +442 -0
  246. package/src/lib/jobs/ai-job-component-checks.js.map +1 -0
  247. package/src/lib/jobs/ai-job-component-step.d.ts +75 -0
  248. package/src/lib/jobs/ai-job-component-step.js +262 -0
  249. package/src/lib/jobs/ai-job-component-step.js.map +1 -0
  250. package/src/lib/jobs/ai-job-crm-step.d.ts +192 -0
  251. package/src/lib/jobs/ai-job-crm-step.js +734 -0
  252. package/src/lib/jobs/ai-job-crm-step.js.map +1 -0
  253. package/src/lib/jobs/ai-job-draft-ids.d.ts +62 -0
  254. package/src/lib/jobs/ai-job-draft-ids.js +132 -0
  255. package/src/lib/jobs/ai-job-draft-ids.js.map +1 -0
  256. package/src/lib/jobs/ai-job-drafts.d.ts +304 -0
  257. package/src/lib/jobs/ai-job-drafts.js +557 -0
  258. package/src/lib/jobs/ai-job-drafts.js.map +1 -0
  259. package/src/lib/jobs/ai-job-email-step.d.ts +195 -0
  260. package/src/lib/jobs/ai-job-email-step.js +547 -0
  261. package/src/lib/jobs/ai-job-email-step.js.map +1 -0
  262. package/src/lib/jobs/ai-job-experiment-step.d.ts +105 -0
  263. package/src/lib/jobs/ai-job-experiment-step.js +445 -0
  264. package/src/lib/jobs/ai-job-experiment-step.js.map +1 -0
  265. package/src/lib/jobs/ai-job-form-step.d.ts +250 -0
  266. package/src/lib/jobs/ai-job-form-step.js +634 -0
  267. package/src/lib/jobs/ai-job-form-step.js.map +1 -0
  268. package/src/lib/jobs/ai-job-generation.d.ts +114 -0
  269. package/src/lib/jobs/ai-job-generation.js +384 -0
  270. package/src/lib/jobs/ai-job-generation.js.map +1 -0
  271. package/src/lib/jobs/ai-job-insight-budget.d.ts +41 -0
  272. package/src/lib/jobs/ai-job-insight-budget.js +46 -0
  273. package/src/lib/jobs/ai-job-insight-budget.js.map +1 -0
  274. package/src/lib/jobs/ai-job-insight-step.d.ts +58 -0
  275. package/src/lib/jobs/ai-job-insight-step.js +350 -0
  276. package/src/lib/jobs/ai-job-insight-step.js.map +1 -0
  277. package/src/lib/jobs/ai-job-layout-step.d.ts +103 -0
  278. package/src/lib/jobs/ai-job-layout-step.js +340 -0
  279. package/src/lib/jobs/ai-job-layout-step.js.map +1 -0
  280. package/src/lib/jobs/ai-job-page-budget.d.ts +57 -0
  281. package/src/lib/jobs/ai-job-page-budget.js +60 -0
  282. package/src/lib/jobs/ai-job-page-budget.js.map +1 -0
  283. package/src/lib/jobs/ai-job-page-sections.d.ts +150 -0
  284. package/src/lib/jobs/ai-job-page-sections.js +450 -0
  285. package/src/lib/jobs/ai-job-page-sections.js.map +1 -0
  286. package/src/lib/jobs/ai-job-page-step.d.ts +198 -0
  287. package/src/lib/jobs/ai-job-page-step.js +667 -0
  288. package/src/lib/jobs/ai-job-page-step.js.map +1 -0
  289. package/src/lib/jobs/ai-job-plan-conformance.d.ts +107 -0
  290. package/src/lib/jobs/ai-job-plan-conformance.js +164 -0
  291. package/src/lib/jobs/ai-job-plan-conformance.js.map +1 -0
  292. package/src/lib/jobs/ai-job-plan-step.d.ts +196 -0
  293. package/src/lib/jobs/ai-job-plan-step.js +458 -0
  294. package/src/lib/jobs/ai-job-plan-step.js.map +1 -0
  295. package/src/lib/jobs/ai-job-plugin-drafts.d.ts +76 -0
  296. package/src/lib/jobs/ai-job-plugin-drafts.js +91 -0
  297. package/src/lib/jobs/ai-job-plugin-drafts.js.map +1 -0
  298. package/src/lib/jobs/ai-job-products-step.d.ts +106 -0
  299. package/src/lib/jobs/ai-job-products-step.js +436 -0
  300. package/src/lib/jobs/ai-job-products-step.js.map +1 -0
  301. package/src/lib/jobs/ai-job-seo-budget.d.ts +52 -0
  302. package/src/lib/jobs/ai-job-seo-budget.js +63 -0
  303. package/src/lib/jobs/ai-job-seo-budget.js.map +1 -0
  304. package/src/lib/jobs/ai-job-seo-step.d.ts +145 -0
  305. package/src/lib/jobs/ai-job-seo-step.js +809 -0
  306. package/src/lib/jobs/ai-job-seo-step.js.map +1 -0
  307. package/src/lib/jobs/ai-job-site-step.d.ts +252 -0
  308. package/src/lib/jobs/ai-job-site-step.js +538 -0
  309. package/src/lib/jobs/ai-job-site-step.js.map +1 -0
  310. package/src/lib/jobs/ai-job-template-step.d.ts +105 -0
  311. package/src/lib/jobs/ai-job-template-step.js +391 -0
  312. package/src/lib/jobs/ai-job-template-step.js.map +1 -0
  313. package/src/lib/jobs/ai-job-text-step.d.ts +125 -0
  314. package/src/lib/jobs/ai-job-text-step.js +128 -0
  315. package/src/lib/jobs/ai-job-text-step.js.map +1 -0
  316. package/src/lib/jobs/ai-job-theme-budget.d.ts +38 -0
  317. package/src/lib/jobs/ai-job-theme-budget.js +43 -0
  318. package/src/lib/jobs/ai-job-theme-budget.js.map +1 -0
  319. package/src/lib/jobs/ai-job-theme-step.d.ts +115 -0
  320. package/src/lib/jobs/ai-job-theme-step.js +337 -0
  321. package/src/lib/jobs/ai-job-theme-step.js.map +1 -0
  322. package/src/lib/jobs/ai-job-workflow-step.d.ts +139 -0
  323. package/src/lib/jobs/ai-job-workflow-step.js +530 -0
  324. package/src/lib/jobs/ai-job-workflow-step.js.map +1 -0
  325. package/src/lib/jobs/ai-jobs-beat.d.ts +78 -0
  326. package/src/lib/jobs/ai-jobs-beat.js +93 -0
  327. package/src/lib/jobs/ai-jobs-beat.js.map +1 -0
  328. package/src/lib/jobs/ai-jobs-pause.d.ts +38 -0
  329. package/src/lib/jobs/ai-jobs-pause.js +45 -0
  330. package/src/lib/jobs/ai-jobs-pause.js.map +1 -0
  331. package/src/lib/jobs/ai-jobs.d.ts +558 -0
  332. package/src/lib/jobs/ai-jobs.js +1410 -0
  333. package/src/lib/jobs/ai-jobs.js.map +1 -0
  334. package/src/lib/jobs/ai-media-asset-server.d.ts +34 -0
  335. package/src/lib/jobs/ai-media-asset-server.js +34 -0
  336. package/src/lib/jobs/ai-media-asset-server.js.map +1 -0
  337. package/src/lib/jobs/ai-media-asset.d.ts +59 -0
  338. package/src/lib/jobs/ai-media-asset.js +86 -0
  339. package/src/lib/jobs/ai-media-asset.js.map +1 -0
  340. package/src/lib/jobs/ai-product-image.d.ts +78 -0
  341. package/src/lib/jobs/ai-product-image.js +113 -0
  342. package/src/lib/jobs/ai-product-image.js.map +1 -0
  343. package/src/lib/jobs/ai-theme-brand-inputs.d.ts +125 -0
  344. package/src/lib/jobs/ai-theme-brand-inputs.js +378 -0
  345. package/src/lib/jobs/ai-theme-brand-inputs.js.map +1 -0
  346. package/src/lib/jobs/ai-theme-brand-server.d.ts +33 -0
  347. package/src/lib/jobs/ai-theme-brand-server.js +33 -0
  348. package/src/lib/jobs/ai-theme-brand-server.js.map +1 -0
  349. package/src/lib/jobs/ai-workflow-records.d.ts +84 -0
  350. package/src/lib/jobs/ai-workflow-records.js +158 -0
  351. package/src/lib/jobs/ai-workflow-records.js.map +1 -0
  352. package/src/lib/jobs/fixtures/ai-free-page-built-recording.d.ts +31 -0
  353. package/src/lib/jobs/fixtures/ai-free-page-built-recording.js +367 -0
  354. package/src/lib/jobs/fixtures/ai-free-page-built-recording.js.map +1 -0
  355. package/src/lib/jobs/fixtures/ai-free-page-recording.d.ts +69 -0
  356. package/src/lib/jobs/fixtures/ai-free-page-recording.js +442 -0
  357. package/src/lib/jobs/fixtures/ai-free-page-recording.js.map +1 -0
  358. package/src/lib/jobs/fixtures/ai-page-briefs.d.ts +146 -0
  359. package/src/lib/jobs/fixtures/ai-page-briefs.js +1850 -0
  360. package/src/lib/jobs/fixtures/ai-page-briefs.js.map +1 -0
  361. package/src/lib/model/ai-allotments.d.ts +208 -0
  362. package/src/lib/model/ai-allotments.js +269 -0
  363. package/src/lib/model/ai-allotments.js.map +1 -0
  364. package/src/lib/model/ai-automation-draft.d.ts +74 -0
  365. package/src/lib/model/ai-automation-draft.js +310 -0
  366. package/src/lib/model/ai-automation-draft.js.map +1 -0
  367. package/src/lib/model/ai-automation-outline.d.ts +50 -0
  368. package/src/lib/model/ai-automation-outline.js +262 -0
  369. package/src/lib/model/ai-automation-outline.js.map +1 -0
  370. package/src/lib/model/ai-build-plan.d.ts +197 -0
  371. package/src/lib/model/ai-build-plan.js +438 -0
  372. package/src/lib/model/ai-build-plan.js.map +1 -0
  373. package/src/lib/model/ai-crm.d.ts +237 -0
  374. package/src/lib/model/ai-crm.js +225 -0
  375. package/src/lib/model/ai-crm.js.map +1 -0
  376. package/src/lib/model/ai-experiment-proposal.d.ts +68 -0
  377. package/src/lib/model/ai-experiment-proposal.js +146 -0
  378. package/src/lib/model/ai-experiment-proposal.js.map +1 -0
  379. package/src/lib/model/ai-experiment.d.ts +309 -0
  380. package/src/lib/model/ai-experiment.js +395 -0
  381. package/src/lib/model/ai-experiment.js.map +1 -0
  382. package/src/lib/model/ai-insight.d.ts +178 -0
  383. package/src/lib/model/ai-insight.js +201 -0
  384. package/src/lib/model/ai-insight.js.map +1 -0
  385. package/src/lib/model/ai-jobs.types.d.ts +412 -0
  386. package/src/lib/model/ai-jobs.types.js +42 -0
  387. package/src/lib/model/ai-jobs.types.js.map +1 -0
  388. package/src/lib/model/ai-page-job.d.ts +92 -0
  389. package/src/lib/model/ai-page-job.js +159 -0
  390. package/src/lib/model/ai-page-job.js.map +1 -0
  391. package/src/lib/model/ai-permissions.d.ts +49 -0
  392. package/src/lib/model/ai-permissions.js +97 -0
  393. package/src/lib/model/ai-permissions.js.map +1 -0
  394. package/src/lib/model/ai-plan-capabilities.d.ts +139 -0
  395. package/src/lib/model/ai-plan-capabilities.js +149 -0
  396. package/src/lib/model/ai-plan-capabilities.js.map +1 -0
  397. package/src/lib/model/ai-products.d.ts +251 -0
  398. package/src/lib/model/ai-products.js +253 -0
  399. package/src/lib/model/ai-products.js.map +1 -0
  400. package/src/lib/model/ai-seo.d.ts +208 -0
  401. package/src/lib/model/ai-seo.js +150 -0
  402. package/src/lib/model/ai-seo.js.map +1 -0
  403. package/src/lib/model/ai-site-inventory.d.ts +164 -0
  404. package/src/lib/model/ai-site-inventory.js +145 -0
  405. package/src/lib/model/ai-site-inventory.js.map +1 -0
  406. package/src/lib/model/ai-site-job.d.ts +247 -0
  407. package/src/lib/model/ai-site-job.js +314 -0
  408. package/src/lib/model/ai-site-job.js.map +1 -0
  409. package/src/lib/model/ai-site-start-seo.d.ts +103 -0
  410. package/src/lib/model/ai-site-start-seo.js +154 -0
  411. package/src/lib/model/ai-site-start-seo.js.map +1 -0
  412. package/src/lib/model/ai-site-start.d.ts +122 -0
  413. package/src/lib/model/ai-site-start.js +159 -0
  414. package/src/lib/model/ai-site-start.js.map +1 -0
  415. package/src/lib/model/ai-site-switch.d.ts +56 -0
  416. package/src/lib/model/ai-site-switch.js +73 -0
  417. package/src/lib/model/ai-site-switch.js.map +1 -0
  418. package/src/lib/model/ai-storefront-claims.d.ts +70 -0
  419. package/src/lib/model/ai-storefront-claims.js +130 -0
  420. package/src/lib/model/ai-storefront-claims.js.map +1 -0
  421. package/src/lib/model/ai-template-subjects.d.ts +82 -0
  422. package/src/lib/model/ai-template-subjects.js +136 -0
  423. package/src/lib/model/ai-template-subjects.js.map +1 -0
  424. package/src/lib/model/ai-theme-proposal.d.ts +210 -0
  425. package/src/lib/model/ai-theme-proposal.js +506 -0
  426. package/src/lib/model/ai-theme-proposal.js.map +1 -0
  427. package/src/lib/model/ai-tokens.d.ts +96 -0
  428. package/src/lib/model/ai-tokens.js +117 -0
  429. package/src/lib/model/ai-tokens.js.map +1 -0
  430. package/src/lib/model/ai-usage-by-user.d.ts +120 -0
  431. package/src/lib/model/ai-usage-by-user.js +139 -0
  432. package/src/lib/model/ai-usage-by-user.js.map +1 -0
  433. package/src/lib/model/ai-workflow-job.d.ts +111 -0
  434. package/src/lib/model/ai-workflow-job.js +183 -0
  435. package/src/lib/model/ai-workflow-job.js.map +1 -0
  436. package/src/lib/model/assist-edit.d.ts +261 -0
  437. package/src/lib/model/assist-edit.js +175 -0
  438. package/src/lib/model/assist-edit.js.map +1 -0
  439. package/src/lib/plugin-config.d.ts +33 -0
  440. package/src/lib/plugin-config.js +118 -0
  441. package/src/lib/plugin-config.js.map +1 -0
  442. package/src/lib/plugin.d.ts +30 -0
  443. package/src/lib/plugin.js +525 -0
  444. package/src/lib/plugin.js.map +1 -0
  445. package/src/lib/providers/anthropic.d.ts +84 -0
  446. package/src/lib/providers/anthropic.js +432 -0
  447. package/src/lib/providers/anthropic.js.map +1 -0
  448. package/src/lib/providers/catalog.d.ts +197 -0
  449. package/src/lib/providers/catalog.js +312 -0
  450. package/src/lib/providers/catalog.js.map +1 -0
  451. package/src/lib/providers/contract.d.ts +464 -0
  452. package/src/lib/providers/contract.js +274 -0
  453. package/src/lib/providers/contract.js.map +1 -0
  454. package/src/lib/providers/model-choice.d.ts +119 -0
  455. package/src/lib/providers/model-choice.js +416 -0
  456. package/src/lib/providers/model-choice.js.map +1 -0
  457. package/src/lib/providers/openai-compatible.d.ts +58 -0
  458. package/src/lib/providers/openai-compatible.js +361 -0
  459. package/src/lib/providers/openai-compatible.js.map +1 -0
  460. package/src/lib/providers/registry.d.ts +49 -0
  461. package/src/lib/providers/registry.js +71 -0
  462. package/src/lib/providers/registry.js.map +1 -0
  463. package/src/lib/providers/routing.d.ts +98 -0
  464. package/src/lib/providers/routing.js +450 -0
  465. package/src/lib/providers/routing.js.map +1 -0
  466. package/src/lib/runtime/ai-abuse-guards.d.ts +113 -0
  467. package/src/lib/runtime/ai-abuse-guards.js +148 -0
  468. package/src/lib/runtime/ai-abuse-guards.js.map +1 -0
  469. package/src/lib/runtime/ai-component-bindings.d.ts +67 -0
  470. package/src/lib/runtime/ai-component-bindings.js +106 -0
  471. package/src/lib/runtime/ai-component-bindings.js.map +1 -0
  472. package/src/lib/runtime/ai-device-audit.d.ts +109 -0
  473. package/src/lib/runtime/ai-device-audit.js +97 -0
  474. package/src/lib/runtime/ai-device-audit.js.map +1 -0
  475. package/src/lib/runtime/ai-doctrine-validators.d.ts +720 -0
  476. package/src/lib/runtime/ai-doctrine-validators.js +3133 -0
  477. package/src/lib/runtime/ai-doctrine-validators.js.map +1 -0
  478. package/src/lib/runtime/ai-doctrine.d.ts +372 -0
  479. package/src/lib/runtime/ai-doctrine.js +944 -0
  480. package/src/lib/runtime/ai-doctrine.js.map +1 -0
  481. package/src/lib/runtime/ai-eval-live.d.ts +321 -0
  482. package/src/lib/runtime/ai-eval-live.js +1257 -0
  483. package/src/lib/runtime/ai-eval-live.js.map +1 -0
  484. package/src/lib/runtime/ai-eval-memory-firestore.d.ts +51 -0
  485. package/src/lib/runtime/ai-eval-memory-firestore.js +183 -0
  486. package/src/lib/runtime/ai-eval-memory-firestore.js.map +1 -0
  487. package/src/lib/runtime/ai-eval.d.ts +441 -0
  488. package/src/lib/runtime/ai-eval.js +1151 -0
  489. package/src/lib/runtime/ai-eval.js.map +1 -0
  490. package/src/lib/runtime/ai-gate.d.ts +130 -0
  491. package/src/lib/runtime/ai-gate.js +272 -0
  492. package/src/lib/runtime/ai-gate.js.map +1 -0
  493. package/src/lib/runtime/ai-generation-bounds.d.ts +24 -0
  494. package/src/lib/runtime/ai-generation-bounds.js +23 -0
  495. package/src/lib/runtime/ai-generation-bounds.js.map +1 -0
  496. package/src/lib/runtime/ai-insight-check.d.ts +76 -0
  497. package/src/lib/runtime/ai-insight-check.js +281 -0
  498. package/src/lib/runtime/ai-insight-check.js.map +1 -0
  499. package/src/lib/runtime/ai-node-tree.d.ts +181 -0
  500. package/src/lib/runtime/ai-node-tree.js +931 -0
  501. package/src/lib/runtime/ai-node-tree.js.map +1 -0
  502. package/src/lib/runtime/ai-page-links.d.ts +79 -0
  503. package/src/lib/runtime/ai-page-links.js +135 -0
  504. package/src/lib/runtime/ai-page-links.js.map +1 -0
  505. package/src/lib/runtime/ai-palette.d.ts +252 -0
  506. package/src/lib/runtime/ai-palette.generated.d.ts +34 -0
  507. package/src/lib/runtime/ai-palette.generated.js +5263 -0
  508. package/src/lib/runtime/ai-palette.generated.js.map +1 -0
  509. package/src/lib/runtime/ai-palette.js +187 -0
  510. package/src/lib/runtime/ai-palette.js.map +1 -0
  511. package/src/lib/runtime/ai-products-generation.d.ts +107 -0
  512. package/src/lib/runtime/ai-products-generation.js +250 -0
  513. package/src/lib/runtime/ai-products-generation.js.map +1 -0
  514. package/src/lib/runtime/ai-repeated-items.d.ts +95 -0
  515. package/src/lib/runtime/ai-repeated-items.js +397 -0
  516. package/src/lib/runtime/ai-repeated-items.js.map +1 -0
  517. package/src/lib/runtime/ai-runtime.d.ts +148 -0
  518. package/src/lib/runtime/ai-runtime.js +237 -0
  519. package/src/lib/runtime/ai-runtime.js.map +1 -0
  520. package/src/lib/runtime/ai-template-examples.d.ts +71 -0
  521. package/src/lib/runtime/ai-template-examples.js +135 -0
  522. package/src/lib/runtime/ai-template-examples.js.map +1 -0
  523. package/src/lib/runtime/assist-answer-cache.d.ts +80 -0
  524. package/src/lib/runtime/assist-answer-cache.js +184 -0
  525. package/src/lib/runtime/assist-answer-cache.js.map +1 -0
  526. package/src/lib/runtime/seo-audit.d.ts +93 -0
  527. package/src/lib/runtime/seo-audit.js +260 -0
  528. package/src/lib/runtime/seo-audit.js.map +1 -0
  529. package/src/lib/runtime/seo-content-fixes.d.ts +41 -0
  530. package/src/lib/runtime/seo-content-fixes.js +168 -0
  531. package/src/lib/runtime/seo-content-fixes.js.map +1 -0
  532. package/src/lib/runtime/seo-fields.d.ts +152 -0
  533. package/src/lib/runtime/seo-fields.js +215 -0
  534. package/src/lib/runtime/seo-fields.js.map +1 -0
  535. package/src/lib/runtime/seo-page-facts.d.ts +61 -0
  536. package/src/lib/runtime/seo-page-facts.js +150 -0
  537. package/src/lib/runtime/seo-page-facts.js.map +1 -0
  538. package/src/lib/runtime/site-inventory.d.ts +63 -0
  539. package/src/lib/runtime/site-inventory.js +230 -0
  540. package/src/lib/runtime/site-inventory.js.map +1 -0
  541. package/src/lib/server/ai-admin-org.d.ts +33 -0
  542. package/src/lib/server/ai-admin-org.js +381 -0
  543. package/src/lib/server/ai-admin-org.js.map +1 -0
  544. package/src/lib/server/ai-admin-orgs-spend.d.ts +40 -0
  545. package/src/lib/server/ai-admin-orgs-spend.js +129 -0
  546. package/src/lib/server/ai-admin-orgs-spend.js.map +1 -0
  547. package/src/lib/server/ai-admin-overage.d.ts +19 -0
  548. package/src/lib/server/ai-admin-overage.js +246 -0
  549. package/src/lib/server/ai-admin-overage.js.map +1 -0
  550. package/src/lib/server/ai-admin-signals.d.ts +34 -0
  551. package/src/lib/server/ai-admin-signals.js +330 -0
  552. package/src/lib/server/ai-admin-signals.js.map +1 -0
  553. package/src/lib/server/ai-admin-user.d.ts +27 -0
  554. package/src/lib/server/ai-admin-user.js +128 -0
  555. package/src/lib/server/ai-admin-user.js.map +1 -0
  556. package/src/lib/server/ai-allotments.d.ts +27 -0
  557. package/src/lib/server/ai-allotments.js +544 -0
  558. package/src/lib/server/ai-allotments.js.map +1 -0
  559. package/src/lib/server/ai-assist-prompts.d.ts +102 -0
  560. package/src/lib/server/ai-assist-prompts.js +207 -0
  561. package/src/lib/server/ai-assist-prompts.js.map +1 -0
  562. package/src/lib/server/ai-assist.d.ts +119 -0
  563. package/src/lib/server/ai-assist.js +517 -0
  564. package/src/lib/server/ai-assist.js.map +1 -0
  565. package/src/lib/server/ai-crm-answer.d.ts +30 -0
  566. package/src/lib/server/ai-crm-answer.js +98 -0
  567. package/src/lib/server/ai-crm-answer.js.map +1 -0
  568. package/src/lib/server/ai-generate-component.d.ts +111 -0
  569. package/src/lib/server/ai-generate-component.js +643 -0
  570. package/src/lib/server/ai-generate-component.js.map +1 -0
  571. package/src/lib/server/ai-host-permissions.d.ts +46 -0
  572. package/src/lib/server/ai-host-permissions.js +204 -0
  573. package/src/lib/server/ai-host-permissions.js.map +1 -0
  574. package/src/lib/server/ai-insight-answer.d.ts +30 -0
  575. package/src/lib/server/ai-insight-answer.js +83 -0
  576. package/src/lib/server/ai-insight-answer.js.map +1 -0
  577. package/src/lib/server/ai-insight-digest-route.d.ts +30 -0
  578. package/src/lib/server/ai-insight-digest-route.js +156 -0
  579. package/src/lib/server/ai-insight-digest-route.js.map +1 -0
  580. package/src/lib/server/ai-jobs-batch.d.ts +48 -0
  581. package/src/lib/server/ai-jobs-batch.js +306 -0
  582. package/src/lib/server/ai-jobs-batch.js.map +1 -0
  583. package/src/lib/server/ai-jobs-beat-route.d.ts +36 -0
  584. package/src/lib/server/ai-jobs-beat-route.js +86 -0
  585. package/src/lib/server/ai-jobs-beat-route.js.map +1 -0
  586. package/src/lib/server/ai-jobs-cancel.d.ts +30 -0
  587. package/src/lib/server/ai-jobs-cancel.js +74 -0
  588. package/src/lib/server/ai-jobs-cancel.js.map +1 -0
  589. package/src/lib/server/ai-jobs-events-route.d.ts +31 -0
  590. package/src/lib/server/ai-jobs-events-route.js +51 -0
  591. package/src/lib/server/ai-jobs-events-route.js.map +1 -0
  592. package/src/lib/server/ai-jobs-events.d.ts +55 -0
  593. package/src/lib/server/ai-jobs-events.js +144 -0
  594. package/src/lib/server/ai-jobs-events.js.map +1 -0
  595. package/src/lib/server/ai-jobs-gate.d.ts +47 -0
  596. package/src/lib/server/ai-jobs-gate.js +106 -0
  597. package/src/lib/server/ai-jobs-gate.js.map +1 -0
  598. package/src/lib/server/ai-jobs-resume.d.ts +23 -0
  599. package/src/lib/server/ai-jobs-resume.js +209 -0
  600. package/src/lib/server/ai-jobs-resume.js.map +1 -0
  601. package/src/lib/server/ai-jobs-route.d.ts +32 -0
  602. package/src/lib/server/ai-jobs-route.js +307 -0
  603. package/src/lib/server/ai-jobs-route.js.map +1 -0
  604. package/src/lib/server/ai-models.d.ts +18 -0
  605. package/src/lib/server/ai-models.js +134 -0
  606. package/src/lib/server/ai-models.js.map +1 -0
  607. package/src/lib/server/ai-seo-apply.d.ts +53 -0
  608. package/src/lib/server/ai-seo-apply.js +294 -0
  609. package/src/lib/server/ai-seo-apply.js.map +1 -0
  610. package/src/lib/server/ai-usage.d.ts +18 -0
  611. package/src/lib/server/ai-usage.js +220 -0
  612. package/src/lib/server/ai-usage.js.map +1 -0
  613. package/src/lib/server/assist-chat.d.ts +234 -0
  614. package/src/lib/server/assist-chat.js +1446 -0
  615. package/src/lib/server/assist-chat.js.map +1 -0
  616. package/src/lib/server/assist-edit-applied.d.ts +22 -0
  617. package/src/lib/server/assist-edit-applied.js +239 -0
  618. package/src/lib/server/assist-edit-applied.js.map +1 -0
  619. package/src/lib/server/assist-edit.d.ts +124 -0
  620. package/src/lib/server/assist-edit.js +1000 -0
  621. package/src/lib/server/assist-edit.js.map +1 -0
  622. package/src/lib/server/assist-feedback.d.ts +31 -0
  623. package/src/lib/server/assist-feedback.js +115 -0
  624. package/src/lib/server/assist-feedback.js.map +1 -0
  625. package/src/lib/server/assist-view-context.d.ts +343 -0
  626. package/src/lib/server/assist-view-context.js +690 -0
  627. package/src/lib/server/assist-view-context.js.map +1 -0
  628. package/src/lib/server/billing-credits.d.ts +59 -0
  629. package/src/lib/server/billing-credits.js +146 -0
  630. package/src/lib/server/billing-credits.js.map +1 -0
  631. package/src/lib/server/billing-overage.d.ts +19 -0
  632. package/src/lib/server/billing-overage.js +337 -0
  633. package/src/lib/server/billing-overage.js.map +1 -0
  634. package/src/lib/server.d.ts +32 -0
  635. package/src/lib/server.js +265 -0
  636. package/src/lib/server.js.map +1 -0
  637. package/src/lib/subprocessors.d.ts +18 -0
  638. package/src/lib/subprocessors.js +52 -0
  639. package/src/lib/subprocessors.js.map +1 -0
  640. package/src/lib/tools/ai-component-tool.d.ts +99 -0
  641. package/src/lib/tools/ai-component-tool.js +369 -0
  642. package/src/lib/tools/ai-component-tool.js.map +1 -0
  643. package/src/lib/tools/ai-crm-tool.d.ts +106 -0
  644. package/src/lib/tools/ai-crm-tool.js +488 -0
  645. package/src/lib/tools/ai-crm-tool.js.map +1 -0
  646. package/src/lib/tools/ai-duplicate-resource-tool.d.ts +71 -0
  647. package/src/lib/tools/ai-duplicate-resource-tool.js +164 -0
  648. package/src/lib/tools/ai-duplicate-resource-tool.js.map +1 -0
  649. package/src/lib/tools/ai-experiment-tool.d.ts +40 -0
  650. package/src/lib/tools/ai-experiment-tool.js +155 -0
  651. package/src/lib/tools/ai-experiment-tool.js.map +1 -0
  652. package/src/lib/tools/ai-insight-tool.d.ts +46 -0
  653. package/src/lib/tools/ai-insight-tool.js +200 -0
  654. package/src/lib/tools/ai-insight-tool.js.map +1 -0
  655. package/src/lib/tools/ai-inventory-lookup-tool.d.ts +86 -0
  656. package/src/lib/tools/ai-inventory-lookup-tool.js +164 -0
  657. package/src/lib/tools/ai-inventory-lookup-tool.js.map +1 -0
  658. package/src/lib/tools/ai-products-tool.d.ts +65 -0
  659. package/src/lib/tools/ai-products-tool.js +644 -0
  660. package/src/lib/tools/ai-products-tool.js.map +1 -0
  661. package/src/lib/tools/ai-seo-tool.d.ts +162 -0
  662. package/src/lib/tools/ai-seo-tool.js +546 -0
  663. package/src/lib/tools/ai-seo-tool.js.map +1 -0
  664. package/src/lib/tools/ai-theme-tool.d.ts +101 -0
  665. package/src/lib/tools/ai-theme-tool.js +562 -0
  666. package/src/lib/tools/ai-theme-tool.js.map +1 -0
  667. package/src/lib/tools/ai-workflow-tool.d.ts +166 -0
  668. package/src/lib/tools/ai-workflow-tool.js +860 -0
  669. package/src/lib/tools/ai-workflow-tool.js.map +1 -0
  670. package/src/lib/usage/ai-allotment-alerts.d.ts +72 -0
  671. package/src/lib/usage/ai-allotment-alerts.js +157 -0
  672. package/src/lib/usage/ai-allotment-alerts.js.map +1 -0
  673. package/src/lib/usage/ai-allotments.d.ts +125 -0
  674. package/src/lib/usage/ai-allotments.js +239 -0
  675. package/src/lib/usage/ai-allotments.js.map +1 -0
  676. package/src/lib/usage/ai-model-sample.d.ts +36 -0
  677. package/src/lib/usage/ai-model-sample.js +68 -0
  678. package/src/lib/usage/ai-model-sample.js.map +1 -0
  679. package/src/lib/usage/ai-usage-alerts.d.ts +55 -0
  680. package/src/lib/usage/ai-usage-alerts.js +114 -0
  681. package/src/lib/usage/ai-usage-alerts.js.map +1 -0
  682. package/src/lib/usage/ai-usage-by-user.d.ts +161 -0
  683. package/src/lib/usage/ai-usage-by-user.js +211 -0
  684. package/src/lib/usage/ai-usage-by-user.js.map +1 -0
  685. package/src/lib/usage/ai-usage-eraser.d.ts +29 -0
  686. package/src/lib/usage/ai-usage-eraser.js +40 -0
  687. package/src/lib/usage/ai-usage-eraser.js.map +1 -0
  688. package/src/lib/usage/ai-usage-meter.d.ts +39 -0
  689. package/src/lib/usage/ai-usage-meter.js +85 -0
  690. package/src/lib/usage/ai-usage-meter.js.map +1 -0
  691. package/src/lib/usage/ai-usage-wire.d.ts +184 -0
  692. package/src/lib/usage/ai-usage-wire.js +98 -0
  693. package/src/lib/usage/ai-usage-wire.js.map +1 -0
  694. package/src/lib/usage/assist-ceiling.d.ts +87 -0
  695. package/src/lib/usage/assist-ceiling.js +110 -0
  696. package/src/lib/usage/assist-ceiling.js.map +1 -0
  697. package/src/lib/usage/assist-free-taste.d.ts +225 -0
  698. package/src/lib/usage/assist-free-taste.js +308 -0
  699. package/src/lib/usage/assist-free-taste.js.map +1 -0
  700. package/src/lib/usage/assist-refusals.d.ts +69 -0
  701. package/src/lib/usage/assist-refusals.js +79 -0
  702. package/src/lib/usage/assist-refusals.js.map +1 -0
  703. package/src/lib/usage/assist-signal-mining.d.ts +375 -0
  704. package/src/lib/usage/assist-signal-mining.js +344 -0
  705. package/src/lib/usage/assist-signal-mining.js.map +1 -0
  706. package/src/lib/usage/assist-usage.d.ts +571 -0
  707. package/src/lib/usage/assist-usage.js +978 -0
  708. package/src/lib/usage/assist-usage.js.map +1 -0
  709. package/src/lib/usage/staff-org-ai.d.ts +242 -0
  710. package/src/lib/usage/staff-org-ai.js +173 -0
  711. package/src/lib/usage/staff-org-ai.js.map +1 -0
  712. package/src/lib/usage/staff-org-usage-ai.d.ts +83 -0
  713. package/src/lib/usage/staff-org-usage-ai.js +59 -0
  714. package/src/lib/usage/staff-org-usage-ai.js.map +1 -0
  715. package/src/lib/usage/staff-orgs-ai-spend.d.ts +83 -0
  716. package/src/lib/usage/staff-orgs-ai-spend.js +114 -0
  717. package/src/lib/usage/staff-orgs-ai-spend.js.map +1 -0
@@ -0,0 +1,96 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import type { AiUsage } from '../providers/contract';
18
+ /**
19
+ * TOKENS AS THE ROLLUPS KEEP THEM (AGL-2937): the pure half.
20
+ *
21
+ * A provider reports four counts per request, and each is priced at its own
22
+ * rate: prompt tokens sent uncached, prompt tokens read from the prompt
23
+ * cache, prompt tokens written to it, and tokens generated. The org month
24
+ * (per kind), the person's month and the job step keep the same four, so a
25
+ * figure read off one means what it means on the others, and the cache hit
26
+ * rate is the same division everywhere it is shown.
27
+ *
28
+ * Stored shapes:
29
+ *
30
+ * orgs/{orgId}/assistUsage/{YYYY-MM}
31
+ * kinds: { [kind]: { requests, estCostUsd, providerCostUsd,
32
+ * tokens: { input, cached, cacheWrite, output } } }
33
+ * orgs/{orgId}/aiUsageByUser/{uid}/months/{YYYY-MM}
34
+ * tokens: { input, cached, cacheWrite, output }
35
+ *
36
+ * The month document's own top-level `inputTokens`, `outputTokens`,
37
+ * `cacheReadTokens` and `cacheWriteTokens` stay its totals; `kinds` splits
38
+ * them by what the request was for.
39
+ */
40
+ /** The month document's per-kind map. */
41
+ export declare const AI_USAGE_MONTH_KINDS_FIELD = "kinds";
42
+ /** The token map, on a person's month and on each kind of the org's. */
43
+ export declare const AI_USAGE_TOKENS_FIELD = "tokens";
44
+ export interface AiTokenTotals {
45
+ /** Prompt tokens sent uncached, at the model's input rate. */
46
+ input: number;
47
+ /** Prompt tokens read from the prompt cache, at its read rate. */
48
+ cached: number;
49
+ /** Prompt tokens written to the prompt cache, at its write rate. */
50
+ cacheWrite: number;
51
+ /** Tokens the model generated, thinking included. */
52
+ output: number;
53
+ }
54
+ export declare function emptyAiTokenTotals(): AiTokenTotals;
55
+ /** A request's usage, in the rollups' names. */
56
+ export declare function aiTokenTotalsFrom(usage: AiUsage): AiTokenTotals;
57
+ export declare function addAiTokenTotals(a: AiTokenTotals, b: AiTokenTotals): AiTokenTotals;
58
+ /** A stored token map read back, every absent or malformed count as zero. */
59
+ export declare function readAiTokenTotals(raw: unknown): AiTokenTotals;
60
+ /**
61
+ * The share of prompt tokens served from the cache: reads over everything the
62
+ * prompt was billed as — sent, read and written.
63
+ *
64
+ * Writes sit in the denominator on purpose. A prefix that expires and is
65
+ * rewritten every other request is the expensive failure, since a write costs
66
+ * more than a fresh input token; a rate over reads and fresh input alone
67
+ * reads that month as healthy. `null` when there are no prompt tokens at all,
68
+ * which is nothing to divide rather than a 0% hit rate.
69
+ */
70
+ export declare function aiCacheHitRate(tokens: Pick<AiTokenTotals, 'input' | 'cached' | 'cacheWrite'>): number | null;
71
+ /** One kind of request in an org's month. */
72
+ export interface AiKindMonth {
73
+ /** An `AiUsageKind`: `assist`, a besigner mode, or a job kind. */
74
+ kind: string;
75
+ /** Metered model requests; a docs answer or a cache hit is not one. */
76
+ requests: number;
77
+ /** What the kind DREW, at billed rates — the credits behind it. */
78
+ estCostUsd: number;
79
+ /**
80
+ * What the kind COST US (AGL-3015). Equal to `estCostUsd` on a kind served
81
+ * only by models billed at their provider's list, and below it wherever a
82
+ * marked-up model served. A month written before the split answers the
83
+ * billed figure here, which over-reads our bill rather than under-reads it.
84
+ */
85
+ providerCostUsd: number;
86
+ tokens: AiTokenTotals;
87
+ }
88
+ /**
89
+ * The month document's `kinds` map as rows, dearest first.
90
+ *
91
+ * Ordered on what each kind DREW, not on what it cost us: the reader asking
92
+ * "which kind is expensive" is asking about the meter every other figure on
93
+ * the card is denominated in, and the two orders differ only where a kind's
94
+ * model mix differs from its neighbour's.
95
+ */
96
+ export declare function readAiKindMonths(raw: unknown): AiKindMonth[];
@@ -0,0 +1,117 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ import { assistProviderCostUsd, ASSIST_PROVIDER_COST_FIELD } from "@aglyn/aglyn/app-utils/assist-credits";
17
+ /**
18
+ * TOKENS AS THE ROLLUPS KEEP THEM (AGL-2937): the pure half.
19
+ *
20
+ * A provider reports four counts per request, and each is priced at its own
21
+ * rate: prompt tokens sent uncached, prompt tokens read from the prompt
22
+ * cache, prompt tokens written to it, and tokens generated. The org month
23
+ * (per kind), the person's month and the job step keep the same four, so a
24
+ * figure read off one means what it means on the others, and the cache hit
25
+ * rate is the same division everywhere it is shown.
26
+ *
27
+ * Stored shapes:
28
+ *
29
+ * orgs/{orgId}/assistUsage/{YYYY-MM}
30
+ * kinds: { [kind]: { requests, estCostUsd, providerCostUsd,
31
+ * tokens: { input, cached, cacheWrite, output } } }
32
+ * orgs/{orgId}/aiUsageByUser/{uid}/months/{YYYY-MM}
33
+ * tokens: { input, cached, cacheWrite, output }
34
+ *
35
+ * The month document's own top-level `inputTokens`, `outputTokens`,
36
+ * `cacheReadTokens` and `cacheWriteTokens` stay its totals; `kinds` splits
37
+ * them by what the request was for.
38
+ */ /** The month document's per-kind map. */ export const AI_USAGE_MONTH_KINDS_FIELD = 'kinds';
39
+ /** The token map, on a person's month and on each kind of the org's. */ export const AI_USAGE_TOKENS_FIELD = 'tokens';
40
+ const count = (value)=>{
41
+ const parsed = Number(value != null ? value : 0);
42
+ return Number.isFinite(parsed) && parsed > 0 ? Math.floor(parsed) : 0;
43
+ };
44
+ const isRecord = (value)=>typeof value === 'object' && value !== null && !Array.isArray(value);
45
+ export function emptyAiTokenTotals() {
46
+ return {
47
+ input: 0,
48
+ cached: 0,
49
+ cacheWrite: 0,
50
+ output: 0
51
+ };
52
+ }
53
+ /** A request's usage, in the rollups' names. */ export function aiTokenTotalsFrom(usage) {
54
+ return {
55
+ input: count(usage.inputTokens),
56
+ cached: count(usage.cacheReadTokens),
57
+ cacheWrite: count(usage.cacheWriteTokens),
58
+ output: count(usage.outputTokens)
59
+ };
60
+ }
61
+ export function addAiTokenTotals(a, b) {
62
+ return {
63
+ input: a.input + b.input,
64
+ cached: a.cached + b.cached,
65
+ cacheWrite: a.cacheWrite + b.cacheWrite,
66
+ output: a.output + b.output
67
+ };
68
+ }
69
+ /** A stored token map read back, every absent or malformed count as zero. */ export function readAiTokenTotals(raw) {
70
+ const record = isRecord(raw) ? raw : {};
71
+ return {
72
+ input: count(record['input']),
73
+ cached: count(record['cached']),
74
+ cacheWrite: count(record['cacheWrite']),
75
+ output: count(record['output'])
76
+ };
77
+ }
78
+ /**
79
+ * The share of prompt tokens served from the cache: reads over everything the
80
+ * prompt was billed as — sent, read and written.
81
+ *
82
+ * Writes sit in the denominator on purpose. A prefix that expires and is
83
+ * rewritten every other request is the expensive failure, since a write costs
84
+ * more than a fresh input token; a rate over reads and fresh input alone
85
+ * reads that month as healthy. `null` when there are no prompt tokens at all,
86
+ * which is nothing to divide rather than a 0% hit rate.
87
+ */ export function aiCacheHitRate(tokens) {
88
+ const prompt = tokens.input + tokens.cached + tokens.cacheWrite;
89
+ return prompt > 0 ? tokens.cached / prompt : null;
90
+ }
91
+ /**
92
+ * The month document's `kinds` map as rows, dearest first.
93
+ *
94
+ * Ordered on what each kind DREW, not on what it cost us: the reader asking
95
+ * "which kind is expensive" is asking about the meter every other figure on
96
+ * the card is denominated in, and the two orders differ only where a kind's
97
+ * model mix differs from its neighbour's.
98
+ */ export function readAiKindMonths(raw) {
99
+ if (!isRecord(raw)) return [];
100
+ const rows = [];
101
+ for (const [kind, value] of Object.entries(raw)){
102
+ var _value_estCostUsd;
103
+ if (!isRecord(value)) continue;
104
+ const cost = Number((_value_estCostUsd = value['estCostUsd']) != null ? _value_estCostUsd : 0);
105
+ const billed = Number.isFinite(cost) && cost > 0 ? cost : 0;
106
+ rows.push({
107
+ kind,
108
+ requests: count(value['requests']),
109
+ estCostUsd: billed,
110
+ providerCostUsd: assistProviderCostUsd(billed, value[ASSIST_PROVIDER_COST_FIELD]),
111
+ tokens: readAiTokenTotals(value[AI_USAGE_TOKENS_FIELD])
112
+ });
113
+ }
114
+ return rows.sort((a, b)=>b.estCostUsd - a.estCostUsd || b.requests - a.requests || a.kind.localeCompare(b.kind));
115
+ }
116
+
117
+ //# sourceMappingURL=ai-tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-tokens.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 {\n assistProviderCostUsd,\n ASSIST_PROVIDER_COST_FIELD,\n} from '@aglyn/aglyn/app-utils/assist-credits'\nimport type { AiUsage } from '../providers/contract'\n\n/**\n * TOKENS AS THE ROLLUPS KEEP THEM (AGL-2937): the pure half.\n *\n * A provider reports four counts per request, and each is priced at its own\n * rate: prompt tokens sent uncached, prompt tokens read from the prompt\n * cache, prompt tokens written to it, and tokens generated. The org month\n * (per kind), the person's month and the job step keep the same four, so a\n * figure read off one means what it means on the others, and the cache hit\n * rate is the same division everywhere it is shown.\n *\n * Stored shapes:\n *\n * orgs/{orgId}/assistUsage/{YYYY-MM}\n * kinds: { [kind]: { requests, estCostUsd, providerCostUsd,\n * tokens: { input, cached, cacheWrite, output } } }\n * orgs/{orgId}/aiUsageByUser/{uid}/months/{YYYY-MM}\n * tokens: { input, cached, cacheWrite, output }\n *\n * The month document's own top-level `inputTokens`, `outputTokens`,\n * `cacheReadTokens` and `cacheWriteTokens` stay its totals; `kinds` splits\n * them by what the request was for.\n */\n\n/** The month document's per-kind map. */\nexport const AI_USAGE_MONTH_KINDS_FIELD = 'kinds'\n\n/** The token map, on a person's month and on each kind of the org's. */\nexport const AI_USAGE_TOKENS_FIELD = 'tokens'\n\nexport interface AiTokenTotals {\n /** Prompt tokens sent uncached, at the model's input rate. */\n input: number\n /** Prompt tokens read from the prompt cache, at its read rate. */\n cached: number\n /** Prompt tokens written to the prompt cache, at its write rate. */\n cacheWrite: number\n /** Tokens the model generated, thinking included. */\n output: number\n}\n\nconst count = (value: unknown): number => {\n const parsed = Number(value ?? 0)\n return Number.isFinite(parsed) && parsed > 0 ? Math.floor(parsed) : 0\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n\nexport function emptyAiTokenTotals(): AiTokenTotals {\n return { input: 0, cached: 0, cacheWrite: 0, output: 0 }\n}\n\n/** A request's usage, in the rollups' names. */\nexport function aiTokenTotalsFrom(usage: AiUsage): AiTokenTotals {\n return {\n input: count(usage.inputTokens),\n cached: count(usage.cacheReadTokens),\n cacheWrite: count(usage.cacheWriteTokens),\n output: count(usage.outputTokens),\n }\n}\n\nexport function addAiTokenTotals(a: AiTokenTotals, b: AiTokenTotals): AiTokenTotals {\n return {\n input: a.input + b.input,\n cached: a.cached + b.cached,\n cacheWrite: a.cacheWrite + b.cacheWrite,\n output: a.output + b.output,\n }\n}\n\n/** A stored token map read back, every absent or malformed count as zero. */\nexport function readAiTokenTotals(raw: unknown): AiTokenTotals {\n const record = isRecord(raw) ? raw : {}\n return {\n input: count(record['input']),\n cached: count(record['cached']),\n cacheWrite: count(record['cacheWrite']),\n output: count(record['output']),\n }\n}\n\n/**\n * The share of prompt tokens served from the cache: reads over everything the\n * prompt was billed as — sent, read and written.\n *\n * Writes sit in the denominator on purpose. A prefix that expires and is\n * rewritten every other request is the expensive failure, since a write costs\n * more than a fresh input token; a rate over reads and fresh input alone\n * reads that month as healthy. `null` when there are no prompt tokens at all,\n * which is nothing to divide rather than a 0% hit rate.\n */\nexport function aiCacheHitRate(\n tokens: Pick<AiTokenTotals, 'input' | 'cached' | 'cacheWrite'>,\n): number | null {\n const prompt = tokens.input + tokens.cached + tokens.cacheWrite\n return prompt > 0 ? tokens.cached / prompt : null\n}\n\n/** One kind of request in an org's month. */\nexport interface AiKindMonth {\n /** An `AiUsageKind`: `assist`, a besigner mode, or a job kind. */\n kind: string\n /** Metered model requests; a docs answer or a cache hit is not one. */\n requests: number\n /** What the kind DREW, at billed rates — the credits behind it. */\n estCostUsd: number\n /**\n * What the kind COST US (AGL-3015). Equal to `estCostUsd` on a kind served\n * only by models billed at their provider's list, and below it wherever a\n * marked-up model served. A month written before the split answers the\n * billed figure here, which over-reads our bill rather than under-reads it.\n */\n providerCostUsd: number\n tokens: AiTokenTotals\n}\n\n/**\n * The month document's `kinds` map as rows, dearest first.\n *\n * Ordered on what each kind DREW, not on what it cost us: the reader asking\n * \"which kind is expensive\" is asking about the meter every other figure on\n * the card is denominated in, and the two orders differ only where a kind's\n * model mix differs from its neighbour's.\n */\nexport function readAiKindMonths(raw: unknown): AiKindMonth[] {\n if (!isRecord(raw)) return []\n const rows: AiKindMonth[] = []\n for (const [kind, value] of Object.entries(raw)) {\n if (!isRecord(value)) continue\n const cost = Number(value['estCostUsd'] ?? 0)\n const billed = Number.isFinite(cost) && cost > 0 ? cost : 0\n rows.push({\n kind,\n requests: count(value['requests']),\n estCostUsd: billed,\n providerCostUsd: assistProviderCostUsd(\n billed,\n value[ASSIST_PROVIDER_COST_FIELD],\n ),\n tokens: readAiTokenTotals(value[AI_USAGE_TOKENS_FIELD]),\n })\n }\n return rows.sort(\n (a, b) => b.estCostUsd - a.estCostUsd || b.requests - a.requests || a.kind.localeCompare(b.kind),\n )\n}\n"],"names":["assistProviderCostUsd","ASSIST_PROVIDER_COST_FIELD","AI_USAGE_MONTH_KINDS_FIELD","AI_USAGE_TOKENS_FIELD","count","value","parsed","Number","isFinite","Math","floor","isRecord","Array","isArray","emptyAiTokenTotals","input","cached","cacheWrite","output","aiTokenTotalsFrom","usage","inputTokens","cacheReadTokens","cacheWriteTokens","outputTokens","addAiTokenTotals","a","b","readAiTokenTotals","raw","record","aiCacheHitRate","tokens","prompt","readAiKindMonths","rows","kind","Object","entries","cost","billed","push","requests","estCostUsd","providerCostUsd","sort","localeCompare"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,qBAAqB,EACrBC,0BAA0B,QACrB,wCAAuC;AAG9C;;;;;;;;;;;;;;;;;;;;;CAqBC,GAED,uCAAuC,GACvC,OAAO,MAAMC,6BAA6B,QAAO;AAEjD,sEAAsE,GACtE,OAAO,MAAMC,wBAAwB,SAAQ;AAa7C,MAAMC,QAAQ,CAACC;IACb,MAAMC,SAASC,OAAOF,gBAAAA,QAAS;IAC/B,OAAOE,OAAOC,QAAQ,CAACF,WAAWA,SAAS,IAAIG,KAAKC,KAAK,CAACJ,UAAU;AACtE;AAEA,MAAMK,WAAW,CAACN,QAChB,OAAOA,UAAU,YAAYA,UAAU,QAAQ,CAACO,MAAMC,OAAO,CAACR;AAEhE,OAAO,SAASS;IACd,OAAO;QAAEC,OAAO;QAAGC,QAAQ;QAAGC,YAAY;QAAGC,QAAQ;IAAE;AACzD;AAEA,8CAA8C,GAC9C,OAAO,SAASC,kBAAkBC,KAAc;IAC9C,OAAO;QACLL,OAAOX,MAAMgB,MAAMC,WAAW;QAC9BL,QAAQZ,MAAMgB,MAAME,eAAe;QACnCL,YAAYb,MAAMgB,MAAMG,gBAAgB;QACxCL,QAAQd,MAAMgB,MAAMI,YAAY;IAClC;AACF;AAEA,OAAO,SAASC,iBAAiBC,CAAgB,EAAEC,CAAgB;IACjE,OAAO;QACLZ,OAAOW,EAAEX,KAAK,GAAGY,EAAEZ,KAAK;QACxBC,QAAQU,EAAEV,MAAM,GAAGW,EAAEX,MAAM;QAC3BC,YAAYS,EAAET,UAAU,GAAGU,EAAEV,UAAU;QACvCC,QAAQQ,EAAER,MAAM,GAAGS,EAAET,MAAM;IAC7B;AACF;AAEA,2EAA2E,GAC3E,OAAO,SAASU,kBAAkBC,GAAY;IAC5C,MAAMC,SAASnB,SAASkB,OAAOA,MAAM,CAAC;IACtC,OAAO;QACLd,OAAOX,MAAM0B,MAAM,CAAC,QAAQ;QAC5Bd,QAAQZ,MAAM0B,MAAM,CAAC,SAAS;QAC9Bb,YAAYb,MAAM0B,MAAM,CAAC,aAAa;QACtCZ,QAAQd,MAAM0B,MAAM,CAAC,SAAS;IAChC;AACF;AAEA;;;;;;;;;CASC,GACD,OAAO,SAASC,eACdC,MAA8D;IAE9D,MAAMC,SAASD,OAAOjB,KAAK,GAAGiB,OAAOhB,MAAM,GAAGgB,OAAOf,UAAU;IAC/D,OAAOgB,SAAS,IAAID,OAAOhB,MAAM,GAAGiB,SAAS;AAC/C;AAoBA;;;;;;;CAOC,GACD,OAAO,SAASC,iBAAiBL,GAAY;IAC3C,IAAI,CAAClB,SAASkB,MAAM,OAAO,EAAE;IAC7B,MAAMM,OAAsB,EAAE;IAC9B,KAAK,MAAM,CAACC,MAAM/B,MAAM,IAAIgC,OAAOC,OAAO,CAACT,KAAM;YAE3BxB;QADpB,IAAI,CAACM,SAASN,QAAQ;QACtB,MAAMkC,OAAOhC,QAAOF,oBAAAA,KAAK,CAAC,aAAa,YAAnBA,oBAAuB;QAC3C,MAAMmC,SAASjC,OAAOC,QAAQ,CAAC+B,SAASA,OAAO,IAAIA,OAAO;QAC1DJ,KAAKM,IAAI,CAAC;YACRL;YACAM,UAAUtC,MAAMC,KAAK,CAAC,WAAW;YACjCsC,YAAYH;YACZI,iBAAiB5C,sBACfwC,QACAnC,KAAK,CAACJ,2BAA2B;YAEnC+B,QAAQJ,kBAAkBvB,KAAK,CAACF,sBAAsB;QACxD;IACF;IACA,OAAOgC,KAAKU,IAAI,CACd,CAACnB,GAAGC,IAAMA,EAAEgB,UAAU,GAAGjB,EAAEiB,UAAU,IAAIhB,EAAEe,QAAQ,GAAGhB,EAAEgB,QAAQ,IAAIhB,EAAEU,IAAI,CAACU,aAAa,CAACnB,EAAES,IAAI;AAEnG"}
@@ -0,0 +1,120 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import type { AiJobKind } from './ai-jobs.types';
18
+ /**
19
+ * PER-USER AI USAGE (AGL-2928): the pure half.
20
+ *
21
+ * The org rollup at `assistUsage/{month}` says what a workspace spent on AI
22
+ * and nothing about who spent it. This module is the shape and the arithmetic
23
+ * of the second rollup — one document per person per month, under the org,
24
+ * keyed by uid — so an agency or a multi-brand workspace can see which of its
25
+ * people, on which site, is generating what. No prose, no PII beyond the uid
26
+ * the document is keyed by.
27
+ *
28
+ * The write lives in the plugin's `usage/ai-usage-by-user.ts`, inside the
29
+ * same batch as the org rollup. Everything here is dependency-free so the
30
+ * plugin's tables and the doors that serve them read one definition of a
31
+ * share, a month key and a retention window.
32
+ */
33
+ /** `orgs/{orgId}/{this}/{uid}/{months}/{YYYY-MM}` — the subcollection names. */
34
+ export declare const AI_USAGE_BY_USER_COLLECTION = "aiUsageByUser";
35
+ export declare const AI_USAGE_BY_USER_MONTHS_COLLECTION = "months";
36
+ /**
37
+ * How many months a person's usage is kept, counted from the month it
38
+ * describes. Thirteen: a full year of month-over-month comparison for a
39
+ * workspace admin, plus the month in progress. A TTL policy on the month
40
+ * document's `expiresAt` enforces it — see `aiUsageByUserExpiry`.
41
+ */
42
+ export declare const AI_USAGE_BY_USER_RETENTION_MONTHS = 13;
43
+ /**
44
+ * What an AI request was FOR, as the per-user rollup buckets it.
45
+ *
46
+ * `assist` is a console chat turn; `element`, `blog` and `section` are the
47
+ * besigner's three assist modes; the rest are generation job kinds, named
48
+ * exactly as the job document names them so a reader can join the two.
49
+ */
50
+ export type AiUsageKind = 'assist' | 'element' | 'blog' | 'section' | AiJobKind;
51
+ /** One person's month, zero-filled — the shape every reader hands on. */
52
+ export interface AiUsageByUserMonth {
53
+ uid: string;
54
+ month: string;
55
+ /** Credits drawn, each request rounded up as the meter rounds. */
56
+ credits: number;
57
+ /**
58
+ * The measured provider spend behind `credits`. Server-side only: no
59
+ * customer surface renders it, and `aiUsageShare` is how it becomes a
60
+ * figure a customer may see.
61
+ */
62
+ estCostUsd: number;
63
+ requests: number;
64
+ refusals: number;
65
+ /** Credits by `AiUsageKind`. */
66
+ byKind: Record<string, number>;
67
+ /** Credits by host id, for requests that named a site. */
68
+ byHost: Record<string, number>;
69
+ }
70
+ /** Whether `value` is a `YYYY-MM` month key. */
71
+ export declare function isAiUsageMonthKey(value: unknown): value is string;
72
+ /**
73
+ * The month keys a reader may ask for, newest first: the month in progress
74
+ * and the twelve before it — the retention window, so a picker built from
75
+ * this list never names a month the TTL has reaped.
76
+ */
77
+ export declare function aiUsageMonthKeys(now?: Date, count?: number): string[];
78
+ /** Whether `month` is inside the window `aiUsageMonthKeys` describes. */
79
+ export declare function aiUsageMonthWithinRetention(month: string, now?: Date): boolean;
80
+ /**
81
+ * When a month document expires: the first instant of the month that is
82
+ * `AI_USAGE_BY_USER_RETENTION_MONTHS` after the one it describes has closed.
83
+ *
84
+ * A `Date`, not a number: the TTL policy keys on a Firestore Timestamp and
85
+ * silently governs nothing when the field is a number. Deterministic per
86
+ * month, so every increment into the document re-stamps the same value and
87
+ * the policy never moves under a month that is still being written.
88
+ */
89
+ export declare function aiUsageByUserExpiry(month: string): Date;
90
+ /**
91
+ * The kind an assist request was, read off the route it arrived on — for the
92
+ * meters that carry a route and no kind of their own. The three besigner
93
+ * modes name themselves in the path; everything else is a chat turn.
94
+ */
95
+ export declare function aiUsageKindFromRoute(route: string | null | undefined): AiUsageKind;
96
+ /**
97
+ * One person's share of the workspace's spend for the month, in `[0, 1]`.
98
+ *
99
+ * Measured on the dollar figures, never on credits: the org meter rounds the
100
+ * month's spend up ONCE, while a person's credits round each request up, so
101
+ * a roster's credits can sum to a little more than the pool they drew from.
102
+ * The ratio of measured spends has no such drift. Clamped, because a month
103
+ * document written a moment after the org rollup is still a fraction, not a
104
+ * percentage over one hundred — and rounded to a basis point, which is finer
105
+ * than any surface renders and coarser than floating-point noise.
106
+ */
107
+ export declare function aiUsageShare(userEstCostUsd: number, orgEstCostUsd: number): number;
108
+ /**
109
+ * A month document as a complete record. Absent and malformed fields read as
110
+ * zero; a `credits` the writer never set is derived from the spend, so a
111
+ * document written before the field existed still ranks.
112
+ */
113
+ export declare function aiUsageByUserMonthFrom(raw: Record<string, unknown> | null | undefined, uid: string, month: string): AiUsageByUserMonth;
114
+ /** The kinds a person drew the most credits on, dearest first. */
115
+ export declare function topAiUsageKinds(byKind: Record<string, number>, limit?: number): Array<{
116
+ kind: string;
117
+ credits: number;
118
+ }>;
119
+ /** Two month documents for one person, summed — the roster column's figure. */
120
+ export declare function sumAiUsageCredits(months: readonly AiUsageByUserMonth[]): number;
@@ -0,0 +1,139 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ import { assistCreditsFromUsd } from "@aglyn/aglyn/app-utils/assist-credits";
17
+ /**
18
+ * PER-USER AI USAGE (AGL-2928): the pure half.
19
+ *
20
+ * The org rollup at `assistUsage/{month}` says what a workspace spent on AI
21
+ * and nothing about who spent it. This module is the shape and the arithmetic
22
+ * of the second rollup — one document per person per month, under the org,
23
+ * keyed by uid — so an agency or a multi-brand workspace can see which of its
24
+ * people, on which site, is generating what. No prose, no PII beyond the uid
25
+ * the document is keyed by.
26
+ *
27
+ * The write lives in the plugin's `usage/ai-usage-by-user.ts`, inside the
28
+ * same batch as the org rollup. Everything here is dependency-free so the
29
+ * plugin's tables and the doors that serve them read one definition of a
30
+ * share, a month key and a retention window.
31
+ */ /** `orgs/{orgId}/{this}/{uid}/{months}/{YYYY-MM}` — the subcollection names. */ export const AI_USAGE_BY_USER_COLLECTION = 'aiUsageByUser';
32
+ export const AI_USAGE_BY_USER_MONTHS_COLLECTION = 'months';
33
+ /**
34
+ * How many months a person's usage is kept, counted from the month it
35
+ * describes. Thirteen: a full year of month-over-month comparison for a
36
+ * workspace admin, plus the month in progress. A TTL policy on the month
37
+ * document's `expiresAt` enforces it — see `aiUsageByUserExpiry`.
38
+ */ export const AI_USAGE_BY_USER_RETENTION_MONTHS = 13;
39
+ const MONTH_KEY = /^\d{4}-(0[1-9]|1[0-2])$/;
40
+ /** Whether `value` is a `YYYY-MM` month key. */ export function isAiUsageMonthKey(value) {
41
+ return typeof value === 'string' && MONTH_KEY.test(value);
42
+ }
43
+ /**
44
+ * The month keys a reader may ask for, newest first: the month in progress
45
+ * and the twelve before it — the retention window, so a picker built from
46
+ * this list never names a month the TTL has reaped.
47
+ */ export function aiUsageMonthKeys(now = new Date(), count = AI_USAGE_BY_USER_RETENTION_MONTHS) {
48
+ const keys = [];
49
+ for(let back = 0; back < count; back += 1){
50
+ keys.push(new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth() - back, 1)).toISOString().slice(0, 7));
51
+ }
52
+ return keys;
53
+ }
54
+ /** Whether `month` is inside the window `aiUsageMonthKeys` describes. */ export function aiUsageMonthWithinRetention(month, now = new Date()) {
55
+ return isAiUsageMonthKey(month) && aiUsageMonthKeys(now).includes(month);
56
+ }
57
+ /**
58
+ * When a month document expires: the first instant of the month that is
59
+ * `AI_USAGE_BY_USER_RETENTION_MONTHS` after the one it describes has closed.
60
+ *
61
+ * A `Date`, not a number: the TTL policy keys on a Firestore Timestamp and
62
+ * silently governs nothing when the field is a number. Deterministic per
63
+ * month, so every increment into the document re-stamps the same value and
64
+ * the policy never moves under a month that is still being written.
65
+ */ export function aiUsageByUserExpiry(month) {
66
+ if (!isAiUsageMonthKey(month)) {
67
+ throw new Error(`not a month key: ${month}`);
68
+ }
69
+ const [year, monthOfYear] = month.split('-').map(Number);
70
+ return new Date(Date.UTC(year, monthOfYear + AI_USAGE_BY_USER_RETENTION_MONTHS, 1));
71
+ }
72
+ /**
73
+ * The kind an assist request was, read off the route it arrived on — for the
74
+ * meters that carry a route and no kind of their own. The three besigner
75
+ * modes name themselves in the path; everything else is a chat turn.
76
+ */ export function aiUsageKindFromRoute(route) {
77
+ var _String_split_filter_pop;
78
+ const tail = (_String_split_filter_pop = String(route != null ? route : '').split('/').filter(Boolean).pop()) != null ? _String_split_filter_pop : '';
79
+ if (tail === 'element' || tail === 'blog' || tail === 'section') return tail;
80
+ return 'assist';
81
+ }
82
+ /**
83
+ * One person's share of the workspace's spend for the month, in `[0, 1]`.
84
+ *
85
+ * Measured on the dollar figures, never on credits: the org meter rounds the
86
+ * month's spend up ONCE, while a person's credits round each request up, so
87
+ * a roster's credits can sum to a little more than the pool they drew from.
88
+ * The ratio of measured spends has no such drift. Clamped, because a month
89
+ * document written a moment after the org rollup is still a fraction, not a
90
+ * percentage over one hundred — and rounded to a basis point, which is finer
91
+ * than any surface renders and coarser than floating-point noise.
92
+ */ export function aiUsageShare(userEstCostUsd, orgEstCostUsd) {
93
+ const user = Number(userEstCostUsd);
94
+ const org = Number(orgEstCostUsd);
95
+ if (!Number.isFinite(user) || user <= 0) return 0;
96
+ if (!Number.isFinite(org) || org <= 0) return 0;
97
+ return Math.min(1, Math.round(user / org * 10000) / 10000);
98
+ }
99
+ const finite = (value)=>{
100
+ const parsed = Number(value != null ? value : 0);
101
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : 0;
102
+ };
103
+ const creditMap = (raw)=>{
104
+ const out = {};
105
+ for (const [key, value] of Object.entries(raw != null ? raw : {})){
106
+ const credits = Math.floor(finite(value));
107
+ if (credits > 0) out[key] = credits;
108
+ }
109
+ return out;
110
+ };
111
+ /**
112
+ * A month document as a complete record. Absent and malformed fields read as
113
+ * zero; a `credits` the writer never set is derived from the spend, so a
114
+ * document written before the field existed still ranks.
115
+ */ export function aiUsageByUserMonthFrom(raw, uid, month) {
116
+ const estCostUsd = finite(raw == null ? void 0 : raw['estCostUsd']);
117
+ const stored = Math.floor(finite(raw == null ? void 0 : raw['credits']));
118
+ return {
119
+ uid,
120
+ month,
121
+ credits: stored > 0 ? stored : assistCreditsFromUsd(estCostUsd),
122
+ estCostUsd,
123
+ requests: Math.floor(finite(raw == null ? void 0 : raw['requests'])),
124
+ refusals: Math.floor(finite(raw == null ? void 0 : raw['refusals'])),
125
+ byKind: creditMap(raw == null ? void 0 : raw['byKind']),
126
+ byHost: creditMap(raw == null ? void 0 : raw['byHost'])
127
+ };
128
+ }
129
+ /** The kinds a person drew the most credits on, dearest first. */ export function topAiUsageKinds(byKind, limit = 3) {
130
+ return Object.entries(byKind).map(([kind, credits])=>({
131
+ kind,
132
+ credits
133
+ })).sort((a, b)=>b.credits - a.credits || a.kind.localeCompare(b.kind)).slice(0, limit);
134
+ }
135
+ /** Two month documents for one person, summed — the roster column's figure. */ export function sumAiUsageCredits(months) {
136
+ return months.reduce((sum, entry)=>sum + entry.credits, 0);
137
+ }
138
+
139
+ //# sourceMappingURL=ai-usage-by-user.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-usage-by-user.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 type { AiJobKind } from './ai-jobs.types'\nimport { assistCreditsFromUsd } from '@aglyn/aglyn/app-utils/assist-credits'\n\n/**\n * PER-USER AI USAGE (AGL-2928): the pure half.\n *\n * The org rollup at `assistUsage/{month}` says what a workspace spent on AI\n * and nothing about who spent it. This module is the shape and the arithmetic\n * of the second rollup — one document per person per month, under the org,\n * keyed by uid — so an agency or a multi-brand workspace can see which of its\n * people, on which site, is generating what. No prose, no PII beyond the uid\n * the document is keyed by.\n *\n * The write lives in the plugin's `usage/ai-usage-by-user.ts`, inside the\n * same batch as the org rollup. Everything here is dependency-free so the\n * plugin's tables and the doors that serve them read one definition of a\n * share, a month key and a retention window.\n */\n\n/** `orgs/{orgId}/{this}/{uid}/{months}/{YYYY-MM}` — the subcollection names. */\nexport const AI_USAGE_BY_USER_COLLECTION = 'aiUsageByUser'\nexport const AI_USAGE_BY_USER_MONTHS_COLLECTION = 'months'\n\n/**\n * How many months a person's usage is kept, counted from the month it\n * describes. Thirteen: a full year of month-over-month comparison for a\n * workspace admin, plus the month in progress. A TTL policy on the month\n * document's `expiresAt` enforces it — see `aiUsageByUserExpiry`.\n */\nexport const AI_USAGE_BY_USER_RETENTION_MONTHS = 13\n\n/**\n * What an AI request was FOR, as the per-user rollup buckets it.\n *\n * `assist` is a console chat turn; `element`, `blog` and `section` are the\n * besigner's three assist modes; the rest are generation job kinds, named\n * exactly as the job document names them so a reader can join the two.\n */\nexport type AiUsageKind = 'assist' | 'element' | 'blog' | 'section' | AiJobKind\n\n/** One person's month, zero-filled — the shape every reader hands on. */\nexport interface AiUsageByUserMonth {\n uid: string\n month: string\n /** Credits drawn, each request rounded up as the meter rounds. */\n credits: number\n /**\n * The measured provider spend behind `credits`. Server-side only: no\n * customer surface renders it, and `aiUsageShare` is how it becomes a\n * figure a customer may see.\n */\n estCostUsd: number\n requests: number\n refusals: number\n /** Credits by `AiUsageKind`. */\n byKind: Record<string, number>\n /** Credits by host id, for requests that named a site. */\n byHost: Record<string, number>\n}\n\nconst MONTH_KEY = /^\\d{4}-(0[1-9]|1[0-2])$/\n\n/** Whether `value` is a `YYYY-MM` month key. */\nexport function isAiUsageMonthKey(value: unknown): value is string {\n return typeof value === 'string' && MONTH_KEY.test(value)\n}\n\n/**\n * The month keys a reader may ask for, newest first: the month in progress\n * and the twelve before it — the retention window, so a picker built from\n * this list never names a month the TTL has reaped.\n */\nexport function aiUsageMonthKeys(\n now: Date = new Date(),\n count: number = AI_USAGE_BY_USER_RETENTION_MONTHS,\n): string[] {\n const keys: string[] = []\n for (let back = 0; back < count; back += 1) {\n keys.push(\n new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth() - back, 1))\n .toISOString()\n .slice(0, 7),\n )\n }\n return keys\n}\n\n/** Whether `month` is inside the window `aiUsageMonthKeys` describes. */\nexport function aiUsageMonthWithinRetention(\n month: string,\n now: Date = new Date(),\n): boolean {\n return isAiUsageMonthKey(month) && aiUsageMonthKeys(now).includes(month)\n}\n\n/**\n * When a month document expires: the first instant of the month that is\n * `AI_USAGE_BY_USER_RETENTION_MONTHS` after the one it describes has closed.\n *\n * A `Date`, not a number: the TTL policy keys on a Firestore Timestamp and\n * silently governs nothing when the field is a number. Deterministic per\n * month, so every increment into the document re-stamps the same value and\n * the policy never moves under a month that is still being written.\n */\nexport function aiUsageByUserExpiry(month: string): Date {\n if (!isAiUsageMonthKey(month)) {\n throw new Error(`not a month key: ${month}`)\n }\n const [year, monthOfYear] = month.split('-').map(Number)\n return new Date(\n Date.UTC(year, monthOfYear + AI_USAGE_BY_USER_RETENTION_MONTHS, 1),\n )\n}\n\n/**\n * The kind an assist request was, read off the route it arrived on — for the\n * meters that carry a route and no kind of their own. The three besigner\n * modes name themselves in the path; everything else is a chat turn.\n */\nexport function aiUsageKindFromRoute(route: string | null | undefined): AiUsageKind {\n const tail = String(route ?? '').split('/').filter(Boolean).pop() ?? ''\n if (tail === 'element' || tail === 'blog' || tail === 'section') return tail\n return 'assist'\n}\n\n/**\n * One person's share of the workspace's spend for the month, in `[0, 1]`.\n *\n * Measured on the dollar figures, never on credits: the org meter rounds the\n * month's spend up ONCE, while a person's credits round each request up, so\n * a roster's credits can sum to a little more than the pool they drew from.\n * The ratio of measured spends has no such drift. Clamped, because a month\n * document written a moment after the org rollup is still a fraction, not a\n * percentage over one hundred — and rounded to a basis point, which is finer\n * than any surface renders and coarser than floating-point noise.\n */\nexport function aiUsageShare(\n userEstCostUsd: number,\n orgEstCostUsd: number,\n): number {\n const user = Number(userEstCostUsd)\n const org = Number(orgEstCostUsd)\n if (!Number.isFinite(user) || user <= 0) return 0\n if (!Number.isFinite(org) || org <= 0) return 0\n return Math.min(1, Math.round((user / org) * 10_000) / 10_000)\n}\n\nconst finite = (value: unknown): number => {\n const parsed = Number(value ?? 0)\n return Number.isFinite(parsed) && parsed > 0 ? parsed : 0\n}\n\nconst creditMap = (raw: unknown): Record<string, number> => {\n const out: Record<string, number> = {}\n for (const [key, value] of Object.entries(\n (raw ?? {}) as Record<string, unknown>,\n )) {\n const credits = Math.floor(finite(value))\n if (credits > 0) out[key] = credits\n }\n return out\n}\n\n/**\n * A month document as a complete record. Absent and malformed fields read as\n * zero; a `credits` the writer never set is derived from the spend, so a\n * document written before the field existed still ranks.\n */\nexport function aiUsageByUserMonthFrom(\n raw: Record<string, unknown> | null | undefined,\n uid: string,\n month: string,\n): AiUsageByUserMonth {\n const estCostUsd = finite(raw?.['estCostUsd'])\n const stored = Math.floor(finite(raw?.['credits']))\n return {\n uid,\n month,\n credits: stored > 0 ? stored : assistCreditsFromUsd(estCostUsd),\n estCostUsd,\n requests: Math.floor(finite(raw?.['requests'])),\n refusals: Math.floor(finite(raw?.['refusals'])),\n byKind: creditMap(raw?.['byKind']),\n byHost: creditMap(raw?.['byHost']),\n }\n}\n\n/** The kinds a person drew the most credits on, dearest first. */\nexport function topAiUsageKinds(\n byKind: Record<string, number>,\n limit = 3,\n): Array<{ kind: string; credits: number }> {\n return Object.entries(byKind)\n .map(([kind, credits]) => ({ kind, credits }))\n .sort((a, b) => b.credits - a.credits || a.kind.localeCompare(b.kind))\n .slice(0, limit)\n}\n\n/** Two month documents for one person, summed — the roster column's figure. */\nexport function sumAiUsageCredits(months: readonly AiUsageByUserMonth[]): number {\n return months.reduce((sum, entry) => sum + entry.credits, 0)\n}\n"],"names":["assistCreditsFromUsd","AI_USAGE_BY_USER_COLLECTION","AI_USAGE_BY_USER_MONTHS_COLLECTION","AI_USAGE_BY_USER_RETENTION_MONTHS","MONTH_KEY","isAiUsageMonthKey","value","test","aiUsageMonthKeys","now","Date","count","keys","back","push","UTC","getUTCFullYear","getUTCMonth","toISOString","slice","aiUsageMonthWithinRetention","month","includes","aiUsageByUserExpiry","Error","year","monthOfYear","split","map","Number","aiUsageKindFromRoute","route","String","tail","filter","Boolean","pop","aiUsageShare","userEstCostUsd","orgEstCostUsd","user","org","isFinite","Math","min","round","finite","parsed","creditMap","raw","out","key","Object","entries","credits","floor","aiUsageByUserMonthFrom","uid","estCostUsd","stored","requests","refusals","byKind","byHost","topAiUsageKinds","limit","kind","sort","a","b","localeCompare","sumAiUsageCredits","months","reduce","sum","entry"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAGD,SAASA,oBAAoB,QAAQ,wCAAuC;AAE5E;;;;;;;;;;;;;;CAcC,GAED,8EAA8E,GAC9E,OAAO,MAAMC,8BAA8B,gBAAe;AAC1D,OAAO,MAAMC,qCAAqC,SAAQ;AAE1D;;;;;CAKC,GACD,OAAO,MAAMC,oCAAoC,GAAE;AA+BnD,MAAMC,YAAY;AAElB,8CAA8C,GAC9C,OAAO,SAASC,kBAAkBC,KAAc;IAC9C,OAAO,OAAOA,UAAU,YAAYF,UAAUG,IAAI,CAACD;AACrD;AAEA;;;;CAIC,GACD,OAAO,SAASE,iBACdC,MAAY,IAAIC,MAAM,EACtBC,QAAgBR,iCAAiC;IAEjD,MAAMS,OAAiB,EAAE;IACzB,IAAK,IAAIC,OAAO,GAAGA,OAAOF,OAAOE,QAAQ,EAAG;QAC1CD,KAAKE,IAAI,CACP,IAAIJ,KAAKA,KAAKK,GAAG,CAACN,IAAIO,cAAc,IAAIP,IAAIQ,WAAW,KAAKJ,MAAM,IAC/DK,WAAW,GACXC,KAAK,CAAC,GAAG;IAEhB;IACA,OAAOP;AACT;AAEA,uEAAuE,GACvE,OAAO,SAASQ,4BACdC,KAAa,EACbZ,MAAY,IAAIC,MAAM;IAEtB,OAAOL,kBAAkBgB,UAAUb,iBAAiBC,KAAKa,QAAQ,CAACD;AACpE;AAEA;;;;;;;;CAQC,GACD,OAAO,SAASE,oBAAoBF,KAAa;IAC/C,IAAI,CAAChB,kBAAkBgB,QAAQ;QAC7B,MAAM,IAAIG,MAAM,CAAC,iBAAiB,EAAEH,OAAO;IAC7C;IACA,MAAM,CAACI,MAAMC,YAAY,GAAGL,MAAMM,KAAK,CAAC,KAAKC,GAAG,CAACC;IACjD,OAAO,IAAInB,KACTA,KAAKK,GAAG,CAACU,MAAMC,cAAcvB,mCAAmC;AAEpE;AAEA;;;;CAIC,GACD,OAAO,SAAS2B,qBAAqBC,KAAgC;QACtDC;IAAb,MAAMC,QAAOD,2BAAAA,OAAOD,gBAAAA,QAAS,IAAIJ,KAAK,CAAC,KAAKO,MAAM,CAACC,SAASC,GAAG,cAAlDJ,2BAAwD;IACrE,IAAIC,SAAS,aAAaA,SAAS,UAAUA,SAAS,WAAW,OAAOA;IACxE,OAAO;AACT;AAEA;;;;;;;;;;CAUC,GACD,OAAO,SAASI,aACdC,cAAsB,EACtBC,aAAqB;IAErB,MAAMC,OAAOX,OAAOS;IACpB,MAAMG,MAAMZ,OAAOU;IACnB,IAAI,CAACV,OAAOa,QAAQ,CAACF,SAASA,QAAQ,GAAG,OAAO;IAChD,IAAI,CAACX,OAAOa,QAAQ,CAACD,QAAQA,OAAO,GAAG,OAAO;IAC9C,OAAOE,KAAKC,GAAG,CAAC,GAAGD,KAAKE,KAAK,CAAC,AAACL,OAAOC,MAAO,SAAU;AACzD;AAEA,MAAMK,SAAS,CAACxC;IACd,MAAMyC,SAASlB,OAAOvB,gBAAAA,QAAS;IAC/B,OAAOuB,OAAOa,QAAQ,CAACK,WAAWA,SAAS,IAAIA,SAAS;AAC1D;AAEA,MAAMC,YAAY,CAACC;IACjB,MAAMC,MAA8B,CAAC;IACrC,KAAK,MAAM,CAACC,KAAK7C,MAAM,IAAI8C,OAAOC,OAAO,CACtCJ,cAAAA,MAAO,CAAC,GACR;QACD,MAAMK,UAAUX,KAAKY,KAAK,CAACT,OAAOxC;QAClC,IAAIgD,UAAU,GAAGJ,GAAG,CAACC,IAAI,GAAGG;IAC9B;IACA,OAAOJ;AACT;AAEA;;;;CAIC,GACD,OAAO,SAASM,uBACdP,GAA+C,EAC/CQ,GAAW,EACXpC,KAAa;IAEb,MAAMqC,aAAaZ,OAAOG,uBAAAA,GAAK,CAAC,aAAa;IAC7C,MAAMU,SAAShB,KAAKY,KAAK,CAACT,OAAOG,uBAAAA,GAAK,CAAC,UAAU;IACjD,OAAO;QACLQ;QACApC;QACAiC,SAASK,SAAS,IAAIA,SAAS3D,qBAAqB0D;QACpDA;QACAE,UAAUjB,KAAKY,KAAK,CAACT,OAAOG,uBAAAA,GAAK,CAAC,WAAW;QAC7CY,UAAUlB,KAAKY,KAAK,CAACT,OAAOG,uBAAAA,GAAK,CAAC,WAAW;QAC7Ca,QAAQd,UAAUC,uBAAAA,GAAK,CAAC,SAAS;QACjCc,QAAQf,UAAUC,uBAAAA,GAAK,CAAC,SAAS;IACnC;AACF;AAEA,gEAAgE,GAChE,OAAO,SAASe,gBACdF,MAA8B,EAC9BG,QAAQ,CAAC;IAET,OAAOb,OAAOC,OAAO,CAACS,QACnBlC,GAAG,CAAC,CAAC,CAACsC,MAAMZ,QAAQ,GAAM,CAAA;YAAEY;YAAMZ;QAAQ,CAAA,GAC1Ca,IAAI,CAAC,CAACC,GAAGC,IAAMA,EAAEf,OAAO,GAAGc,EAAEd,OAAO,IAAIc,EAAEF,IAAI,CAACI,aAAa,CAACD,EAAEH,IAAI,GACnE/C,KAAK,CAAC,GAAG8C;AACd;AAEA,6EAA6E,GAC7E,OAAO,SAASM,kBAAkBC,MAAqC;IACrE,OAAOA,OAAOC,MAAM,CAAC,CAACC,KAAKC,QAAUD,MAAMC,MAAMrB,OAAO,EAAE;AAC5D"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { type HostEventType } from '@aglyn/aglyn/app-utils/workflows';
18
+ import type { AglynOrgBilling } from '@aglyn/aglyn/foundation/definitions/org-billing.types';
19
+ /**
20
+ * A `workflow` job (AGL-2919): an automation drafted from a description, or an
21
+ * existing automation explained — what it does, or why one of its runs failed.
22
+ *
23
+ * One kind, three modes, because the three share everything a job carries:
24
+ * the site, the gates, the meter and the automation vocabulary. `inputs.mode`
25
+ * picks the mode, and a job created without one drafts.
26
+ *
27
+ * - `draft` writes a new automation to the site's Actions through the
28
+ * workflows plugin's draft writer, OFF, built only from the triggers and
29
+ * steps below that this workspace can run. What the description names that
30
+ * the site does not have is left as a placeholder, never guessed.
31
+ * - `explain` reads a saved automation — an action or a workflow — and
32
+ * answers in plain words what it does.
33
+ * - `diagnose` reads a saved automation and one of its FAILED runs, as the
34
+ * run history recorded it, and answers why it failed and what to change.
35
+ *
36
+ * Nothing in any mode switches an automation on, runs one, or changes one.
37
+ */
38
+ export declare const AI_WORKFLOW_JOB_MODES: readonly ["draft", "explain", "diagnose"];
39
+ export type AiWorkflowJobMode = (typeof AI_WORKFLOW_JOB_MODES)[number];
40
+ /** What an explained automation is: an action, or a workflow of function calls. */
41
+ export declare const AI_WORKFLOW_TARGET_TYPES: readonly ["action", "workflow"];
42
+ export type AiWorkflowTargetType = (typeof AI_WORKFLOW_TARGET_TYPES)[number];
43
+ export type AiWorkflowJobInputs = {
44
+ mode: 'draft';
45
+ } | {
46
+ mode: 'explain';
47
+ targetType: AiWorkflowTargetType;
48
+ targetId: string;
49
+ } | {
50
+ mode: 'diagnose';
51
+ targetType: AiWorkflowTargetType;
52
+ targetId: string;
53
+ runId: string;
54
+ };
55
+ /** A job's inputs read into its mode, or the sentence that says what is wrong with them. */
56
+ export declare function parseAiWorkflowJobInputs(inputs: Readonly<Record<string, unknown>> | null | undefined): AiWorkflowJobInputs | string;
57
+ /** A part of the platform some triggers and steps need beyond the actions builder itself. */
58
+ export type AiAutomationNeed = 'crm' | 'webhooks' | 'bookings';
59
+ export type AiAutomationCapabilities = Readonly<Record<AiAutomationNeed, boolean>>;
60
+ /** Each need as a sentence names it. */
61
+ export declare const AI_AUTOMATION_NEED_LABELS: Readonly<Record<AiAutomationNeed, string>>;
62
+ /**
63
+ * What this workspace can run, from the entitlements the executor itself
64
+ * reads before it runs a step: `crm` for the CRM steps, `webhooks` for a
65
+ * webhook post, and `bookings` for the booking trigger's door.
66
+ */
67
+ export declare function aiAutomationCapabilities(org: Partial<AglynOrgBilling> | Readonly<Record<string, unknown>> | null | undefined): AiAutomationCapabilities;
68
+ /**
69
+ * The triggers a drafted automation may start on: every host event, which is
70
+ * every event a server door emits. The on-page events (a click, a scroll) are
71
+ * left out: they watch one element of one page, which a description cannot
72
+ * name, and they belong to the page's own interactions.
73
+ */
74
+ export declare const AI_AUTOMATION_TRIGGERS: readonly HostEventType[];
75
+ /** The triggers only a door of a part of the platform emits. */
76
+ export declare const AI_AUTOMATION_TRIGGER_NEEDS: Readonly<Partial<Record<HostEventType, AiAutomationNeed>>>;
77
+ /**
78
+ * The steps a drafted automation may take: the server steps and the flow
79
+ * steps, which act on the person an event names. The on-page steps — show an
80
+ * element, open a menu, run a script — are left out for the reason the
81
+ * on-page triggers are: they need a selector on a page a description cannot
82
+ * name.
83
+ */
84
+ export declare const AI_AUTOMATION_STEP_TYPES: readonly ["sendEmail", "notifyAdmins", "enrollList", "assignCampaign", "runWorkflow", "datasetAppend", "updateDataset", "webhookPost", "siteAlert", "wait", "waitForEvent", "exitFlow", "setContactStage", "addContactTag", "assignContactOwner", "createCrmTask", "logCrmActivity"];
85
+ export type AiAutomationStepType = (typeof AI_AUTOMATION_STEP_TYPES)[number];
86
+ /** The steps the executor refuses without a part of the platform. */
87
+ export declare const AI_AUTOMATION_STEP_NEEDS: Readonly<Partial<Record<AiAutomationStepType, AiAutomationNeed>>>;
88
+ /** The trigger's name as the Actions editor labels it. */
89
+ export declare function aiAutomationTriggerLabel(event: string): string;
90
+ /**
91
+ * Why a description was answered with no automation. Each is a fixed reason
92
+ * with a fixed sentence, so what a person reads is never the model's own
93
+ * account of itself.
94
+ */
95
+ export declare const AI_AUTOMATION_UNSUPPORTED: readonly ["not-an-automation", "no-trigger", "no-step", "needs-crm", "needs-webhooks", "needs-bookings"];
96
+ export type AiAutomationUnsupported = (typeof AI_AUTOMATION_UNSUPPORTED)[number];
97
+ /** The need an unsupported reason names, for the reasons that name one. */
98
+ export declare const AI_AUTOMATION_UNSUPPORTED_NEED: Readonly<Partial<Record<AiAutomationUnsupported, AiAutomationNeed>>>;
99
+ export declare const AI_AUTOMATION_UNSUPPORTED_COPY: Readonly<Record<AiAutomationUnsupported, string>>;
100
+ /** The id the workflows plugin is registered under. */
101
+ export declare const AI_WORKFLOWS_PLUGIN_ID = "workflows";
102
+ /** The resource the workflows plugin writes a drafted automation under. */
103
+ export declare const AI_AUTOMATION_RESOURCE = "automation";
104
+ export declare const AI_WORKFLOW_NO_SITE_COPY = "This automation job names a site this workspace does not have.";
105
+ export declare const AI_WORKFLOW_UNAVAILABLE_COPY = "Automations are not available on this site.";
106
+ export declare const AI_WORKFLOW_GONE_COPY = "That automation no longer exists.";
107
+ export declare const AI_WORKFLOW_RUN_GONE_COPY = "That run is no longer in the automation\u2019s history.";
108
+ export declare const AI_WORKFLOW_RUN_NOT_FAILED_COPY = "That run did not fail, so there is nothing to explain.";
109
+ export declare const AI_WORKFLOW_NO_DRAFT_COPY = "The AI could not draft an automation from this description. Try describing what happens, and what should happen then.";
110
+ export declare const AI_WORKFLOW_NO_EXPLANATION_COPY = "The AI could not explain this automation. Try again.";
111
+ export declare const AI_WORKFLOW_SAVE_FAILURE_COPY = "The automation was drafted but could not be saved. Try the job again.";