@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,177 @@
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
+ * THE OVERAGE GUARDS AT THE GATE (AGL-3011).
18
+ *
19
+ * Four reasons a workspace past its included band is refused, decided from
20
+ * the month's own figures and the workspace's standing, and nothing else.
21
+ * Pure: the reservation transaction calls this with what it has already
22
+ * read, so the guard costs one document read and no round trip.
23
+ *
24
+ * ## The one that matters
25
+ *
26
+ * `settling` is why the bound is a bound. The other three describe a
27
+ * workspace whose payment standing is known to be bad; `settling` describes
28
+ * one whose charges simply have not landed — because a background task was
29
+ * killed, because Stripe was down, because the charge path has a bug, or
30
+ * because it was never switched on. In every one of those cases accrued
31
+ * overage stops at the unpaid limit, having charged nothing. **The bound
32
+ * holds even if a charge never runs**, and that is the whole design.
33
+ *
34
+ * ## Every refusal is `refusedBy: 'cap'`
35
+ *
36
+ * These join the workspace's own overage ceiling (AGL-2898) rather than
37
+ * inventing a sixth refusal class, because they are the same kind of fact: a
38
+ * dollar limit on credits sold past the band. `capReason` says whose limit
39
+ * and which one, which is what decides the status and the sentence. Like
40
+ * every other refusal, they move no counter.
41
+ */ import { AI_OVERAGE_THRESHOLD_USD, AI_OVERAGE_UNPAID_LIMIT_USD, aiOverageCardOnFile, aiOverageStandingCeilingUsd } from "./ai-overage-standing.js";
42
+ function money(value) {
43
+ const number = Number(value);
44
+ return Number.isFinite(number) && number > 0 ? number : 0;
45
+ }
46
+ /**
47
+ * Which guard, if any, refuses this request.
48
+ *
49
+ * Order is deliberate and is the order a person can act on: a missing card
50
+ * is one action, a failed charge is another, and both of those are things
51
+ * the workspace can fix right now. A ceiling reached and a balance settling
52
+ * are waits, so they come last. Two guards holding at once is ordinary — a
53
+ * paused workspace is usually also at its unpaid limit — and naming the
54
+ * actionable one is worth more than naming the first one numerically true.
55
+ *
56
+ * `>=` throughout, matching `assistOverageCapReached`: a limit is met when
57
+ * it is met, not once it is passed.
58
+ *
59
+ * The card guard ABSTAINS when nobody has observed the workspace's payment
60
+ * method (see `AiOverageStanding.paymentMethodType`). That is a deliberate
61
+ * hole in the card rule and not in the bound: `settling` below does not read
62
+ * the card at all, so an unobserved workspace is still stopped at the unpaid
63
+ * limit. Closing the hole is a backfill, not a code change.
64
+ */ export function aiOverageRefusal(input) {
65
+ const overageUsd = money(input.overageUsd);
66
+ const paidUsd = money(input.paidUsd);
67
+ const unpaidUsd = Math.max(0, overageUsd - paidUsd);
68
+ const ceilingUsd = aiOverageStandingCeilingUsd(input.standing, input.now);
69
+ if (aiOverageCardOnFile(input.standing) === false) {
70
+ return {
71
+ capReason: 'no-card',
72
+ limitUsd: ceilingUsd,
73
+ unpaidUsd
74
+ };
75
+ }
76
+ if (input.standing.pause) {
77
+ return {
78
+ capReason: 'paused',
79
+ limitUsd: ceilingUsd,
80
+ unpaidUsd
81
+ };
82
+ }
83
+ if (overageUsd >= ceilingUsd) {
84
+ return {
85
+ capReason: 'limit',
86
+ limitUsd: ceilingUsd,
87
+ unpaidUsd
88
+ };
89
+ }
90
+ if (unpaidUsd >= AI_OVERAGE_UNPAID_LIMIT_USD) {
91
+ return {
92
+ capReason: 'settling',
93
+ limitUsd: AI_OVERAGE_UNPAID_LIMIT_USD,
94
+ unpaidUsd
95
+ };
96
+ }
97
+ return null;
98
+ }
99
+ /** `$25.00`, the one place a dollar figure in these sentences is formatted. */ function usd(value) {
100
+ return `$${value.toFixed(2)}`;
101
+ }
102
+ /**
103
+ * The sentence a workspace is told, by reason.
104
+ *
105
+ * In the plugin, beside the guard that produced it, so the figure quoted is
106
+ * the figure that refused. Every one of them says that INCLUDED CREDITS KEEP
107
+ * WORKING, because that is the fact a customer most needs and least expects:
108
+ * these guards stop what is sold past the band, never the band itself.
109
+ *
110
+ * `customer` is not answered here — the workspace's own ceiling keeps the
111
+ * sentence `assistOverageCapRefusalText` already gives it, which names the
112
+ * control by the label the console shows.
113
+ */ export function aiOverageRefusalText(refusal) {
114
+ switch(refusal.capReason){
115
+ case 'no-card':
116
+ return 'AI past your included credits needs a card on file. Add one under ' + 'Billing to keep going — your included credits still work.';
117
+ case 'paused':
118
+ return 'AI past your included credits is paused while a payment is ' + 'outstanding. Pay the open invoice or update your card under ' + 'Billing — your included credits still work.';
119
+ case 'limit':
120
+ return `This workspace reached this month's AI overage limit of ` + `${usd(refusal.limitUsd)}. The limit rises after each month an ` + 'invoice is paid; contact support to raise it sooner — your ' + 'included credits still work.';
121
+ case 'settling':
122
+ return `AI past your included credits is waiting on ` + `${usd(refusal.unpaidUsd)} of charges to settle. It resumes as soon ` + 'as they do — your included credits still work.';
123
+ default:
124
+ return null;
125
+ }
126
+ }
127
+ /**
128
+ * The HTTP status each reason answers with.
129
+ *
130
+ * 402 where the workspace can settle it — a card to add, an invoice to pay.
131
+ * 429 where it can only wait, which is the status the message cap and the
132
+ * spend ceiling already use for exactly that meaning. The two must not be
133
+ * swapped: a client retrying a 429 is right to, and retrying a 402 is not.
134
+ */ export function aiOverageRefusalStatus(capReason) {
135
+ return capReason === 'no-card' || capReason === 'paused' || capReason === 'customer' ? 402 : 429;
136
+ }
137
+ /**
138
+ * What the customer's overage card says about when the next charge lands.
139
+ *
140
+ * Here rather than in the component because it is the same arithmetic the
141
+ * charge trigger makes, and a card that named a different figure from the
142
+ * one that actually charges would be worse than a card that named none.
143
+ */ export function aiOverageNextChargeUsd(overageUsd, invoicedUsd) {
144
+ const remaining = money(overageUsd) - money(invoicedUsd);
145
+ return Math.max(0, AI_OVERAGE_THRESHOLD_USD - remaining);
146
+ }
147
+ /**
148
+ * The sentence and status for a reservation that AGLYN'S guards refused, or
149
+ * `null` when they did not.
150
+ *
151
+ * ONE function for all four doors — the chat door, the besigner copy
152
+ * assistant, the shared gate ladder and the generation jobs — because a
153
+ * refusal whose words differ by door is a refusal a customer cannot search
154
+ * for, and because the status and the sentence must agree about whether the
155
+ * workspace can do anything about it.
156
+ *
157
+ * `null` for the workspace's OWN ceiling and for every other refusal, so a
158
+ * door falls through to `assistOwnControlRefusalText` and the sentences it
159
+ * has always given.
160
+ */ export function aiOverageReservationRefusal(reservation) {
161
+ var _reservation_capReason;
162
+ if (reservation.refusedBy !== 'cap') return null;
163
+ const capReason = (_reservation_capReason = reservation.capReason) != null ? _reservation_capReason : null;
164
+ if (!capReason || capReason === 'customer') return null;
165
+ const text = aiOverageRefusalText({
166
+ capReason,
167
+ limitUsd: money(reservation.overageLimitUsd),
168
+ unpaidUsd: money(reservation.overageUnpaidUsd)
169
+ });
170
+ if (!text) return null;
171
+ return {
172
+ text,
173
+ status: aiOverageRefusalStatus(capReason)
174
+ };
175
+ }
176
+
177
+ //# sourceMappingURL=ai-overage-gate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/billing/ai-overage-gate.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * THE OVERAGE GUARDS AT THE GATE (AGL-3011).\n *\n * Four reasons a workspace past its included band is refused, decided from\n * the month's own figures and the workspace's standing, and nothing else.\n * Pure: the reservation transaction calls this with what it has already\n * read, so the guard costs one document read and no round trip.\n *\n * ## The one that matters\n *\n * `settling` is why the bound is a bound. The other three describe a\n * workspace whose payment standing is known to be bad; `settling` describes\n * one whose charges simply have not landed — because a background task was\n * killed, because Stripe was down, because the charge path has a bug, or\n * because it was never switched on. In every one of those cases accrued\n * overage stops at the unpaid limit, having charged nothing. **The bound\n * holds even if a charge never runs**, and that is the whole design.\n *\n * ## Every refusal is `refusedBy: 'cap'`\n *\n * These join the workspace's own overage ceiling (AGL-2898) rather than\n * inventing a sixth refusal class, because they are the same kind of fact: a\n * dollar limit on credits sold past the band. `capReason` says whose limit\n * and which one, which is what decides the status and the sentence. Like\n * every other refusal, they move no counter.\n */\n\nimport {\n AI_OVERAGE_THRESHOLD_USD,\n AI_OVERAGE_UNPAID_LIMIT_USD,\n aiOverageCardOnFile,\n aiOverageStandingCeilingUsd,\n type AiOverageStanding,\n} from './ai-overage-standing'\n\n/**\n * Which limit refused.\n *\n * - `no-card` the workspace has no card as its default payment method.\n * - `paused` accrual is stopped — a failed charge, a past-due invoice,\n * a dispute, or staff.\n * - `limit` this month's overage reached Aglyn's ceiling.\n * - `settling` accrued-but-unpaid overage reached the unpaid limit.\n * - `customer` the workspace's own ceiling (AGL-2898), which refuses\n * before any of the above and keeps its existing sentence.\n */\nexport type AiOverageCapReason =\n | 'no-card'\n | 'paused'\n | 'limit'\n | 'settling'\n | 'customer'\n\n/** What the gate hands the guards. All figures are retail dollars. */\nexport interface AiOverageGateInput {\n /** This month's overage, priced as the invoice prices it. */\n overageUsd: number\n /** What of it has been paid — `overagePaidUsd` on the month's rollup. */\n paidUsd: number\n standing: AiOverageStanding\n now: Date\n}\n\n/** The refusal, with the figure its sentence must quote. */\nexport interface AiOverageRefusal {\n capReason: AiOverageCapReason\n /** The ceiling in force, for `limit`; the unpaid limit for `settling`. */\n limitUsd: number\n /** What is accrued and unpaid, for the pause and settling sentences. */\n unpaidUsd: number\n}\n\nfunction money(value: unknown): number {\n const number = Number(value)\n return Number.isFinite(number) && number > 0 ? number : 0\n}\n\n/**\n * Which guard, if any, refuses this request.\n *\n * Order is deliberate and is the order a person can act on: a missing card\n * is one action, a failed charge is another, and both of those are things\n * the workspace can fix right now. A ceiling reached and a balance settling\n * are waits, so they come last. Two guards holding at once is ordinary — a\n * paused workspace is usually also at its unpaid limit — and naming the\n * actionable one is worth more than naming the first one numerically true.\n *\n * `>=` throughout, matching `assistOverageCapReached`: a limit is met when\n * it is met, not once it is passed.\n *\n * The card guard ABSTAINS when nobody has observed the workspace's payment\n * method (see `AiOverageStanding.paymentMethodType`). That is a deliberate\n * hole in the card rule and not in the bound: `settling` below does not read\n * the card at all, so an unobserved workspace is still stopped at the unpaid\n * limit. Closing the hole is a backfill, not a code change.\n */\nexport function aiOverageRefusal(\n input: AiOverageGateInput,\n): AiOverageRefusal | null {\n const overageUsd = money(input.overageUsd)\n const paidUsd = money(input.paidUsd)\n const unpaidUsd = Math.max(0, overageUsd - paidUsd)\n const ceilingUsd = aiOverageStandingCeilingUsd(input.standing, input.now)\n\n if (aiOverageCardOnFile(input.standing) === false) {\n return { capReason: 'no-card', limitUsd: ceilingUsd, unpaidUsd }\n }\n if (input.standing.pause) {\n return { capReason: 'paused', limitUsd: ceilingUsd, unpaidUsd }\n }\n if (overageUsd >= ceilingUsd) {\n return { capReason: 'limit', limitUsd: ceilingUsd, unpaidUsd }\n }\n if (unpaidUsd >= AI_OVERAGE_UNPAID_LIMIT_USD) {\n return {\n capReason: 'settling',\n limitUsd: AI_OVERAGE_UNPAID_LIMIT_USD,\n unpaidUsd,\n }\n }\n return null\n}\n\n/** `$25.00`, the one place a dollar figure in these sentences is formatted. */\nfunction usd(value: number): string {\n return `$${value.toFixed(2)}`\n}\n\n/**\n * The sentence a workspace is told, by reason.\n *\n * In the plugin, beside the guard that produced it, so the figure quoted is\n * the figure that refused. Every one of them says that INCLUDED CREDITS KEEP\n * WORKING, because that is the fact a customer most needs and least expects:\n * these guards stop what is sold past the band, never the band itself.\n *\n * `customer` is not answered here — the workspace's own ceiling keeps the\n * sentence `assistOverageCapRefusalText` already gives it, which names the\n * control by the label the console shows.\n */\nexport function aiOverageRefusalText(refusal: AiOverageRefusal): string | null {\n switch (refusal.capReason) {\n case 'no-card':\n return (\n 'AI past your included credits needs a card on file. Add one under ' +\n 'Billing to keep going — your included credits still work.'\n )\n case 'paused':\n return (\n 'AI past your included credits is paused while a payment is ' +\n 'outstanding. Pay the open invoice or update your card under ' +\n 'Billing — your included credits still work.'\n )\n case 'limit':\n return (\n `This workspace reached this month's AI overage limit of ` +\n `${usd(refusal.limitUsd)}. The limit rises after each month an ` +\n 'invoice is paid; contact support to raise it sooner — your ' +\n 'included credits still work.'\n )\n case 'settling':\n return (\n `AI past your included credits is waiting on ` +\n `${usd(refusal.unpaidUsd)} of charges to settle. It resumes as soon ` +\n 'as they do — your included credits still work.'\n )\n default:\n return null\n }\n}\n\n/**\n * The HTTP status each reason answers with.\n *\n * 402 where the workspace can settle it — a card to add, an invoice to pay.\n * 429 where it can only wait, which is the status the message cap and the\n * spend ceiling already use for exactly that meaning. The two must not be\n * swapped: a client retrying a 429 is right to, and retrying a 402 is not.\n */\nexport function aiOverageRefusalStatus(capReason: AiOverageCapReason): 402 | 429 {\n return capReason === 'no-card' || capReason === 'paused' || capReason === 'customer'\n ? 402\n : 429\n}\n\n/**\n * What the customer's overage card says about when the next charge lands.\n *\n * Here rather than in the component because it is the same arithmetic the\n * charge trigger makes, and a card that named a different figure from the\n * one that actually charges would be worse than a card that named none.\n */\nexport function aiOverageNextChargeUsd(\n overageUsd: number,\n invoicedUsd: number,\n): number {\n const remaining = money(overageUsd) - money(invoicedUsd)\n return Math.max(0, AI_OVERAGE_THRESHOLD_USD - remaining)\n}\n\n/** The refusal fields a reservation carries, without importing its type. */\nexport interface AiOverageRefusedReservation {\n refusedBy: string | null\n capReason?: AiOverageCapReason | null\n overageLimitUsd?: number | null\n overageUnpaidUsd?: number | null\n}\n\n/**\n * The sentence and status for a reservation that AGLYN'S guards refused, or\n * `null` when they did not.\n *\n * ONE function for all four doors — the chat door, the besigner copy\n * assistant, the shared gate ladder and the generation jobs — because a\n * refusal whose words differ by door is a refusal a customer cannot search\n * for, and because the status and the sentence must agree about whether the\n * workspace can do anything about it.\n *\n * `null` for the workspace's OWN ceiling and for every other refusal, so a\n * door falls through to `assistOwnControlRefusalText` and the sentences it\n * has always given.\n */\nexport function aiOverageReservationRefusal(\n reservation: AiOverageRefusedReservation,\n): { text: string; status: 402 | 429 } | null {\n if (reservation.refusedBy !== 'cap') return null\n const capReason = reservation.capReason ?? null\n if (!capReason || capReason === 'customer') return null\n const text = aiOverageRefusalText({\n capReason,\n limitUsd: money(reservation.overageLimitUsd),\n unpaidUsd: money(reservation.overageUnpaidUsd),\n })\n if (!text) return null\n return { text, status: aiOverageRefusalStatus(capReason) }\n}\n"],"names":["AI_OVERAGE_THRESHOLD_USD","AI_OVERAGE_UNPAID_LIMIT_USD","aiOverageCardOnFile","aiOverageStandingCeilingUsd","money","value","number","Number","isFinite","aiOverageRefusal","input","overageUsd","paidUsd","unpaidUsd","Math","max","ceilingUsd","standing","now","capReason","limitUsd","pause","usd","toFixed","aiOverageRefusalText","refusal","aiOverageRefusalStatus","aiOverageNextChargeUsd","invoicedUsd","remaining","aiOverageReservationRefusal","reservation","refusedBy","text","overageLimitUsd","overageUnpaidUsd","status"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;CAyBC,GAED,SACEA,wBAAwB,EACxBC,2BAA2B,EAC3BC,mBAAmB,EACnBC,2BAA2B,QAEtB,2BAAuB;AAuC9B,SAASC,MAAMC,KAAc;IAC3B,MAAMC,SAASC,OAAOF;IACtB,OAAOE,OAAOC,QAAQ,CAACF,WAAWA,SAAS,IAAIA,SAAS;AAC1D;AAEA;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,SAASG,iBACdC,KAAyB;IAEzB,MAAMC,aAAaP,MAAMM,MAAMC,UAAU;IACzC,MAAMC,UAAUR,MAAMM,MAAME,OAAO;IACnC,MAAMC,YAAYC,KAAKC,GAAG,CAAC,GAAGJ,aAAaC;IAC3C,MAAMI,aAAab,4BAA4BO,MAAMO,QAAQ,EAAEP,MAAMQ,GAAG;IAExE,IAAIhB,oBAAoBQ,MAAMO,QAAQ,MAAM,OAAO;QACjD,OAAO;YAAEE,WAAW;YAAWC,UAAUJ;YAAYH;QAAU;IACjE;IACA,IAAIH,MAAMO,QAAQ,CAACI,KAAK,EAAE;QACxB,OAAO;YAAEF,WAAW;YAAUC,UAAUJ;YAAYH;QAAU;IAChE;IACA,IAAIF,cAAcK,YAAY;QAC5B,OAAO;YAAEG,WAAW;YAASC,UAAUJ;YAAYH;QAAU;IAC/D;IACA,IAAIA,aAAaZ,6BAA6B;QAC5C,OAAO;YACLkB,WAAW;YACXC,UAAUnB;YACVY;QACF;IACF;IACA,OAAO;AACT;AAEA,6EAA6E,GAC7E,SAASS,IAAIjB,KAAa;IACxB,OAAO,CAAC,CAAC,EAAEA,MAAMkB,OAAO,CAAC,IAAI;AAC/B;AAEA;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,qBAAqBC,OAAyB;IAC5D,OAAQA,QAAQN,SAAS;QACvB,KAAK;YACH,OACE,uEACA;QAEJ,KAAK;YACH,OACE,gEACA,iEACA;QAEJ,KAAK;YACH,OACE,CAAC,wDAAwD,CAAC,GAC1D,GAAGG,IAAIG,QAAQL,QAAQ,EAAE,sCAAsC,CAAC,GAChE,gEACA;QAEJ,KAAK;YACH,OACE,CAAC,4CAA4C,CAAC,GAC9C,GAAGE,IAAIG,QAAQZ,SAAS,EAAE,0CAA0C,CAAC,GACrE;QAEJ;YACE,OAAO;IACX;AACF;AAEA;;;;;;;CAOC,GACD,OAAO,SAASa,uBAAuBP,SAA6B;IAClE,OAAOA,cAAc,aAAaA,cAAc,YAAYA,cAAc,aACtE,MACA;AACN;AAEA;;;;;;CAMC,GACD,OAAO,SAASQ,uBACdhB,UAAkB,EAClBiB,WAAmB;IAEnB,MAAMC,YAAYzB,MAAMO,cAAcP,MAAMwB;IAC5C,OAAOd,KAAKC,GAAG,CAAC,GAAGf,2BAA2B6B;AAChD;AAUA;;;;;;;;;;;;;CAaC,GACD,OAAO,SAASC,4BACdC,WAAwC;QAGtBA;IADlB,IAAIA,YAAYC,SAAS,KAAK,OAAO,OAAO;IAC5C,MAAMb,aAAYY,yBAAAA,YAAYZ,SAAS,YAArBY,yBAAyB;IAC3C,IAAI,CAACZ,aAAaA,cAAc,YAAY,OAAO;IACnD,MAAMc,OAAOT,qBAAqB;QAChCL;QACAC,UAAUhB,MAAM2B,YAAYG,eAAe;QAC3CrB,WAAWT,MAAM2B,YAAYI,gBAAgB;IAC/C;IACA,IAAI,CAACF,MAAM,OAAO;IAClB,OAAO;QAAEA;QAAMG,QAAQV,uBAAuBP;IAAW;AAC3D"}
@@ -0,0 +1,135 @@
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 AiOverageOrg } from './ai-overage-standing';
18
+ /** The subcollection and document the standing lives at. */
19
+ export declare const AI_BILLING_SUBCOLLECTION = "aiBilling";
20
+ export declare const AI_BILLING_STANDING_DOC = "standing";
21
+ /** The subcollection one row per charge lives in. */
22
+ export declare const AI_OVERAGE_CHARGES_SUBCOLLECTION = "aiOverageCharges";
23
+ /** Which sweep asked for the charge. */
24
+ export type AiOverageChargeKind = 'threshold' | 'closeout';
25
+ /** Where a charge is in its life. */
26
+ export type AiOverageChargeStatus = 'claimed' | 'open' | 'paid' | 'failed' | 'void';
27
+ /** A claim taken, ready to be charged. */
28
+ export interface AiOverageClaim {
29
+ chargeId: string;
30
+ orgId: string;
31
+ month: string;
32
+ seq: number;
33
+ kind: AiOverageChargeKind;
34
+ /** Floored to the cent — Stripe bills whole cents. */
35
+ amountUsd: number;
36
+ /** The credits and rate the amount came from, for the audit row. */
37
+ credits: number;
38
+ rateUsdPer1k: number | null;
39
+ }
40
+ /** Why no claim was taken. Each one is a different thing to do about it. */
41
+ export type AiOverageClaimRefusal = 'below-threshold' | 'charge-already-open' | 'no-card' | 'paused' | 'not-sold';
42
+ export type AiOverageClaimResult = {
43
+ claimed: AiOverageClaim;
44
+ refused: null;
45
+ } | {
46
+ claimed: null;
47
+ refused: AiOverageClaimRefusal;
48
+ };
49
+ /** Down to the cent. Never up: a rounded-up cent is a cent never accrued. */
50
+ export declare function floorToCent(usd: number): number;
51
+ /**
52
+ * `{month}-{seq}` — readable, sortable, and unique per workspace-month.
53
+ *
54
+ * The id is also the Stripe idempotency key's payload and the metadata the
55
+ * reconcile search matches on, so it must survive a URL and a Stripe search
56
+ * query unescaped: digits, a hyphen, nothing else.
57
+ */
58
+ export declare function aiOverageChargeId(month: string, seq: number): string;
59
+ /**
60
+ * Takes a claim on the workspace's unbilled overage, or explains why not.
61
+ *
62
+ * The four conditions are the design's, in one transaction with the reads
63
+ * they are decided from:
64
+ *
65
+ * - enough unbilled overage (the threshold, or the minimum for a close-out);
66
+ * - no charge already open — one at a time, so a failure has one owner;
67
+ * - a card on file, since the bound assumes a payment method that settles
68
+ * now rather than in days;
69
+ * - not paused.
70
+ *
71
+ * The card condition abstains when the workspace's payment method has never
72
+ * been observed, for the reason `AiOverageStanding.paymentMethodType` gives.
73
+ * A charge attempted against a customer with no default simply fails, and
74
+ * the failure pauses accrual like any other — the guard is an optimization
75
+ * here, not the safety property.
76
+ */
77
+ export declare function claimAiOverageCharge(firestore: FirebaseFirestore.Firestore, request: {
78
+ orgId: string;
79
+ org: AiOverageOrg;
80
+ month: string;
81
+ kind: AiOverageChargeKind;
82
+ now?: Date;
83
+ }): Promise<AiOverageClaimResult>;
84
+ /** What Stripe said, as the ledger records it. */
85
+ export interface AiOverageSettlement {
86
+ chargeId: string;
87
+ month: string;
88
+ /** `null` only when no invoice was ever created. */
89
+ invoiceId: string | null;
90
+ status: AiOverageChargeStatus;
91
+ /**
92
+ * What Stripe actually collected, in dollars (AGL-3023).
93
+ *
94
+ * The month's paid total moves by THIS and never by the claim. The two are
95
+ * normally equal, and the case where they are not is the one that matters:
96
+ * an invoice that finalized at zero or collected less than it billed would
97
+ * otherwise clear a balance nobody paid, and the gate's unpaid bound would
98
+ * be satisfied by our own bookkeeping instead of by money.
99
+ *
100
+ * Omitted on a settlement that is not a payment, where it is not read.
101
+ */
102
+ paidUsd?: number;
103
+ }
104
+ /**
105
+ * Records what became of a claimed charge.
106
+ *
107
+ * `paid` adds the amount to the month's `overagePaidUsd`, which is what the
108
+ * gate's unpaid bound subtracts — so paying is what lets a workspace keep
109
+ * going, and nothing else does.
110
+ *
111
+ * An invoice that exists but is not paid KEEPS its claim on
112
+ * `overageInvoicedUsd`: it is a real bill, Stripe's retries may still settle
113
+ * it, and re-billing the same dollars on a second invoice would charge the
114
+ * customer twice for one month's usage. Only a claim that never became an
115
+ * invoice at all releases what it claimed, so those dollars can be charged
116
+ * by a later attempt.
117
+ *
118
+ * The open-charge slot is always cleared. Leaving it set on a failure would
119
+ * block the close-out and every later charge behind an invoice that is
120
+ * never going to move on its own.
121
+ */
122
+ export declare function settleAiOverageCharge(firestore: FirebaseFirestore.Firestore, orgId: string, settlement: AiOverageSettlement): Promise<void>;
123
+ /** The month's charge counters, as the customer card and staff card read them. */
124
+ export interface AiOverageMonthLedger {
125
+ invoicedUsd: number;
126
+ paidUsd: number;
127
+ charges: number;
128
+ open: {
129
+ chargeId: string;
130
+ invoiceId: string | null;
131
+ amountUsd: number;
132
+ } | null;
133
+ }
134
+ /** Reads the four fields off a month's rollup, defensively. */
135
+ export declare function readAiOverageMonthLedger(data: Record<string, unknown> | null | undefined): AiOverageMonthLedger;
@@ -0,0 +1,278 @@
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
2
+ /**
3
+ * @license
4
+ * Copyright 2026 Aglyn LLC
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */ /**
18
+ * THE OVERAGE CHARGE LEDGER (AGL-3011).
19
+ *
20
+ * Every dollar of AI overage a workspace is charged mid-period passes
21
+ * through here twice: once as a CLAIM, taken in a transaction before any
22
+ * money is asked for, and once as a SETTLEMENT, recorded after Stripe
23
+ * answers. Nothing in this module talks to Stripe.
24
+ *
25
+ * ## Why claim first
26
+ *
27
+ * The figure that decides a charge — the month's overage — is a counter many
28
+ * requests move. Two requests crossing the threshold a millisecond apart
29
+ * both read "$25 unbilled" and would both charge for it. The claim closes
30
+ * that: inside one transaction it moves `overageInvoicedUsd` forward by the
31
+ * amount it is about to charge and records an open charge, so the second
32
+ * request reads an already-claimed balance and stands down. The invoice is
33
+ * created afterwards, outside the transaction, because a Stripe call inside
34
+ * a Firestore transaction would be retried by the transaction.
35
+ *
36
+ * ## What a lost process costs
37
+ *
38
+ * A claim that never became an invoice leaves `overageInvoicedUsd` ahead of
39
+ * what was billed, which UNDER-charges rather than over-charges, and leaves
40
+ * an open charge that blocks the next one. Both are repaired by the
41
+ * reconcile sweep, which asks Stripe whether the claim ever became an
42
+ * invoice and either records it or releases the claim. Under-charging while
43
+ * confused is the direction this must err in.
44
+ *
45
+ * ## The documents
46
+ *
47
+ * `orgs/{orgId}/assistUsage/{YYYY-MM}` — the month's rollup, which the
48
+ * reservation already reads, gains four fields so the gate costs no extra
49
+ * read: `overageInvoicedUsd`, `overagePaidUsd`, `overageCharges` and
50
+ * `overageInvoiceOpen`.
51
+ *
52
+ * `orgs/{orgId}/aiOverageCharges/{chargeId}` — one row per charge, the
53
+ * audit trail staff read and the reconcile sweep walks.
54
+ *
55
+ * Both are server-written: the rules allow the same readers as
56
+ * `aiAllotments` and no writer at all.
57
+ */ import { FieldValue } from "firebase-admin/firestore";
58
+ import { assistMonthOverage } from "@aglyn/aglyn/app-utils/assist-credits";
59
+ import { AI_OVERAGE_MIN_CHARGE_USD, AI_OVERAGE_THRESHOLD_USD, aiOverageCardOnFile, readAiOverageStanding } from "./ai-overage-standing.js";
60
+ /** The subcollection and document the standing lives at. */ export const AI_BILLING_SUBCOLLECTION = 'aiBilling';
61
+ export const AI_BILLING_STANDING_DOC = 'standing';
62
+ /** The subcollection one row per charge lives in. */ export const AI_OVERAGE_CHARGES_SUBCOLLECTION = 'aiOverageCharges';
63
+ function money(value) {
64
+ const number = Number(value);
65
+ return Number.isFinite(number) && number > 0 ? number : 0;
66
+ }
67
+ /** Down to the cent. Never up: a rounded-up cent is a cent never accrued. */ export function floorToCent(usd) {
68
+ return Math.floor(money(usd) * 100) / 100;
69
+ }
70
+ /**
71
+ * `{month}-{seq}` — readable, sortable, and unique per workspace-month.
72
+ *
73
+ * The id is also the Stripe idempotency key's payload and the metadata the
74
+ * reconcile search matches on, so it must survive a URL and a Stripe search
75
+ * query unescaped: digits, a hyphen, nothing else.
76
+ */ export function aiOverageChargeId(month, seq) {
77
+ return `${month}-${String(Math.max(1, Math.floor(seq))).padStart(3, '0')}`;
78
+ }
79
+ /**
80
+ * Takes a claim on the workspace's unbilled overage, or explains why not.
81
+ *
82
+ * The four conditions are the design's, in one transaction with the reads
83
+ * they are decided from:
84
+ *
85
+ * - enough unbilled overage (the threshold, or the minimum for a close-out);
86
+ * - no charge already open — one at a time, so a failure has one owner;
87
+ * - a card on file, since the bound assumes a payment method that settles
88
+ * now rather than in days;
89
+ * - not paused.
90
+ *
91
+ * The card condition abstains when the workspace's payment method has never
92
+ * been observed, for the reason `AiOverageStanding.paymentMethodType` gives.
93
+ * A charge attempted against a customer with no default simply fails, and
94
+ * the failure pauses accrual like any other — the guard is an optimization
95
+ * here, not the safety property.
96
+ */ export async function claimAiOverageCharge(firestore, request) {
97
+ var _request_now;
98
+ const now = (_request_now = request.now) != null ? _request_now : new Date();
99
+ const orgRef = firestore.collection('orgs').doc(request.orgId);
100
+ const usageRef = orgRef.collection('assistUsage').doc(request.month);
101
+ const standingRef = orgRef.collection(AI_BILLING_SUBCOLLECTION).doc(AI_BILLING_STANDING_DOC);
102
+ // A close-out settles a month that is over: there is nothing left to
103
+ // accrue, so anything Stripe will accept is worth billing. A threshold
104
+ // charge waits for the threshold, which is what keeps the invoice count
105
+ // and its fees down.
106
+ const floorUsd = request.kind === 'closeout' ? AI_OVERAGE_MIN_CHARGE_USD : AI_OVERAGE_THRESHOLD_USD;
107
+ return firestore.runTransaction(async (tx)=>{
108
+ var _standingSnapshot_data;
109
+ const [usageSnapshot, standingSnapshot] = await Promise.all([
110
+ tx.get(usageRef),
111
+ tx.get(standingRef)
112
+ ]);
113
+ const standing = readAiOverageStanding(standingSnapshot.exists ? (_standingSnapshot_data = standingSnapshot.data()) != null ? _standingSnapshot_data : null : null);
114
+ if (aiOverageCardOnFile(standing) === false) {
115
+ return {
116
+ claimed: null,
117
+ refused: 'no-card'
118
+ };
119
+ }
120
+ if (standing.pause) return {
121
+ claimed: null,
122
+ refused: 'paused'
123
+ };
124
+ if (usageSnapshot.get('overageInvoiceOpen')) {
125
+ return {
126
+ claimed: null,
127
+ refused: 'charge-already-open'
128
+ };
129
+ }
130
+ const priced = assistMonthOverage(request.org, money(usageSnapshot.get('estCostUsd')));
131
+ // A plan that sells nothing past its band prices its overage to zero, so
132
+ // this is structural rather than a check that could be forgotten — but
133
+ // it is named, because "we billed nothing" and "there is nothing to
134
+ // bill" are different answers to a staff question.
135
+ if (priced.overageRateUsd === null) {
136
+ return {
137
+ claimed: null,
138
+ refused: 'not-sold'
139
+ };
140
+ }
141
+ const invoicedUsd = money(usageSnapshot.get('overageInvoicedUsd'));
142
+ const unbilledUsd = floorToCent(priced.overageMonthlyUsd - invoicedUsd);
143
+ if (!(unbilledUsd >= floorUsd)) {
144
+ return {
145
+ claimed: null,
146
+ refused: 'below-threshold'
147
+ };
148
+ }
149
+ const seq = Math.max(0, Math.floor(money(usageSnapshot.get('overageCharges')))) + 1;
150
+ const chargeId = aiOverageChargeId(request.month, seq);
151
+ const claim = {
152
+ chargeId,
153
+ orgId: request.orgId,
154
+ month: request.month,
155
+ seq,
156
+ kind: request.kind,
157
+ amountUsd: unbilledUsd,
158
+ credits: priced.overageCredits,
159
+ rateUsdPer1k: priced.overageRateUsd
160
+ };
161
+ tx.set(usageRef, {
162
+ month: request.month,
163
+ overageInvoicedUsd: FieldValue.increment(unbilledUsd),
164
+ overageCharges: FieldValue.increment(1),
165
+ overageInvoiceOpen: {
166
+ chargeId,
167
+ invoiceId: null,
168
+ amountUsd: unbilledUsd,
169
+ since: now.toISOString()
170
+ },
171
+ updatedAt: FieldValue.serverTimestamp()
172
+ }, {
173
+ merge: true
174
+ });
175
+ tx.set(orgRef.collection(AI_OVERAGE_CHARGES_SUBCOLLECTION).doc(chargeId), {
176
+ month: request.month,
177
+ seq,
178
+ kind: request.kind,
179
+ amountUsd: unbilledUsd,
180
+ credits: priced.overageCredits,
181
+ rateUsdPer1k: priced.overageRateUsd,
182
+ invoiceId: null,
183
+ status: 'claimed',
184
+ createdAt: FieldValue.serverTimestamp(),
185
+ paidAt: null,
186
+ failedAt: null
187
+ }, {
188
+ merge: true
189
+ });
190
+ return {
191
+ claimed: claim,
192
+ refused: null
193
+ };
194
+ });
195
+ }
196
+ /**
197
+ * Records what became of a claimed charge.
198
+ *
199
+ * `paid` adds the amount to the month's `overagePaidUsd`, which is what the
200
+ * gate's unpaid bound subtracts — so paying is what lets a workspace keep
201
+ * going, and nothing else does.
202
+ *
203
+ * An invoice that exists but is not paid KEEPS its claim on
204
+ * `overageInvoicedUsd`: it is a real bill, Stripe's retries may still settle
205
+ * it, and re-billing the same dollars on a second invoice would charge the
206
+ * customer twice for one month's usage. Only a claim that never became an
207
+ * invoice at all releases what it claimed, so those dollars can be charged
208
+ * by a later attempt.
209
+ *
210
+ * The open-charge slot is always cleared. Leaving it set on a failure would
211
+ * block the close-out and every later charge behind an invoice that is
212
+ * never going to move on its own.
213
+ */ export async function settleAiOverageCharge(firestore, orgId, settlement) {
214
+ const orgRef = firestore.collection('orgs').doc(orgId);
215
+ const usageRef = orgRef.collection('assistUsage').doc(settlement.month);
216
+ const chargeRef = orgRef.collection(AI_OVERAGE_CHARGES_SUBCOLLECTION).doc(settlement.chargeId);
217
+ await firestore.runTransaction(async (tx)=>{
218
+ var _ref;
219
+ const [usageSnapshot, chargeSnapshot] = await Promise.all([
220
+ tx.get(usageRef),
221
+ tx.get(chargeRef)
222
+ ]);
223
+ const amountUsd = money(chargeSnapshot.get('amountUsd'));
224
+ // What the month's paid total moves by: what Stripe took. A settlement
225
+ // that claims to be a payment and names no collected figure moves
226
+ // nothing — silence is not evidence of money (AGL-3023).
227
+ const paidUsd = money(settlement.paidUsd);
228
+ const open = usageSnapshot.get('overageInvoiceOpen');
229
+ const ownsTheSlot = String((_ref = open == null ? void 0 : open.chargeId) != null ? _ref : '') === settlement.chargeId;
230
+ // Already settled, or settled by another path (the webhook and the
231
+ // synchronous answer both arrive). Recording the status again is
232
+ // harmless; moving the money counters again is not.
233
+ const alreadyPaid = chargeSnapshot.get('status') === 'paid';
234
+ const releases = settlement.status === 'failed' && !settlement.invoiceId;
235
+ tx.set(chargeRef, _extends({
236
+ invoiceId: settlement.invoiceId,
237
+ status: settlement.status
238
+ }, settlement.status === 'paid' ? {
239
+ paidUsd
240
+ } : {}, settlement.status === 'paid' ? {
241
+ paidAt: FieldValue.serverTimestamp()
242
+ } : {}, settlement.status === 'failed' ? {
243
+ failedAt: FieldValue.serverTimestamp()
244
+ } : {}), {
245
+ merge: true
246
+ });
247
+ tx.set(usageRef, _extends({
248
+ month: settlement.month
249
+ }, settlement.status === 'paid' && !alreadyPaid && paidUsd > 0 ? {
250
+ overagePaidUsd: FieldValue.increment(paidUsd)
251
+ } : {}, releases ? {
252
+ overageInvoicedUsd: FieldValue.increment(-amountUsd),
253
+ overageCharges: FieldValue.increment(-1)
254
+ } : {}, ownsTheSlot ? {
255
+ overageInvoiceOpen: null
256
+ } : {}, {
257
+ updatedAt: FieldValue.serverTimestamp()
258
+ }), {
259
+ merge: true
260
+ });
261
+ });
262
+ }
263
+ /** Reads the four fields off a month's rollup, defensively. */ export function readAiOverageMonthLedger(data) {
264
+ const open = data == null ? void 0 : data['overageInvoiceOpen'];
265
+ const chargeId = typeof (open == null ? void 0 : open['chargeId']) === 'string' ? open['chargeId'] : '';
266
+ return {
267
+ invoicedUsd: money(data == null ? void 0 : data['overageInvoicedUsd']),
268
+ paidUsd: money(data == null ? void 0 : data['overagePaidUsd']),
269
+ charges: Math.max(0, Math.floor(money(data == null ? void 0 : data['overageCharges']))),
270
+ open: chargeId ? {
271
+ chargeId,
272
+ invoiceId: typeof (open == null ? void 0 : open['invoiceId']) === 'string' ? open['invoiceId'] : null,
273
+ amountUsd: money(open == null ? void 0 : open['amountUsd'])
274
+ } : null
275
+ };
276
+ }
277
+
278
+ //# sourceMappingURL=ai-overage-ledger.js.map