@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.
- package/LICENSE +201 -0
- package/README.md +25 -0
- package/package.json +60 -0
- package/src/index.d.ts +21 -0
- package/src/index.js +22 -0
- package/src/index.js.map +1 -0
- package/src/lib/activity/ai-activity-actions.d.ts +106 -0
- package/src/lib/activity/ai-activity-actions.js +209 -0
- package/src/lib/activity/ai-activity-actions.js.map +1 -0
- package/src/lib/activity/ai-activity.d.ts +219 -0
- package/src/lib/activity/ai-activity.js +251 -0
- package/src/lib/activity/ai-activity.js.map +1 -0
- package/src/lib/billing/ai-overage-charge.d.ts +102 -0
- package/src/lib/billing/ai-overage-charge.js +258 -0
- package/src/lib/billing/ai-overage-charge.js.map +1 -0
- package/src/lib/billing/ai-overage-close.d.ts +62 -0
- package/src/lib/billing/ai-overage-close.js +129 -0
- package/src/lib/billing/ai-overage-close.js.map +1 -0
- package/src/lib/billing/ai-overage-cutover.d.ts +63 -0
- package/src/lib/billing/ai-overage-cutover.js +114 -0
- package/src/lib/billing/ai-overage-cutover.js.map +1 -0
- package/src/lib/billing/ai-overage-events.d.ts +77 -0
- package/src/lib/billing/ai-overage-events.js +174 -0
- package/src/lib/billing/ai-overage-events.js.map +1 -0
- package/src/lib/billing/ai-overage-gate.d.ts +147 -0
- package/src/lib/billing/ai-overage-gate.js +177 -0
- package/src/lib/billing/ai-overage-gate.js.map +1 -0
- package/src/lib/billing/ai-overage-ledger.d.ts +135 -0
- package/src/lib/billing/ai-overage-ledger.js +278 -0
- package/src/lib/billing/ai-overage-ledger.js.map +1 -0
- package/src/lib/billing/ai-overage-standing-writes.d.ts +110 -0
- package/src/lib/billing/ai-overage-standing-writes.js +205 -0
- package/src/lib/billing/ai-overage-standing-writes.js.map +1 -0
- package/src/lib/billing/ai-overage-standing.d.ts +168 -0
- package/src/lib/billing/ai-overage-standing.js +215 -0
- package/src/lib/billing/ai-overage-standing.js.map +1 -0
- package/src/lib/billing/ai-overage-trigger.d.ts +30 -0
- package/src/lib/billing/ai-overage-trigger.js +76 -0
- package/src/lib/billing/ai-overage-trigger.js.map +1 -0
- package/src/lib/components/ai-allotment-editor.component.d.ts +40 -0
- package/src/lib/components/ai-allotment-editor.component.js +213 -0
- package/src/lib/components/ai-allotment-editor.component.js.map +1 -0
- package/src/lib/components/ai-assist-actions-context.d.ts +13 -0
- package/src/lib/components/ai-assist-actions-context.js +21 -0
- package/src/lib/components/ai-assist-actions-context.js.map +1 -0
- package/src/lib/components/ai-assist-provider.component.d.ts +51 -0
- package/src/lib/components/ai-assist-provider.component.js +519 -0
- package/src/lib/components/ai-assist-provider.component.js.map +1 -0
- package/src/lib/components/ai-brief-dialog.component.d.ts +56 -0
- package/src/lib/components/ai-brief-dialog.component.js +319 -0
- package/src/lib/components/ai-brief-dialog.component.js.map +1 -0
- package/src/lib/components/ai-collaborator-permissions-column.component.d.ts +32 -0
- package/src/lib/components/ai-collaborator-permissions-column.component.js +132 -0
- package/src/lib/components/ai-collaborator-permissions-column.component.js.map +1 -0
- package/src/lib/components/ai-credits-card.component.d.ts +34 -0
- package/src/lib/components/ai-credits-card.component.js +131 -0
- package/src/lib/components/ai-credits-card.component.js.map +1 -0
- package/src/lib/components/ai-credits-columns.component.d.ts +56 -0
- package/src/lib/components/ai-credits-columns.component.js +118 -0
- package/src/lib/components/ai-credits-columns.component.js.map +1 -0
- package/src/lib/components/ai-crm-email-draft.component.d.ts +17 -0
- package/src/lib/components/ai-crm-email-draft.component.js +159 -0
- package/src/lib/components/ai-crm-email-draft.component.js.map +1 -0
- package/src/lib/components/ai-crm-import-mapping.component.d.ts +20 -0
- package/src/lib/components/ai-crm-import-mapping.component.js +167 -0
- package/src/lib/components/ai-crm-import-mapping.component.js.map +1 -0
- package/src/lib/components/ai-crm-record-card.component.d.ts +27 -0
- package/src/lib/components/ai-crm-record-card.component.js +263 -0
- package/src/lib/components/ai-crm-record-card.component.js.map +1 -0
- package/src/lib/components/ai-describe-automation.component.d.ts +31 -0
- package/src/lib/components/ai-describe-automation.component.js +226 -0
- package/src/lib/components/ai-describe-automation.component.js.map +1 -0
- package/src/lib/components/ai-describe-button.component.d.ts +39 -0
- package/src/lib/components/ai-describe-button.component.js +87 -0
- package/src/lib/components/ai-describe-button.component.js.map +1 -0
- package/src/lib/components/ai-describe-page.component.d.ts +26 -0
- package/src/lib/components/ai-describe-page.component.js +18 -0
- package/src/lib/components/ai-describe-page.component.js.map +1 -0
- package/src/lib/components/ai-experiment-cards.component.d.ts +75 -0
- package/src/lib/components/ai-experiment-cards.component.js +573 -0
- package/src/lib/components/ai-experiment-cards.component.js.map +1 -0
- package/src/lib/components/ai-explain-automation.component.d.ts +31 -0
- package/src/lib/components/ai-explain-automation.component.js +265 -0
- package/src/lib/components/ai-explain-automation.component.js.map +1 -0
- package/src/lib/components/ai-insight-dialog.component.d.ts +37 -0
- package/src/lib/components/ai-insight-dialog.component.js +441 -0
- package/src/lib/components/ai-insight-dialog.component.js.map +1 -0
- package/src/lib/components/ai-job-plan.component.d.ts +46 -0
- package/src/lib/components/ai-job-plan.component.js +192 -0
- package/src/lib/components/ai-job-plan.component.js.map +1 -0
- package/src/lib/components/ai-model-selector.component.d.ts +21 -0
- package/src/lib/components/ai-model-selector.component.js +109 -0
- package/src/lib/components/ai-model-selector.component.js.map +1 -0
- package/src/lib/components/ai-page-brief-dialog.component.d.ts +29 -0
- package/src/lib/components/ai-page-brief-dialog.component.js +27 -0
- package/src/lib/components/ai-page-brief-dialog.component.js.map +1 -0
- package/src/lib/components/ai-permissions-on-host.component.d.ts +55 -0
- package/src/lib/components/ai-permissions-on-host.component.js +91 -0
- package/src/lib/components/ai-permissions-on-host.component.js.map +1 -0
- package/src/lib/components/ai-product-copy-card.component.d.ts +25 -0
- package/src/lib/components/ai-product-copy-card.component.js +328 -0
- package/src/lib/components/ai-product-copy-card.component.js.map +1 -0
- package/src/lib/components/ai-product-import-option.component.d.ts +14 -0
- package/src/lib/components/ai-product-import-option.component.js +58 -0
- package/src/lib/components/ai-product-import-option.component.js.map +1 -0
- package/src/lib/components/ai-products-hub-card.component.d.ts +15 -0
- package/src/lib/components/ai-products-hub-card.component.js +418 -0
- package/src/lib/components/ai-products-hub-card.component.js.map +1 -0
- package/src/lib/components/ai-products-proposals.component.d.ts +19 -0
- package/src/lib/components/ai-products-proposals.component.js +547 -0
- package/src/lib/components/ai-products-proposals.component.js.map +1 -0
- package/src/lib/components/ai-save-as-component.component.d.ts +38 -0
- package/src/lib/components/ai-save-as-component.component.js +231 -0
- package/src/lib/components/ai-save-as-component.component.js.map +1 -0
- package/src/lib/components/ai-seo-audit-card.component.d.ts +9 -0
- package/src/lib/components/ai-seo-audit-card.component.js +620 -0
- package/src/lib/components/ai-seo-audit-card.component.js.map +1 -0
- package/src/lib/components/ai-seo-fields-card.component.d.ts +10 -0
- package/src/lib/components/ai-seo-fields-card.component.js +453 -0
- package/src/lib/components/ai-seo-fields-card.component.js.map +1 -0
- package/src/lib/components/ai-site-batch-card.component.d.ts +32 -0
- package/src/lib/components/ai-site-batch-card.component.js +531 -0
- package/src/lib/components/ai-site-batch-card.component.js.map +1 -0
- package/src/lib/components/ai-site-seo-start-card.component.d.ts +26 -0
- package/src/lib/components/ai-site-seo-start-card.component.js +178 -0
- package/src/lib/components/ai-site-seo-start-card.component.js.map +1 -0
- package/src/lib/components/ai-site-start-card.component.d.ts +19 -0
- package/src/lib/components/ai-site-start-card.component.js +348 -0
- package/src/lib/components/ai-site-start-card.component.js.map +1 -0
- package/src/lib/components/ai-template-collection-field.component.d.ts +32 -0
- package/src/lib/components/ai-template-collection-field.component.js +63 -0
- package/src/lib/components/ai-template-collection-field.component.js.map +1 -0
- package/src/lib/components/ai-theme-proposal-card.component.d.ts +6 -0
- package/src/lib/components/ai-theme-proposal-card.component.js +619 -0
- package/src/lib/components/ai-theme-proposal-card.component.js.map +1 -0
- package/src/lib/components/ai-usage-strip.component.d.ts +27 -0
- package/src/lib/components/ai-usage-strip.component.js +145 -0
- package/src/lib/components/ai-usage-strip.component.js.map +1 -0
- package/src/lib/components/assist-edit-canvas.d.ts +169 -0
- package/src/lib/components/assist-edit-canvas.js +636 -0
- package/src/lib/components/assist-edit-canvas.js.map +1 -0
- package/src/lib/components/assist-edit-card.component.d.ts +16 -0
- package/src/lib/components/assist-edit-card.component.js +181 -0
- package/src/lib/components/assist-edit-card.component.js.map +1 -0
- package/src/lib/components/assist-jobs-drawer.component.d.ts +72 -0
- package/src/lib/components/assist-jobs-drawer.component.js +626 -0
- package/src/lib/components/assist-jobs-drawer.component.js.map +1 -0
- package/src/lib/components/assist-panel.component.d.ts +136 -0
- package/src/lib/components/assist-panel.component.js +1099 -0
- package/src/lib/components/assist-panel.component.js.map +1 -0
- package/src/lib/components/assist-signals-page.component.d.ts +3 -0
- package/src/lib/components/assist-signals-page.component.js +1017 -0
- package/src/lib/components/assist-signals-page.component.js.map +1 -0
- package/src/lib/components/besigner-ai-controls.component.d.ts +29 -0
- package/src/lib/components/besigner-ai-controls.component.js +81 -0
- package/src/lib/components/besigner-ai-controls.component.js.map +1 -0
- package/src/lib/components/billing-ai-allotments.component.d.ts +36 -0
- package/src/lib/components/billing-ai-allotments.component.js +486 -0
- package/src/lib/components/billing-ai-allotments.component.js.map +1 -0
- package/src/lib/components/billing-ai-top-users.component.d.ts +44 -0
- package/src/lib/components/billing-ai-top-users.component.js +304 -0
- package/src/lib/components/billing-ai-top-users.component.js.map +1 -0
- package/src/lib/components/billing-assist-overage-card.component.d.ts +69 -0
- package/src/lib/components/billing-assist-overage-card.component.js +437 -0
- package/src/lib/components/billing-assist-overage-card.component.js.map +1 -0
- package/src/lib/components/host-ai-allotments.component.d.ts +40 -0
- package/src/lib/components/host-ai-allotments.component.js +239 -0
- package/src/lib/components/host-ai-allotments.component.js.map +1 -0
- package/src/lib/components/member-ai-allotment-card.component.d.ts +28 -0
- package/src/lib/components/member-ai-allotment-card.component.js +172 -0
- package/src/lib/components/member-ai-allotment-card.component.js.map +1 -0
- package/src/lib/components/member-ai-usage-card.component.d.ts +28 -0
- package/src/lib/components/member-ai-usage-card.component.js +240 -0
- package/src/lib/components/member-ai-usage-card.component.js.map +1 -0
- package/src/lib/components/staff-org-ai-card.component.d.ts +17 -0
- package/src/lib/components/staff-org-ai-card.component.js +739 -0
- package/src/lib/components/staff-org-ai-card.component.js.map +1 -0
- package/src/lib/components/staff-org-usage-ai-columns.component.d.ts +41 -0
- package/src/lib/components/staff-org-usage-ai-columns.component.js +65 -0
- package/src/lib/components/staff-org-usage-ai-columns.component.js.map +1 -0
- package/src/lib/components/staff-orgs-ai-spend-column.component.d.ts +28 -0
- package/src/lib/components/staff-orgs-ai-spend-column.component.js +89 -0
- package/src/lib/components/staff-orgs-ai-spend-column.component.js.map +1 -0
- package/src/lib/components/staff-user-ai-usage-card.component.d.ts +27 -0
- package/src/lib/components/staff-user-ai-usage-card.component.js +183 -0
- package/src/lib/components/staff-user-ai-usage-card.component.js.map +1 -0
- package/src/lib/components/use-ai-allotments.d.ts +49 -0
- package/src/lib/components/use-ai-allotments.js +171 -0
- package/src/lib/components/use-ai-allotments.js.map +1 -0
- package/src/lib/components/use-ai-crm-answer.d.ts +50 -0
- package/src/lib/components/use-ai-crm-answer.js +220 -0
- package/src/lib/components/use-ai-crm-answer.js.map +1 -0
- package/src/lib/components/use-ai-job-run.d.ts +51 -0
- package/src/lib/components/use-ai-job-run.js +176 -0
- package/src/lib/components/use-ai-job-run.js.map +1 -0
- package/src/lib/components/use-ai-model-choice.d.ts +47 -0
- package/src/lib/components/use-ai-model-choice.js +150 -0
- package/src/lib/components/use-ai-model-choice.js.map +1 -0
- package/src/lib/components/use-ai-products-jobs.d.ts +36 -0
- package/src/lib/components/use-ai-products-jobs.js +190 -0
- package/src/lib/components/use-ai-products-jobs.js.map +1 -0
- package/src/lib/components/use-ai-usage-meter.d.ts +11 -0
- package/src/lib/components/use-ai-usage-meter.js +96 -0
- package/src/lib/components/use-ai-usage-meter.js.map +1 -0
- package/src/lib/components/use-org-ai-usage.d.ts +42 -0
- package/src/lib/components/use-org-ai-usage.js +181 -0
- package/src/lib/components/use-org-ai-usage.js.map +1 -0
- package/src/lib/components/use-staff-orgs-ai-spend.d.ts +18 -0
- package/src/lib/components/use-staff-orgs-ai-spend.js +127 -0
- package/src/lib/components/use-staff-orgs-ai-spend.js.map +1 -0
- package/src/lib/constants.d.ts +24 -0
- package/src/lib/constants.js +23 -0
- package/src/lib/constants.js.map +1 -0
- package/src/lib/declarations.d.ts +48 -0
- package/src/lib/declarations.js +129 -0
- package/src/lib/declarations.js.map +1 -0
- package/src/lib/declarations.server.d.ts +35 -0
- package/src/lib/declarations.server.js +138 -0
- package/src/lib/declarations.server.js.map +1 -0
- package/src/lib/insights/ai-figure-readers.d.ts +90 -0
- package/src/lib/insights/ai-figure-readers.js +863 -0
- package/src/lib/insights/ai-figure-readers.js.map +1 -0
- package/src/lib/insights/ai-insight-digest.d.ts +165 -0
- package/src/lib/insights/ai-insight-digest.js +363 -0
- package/src/lib/insights/ai-insight-digest.js.map +1 -0
- package/src/lib/insights/ai-insight-readers.d.ts +71 -0
- package/src/lib/insights/ai-insight-readers.js +141 -0
- package/src/lib/insights/ai-insight-readers.js.map +1 -0
- package/src/lib/jobs/ai-crm-access.d.ts +61 -0
- package/src/lib/jobs/ai-crm-access.js +94 -0
- package/src/lib/jobs/ai-crm-access.js.map +1 -0
- package/src/lib/jobs/ai-email-bindings.d.ts +97 -0
- package/src/lib/jobs/ai-email-bindings.js +147 -0
- package/src/lib/jobs/ai-email-bindings.js.map +1 -0
- package/src/lib/jobs/ai-job-admission.d.ts +82 -0
- package/src/lib/jobs/ai-job-admission.js +45 -0
- package/src/lib/jobs/ai-job-admission.js.map +1 -0
- package/src/lib/jobs/ai-job-budget.d.ts +167 -0
- package/src/lib/jobs/ai-job-budget.js +161 -0
- package/src/lib/jobs/ai-job-budget.js.map +1 -0
- package/src/lib/jobs/ai-job-campaign-step.d.ts +108 -0
- package/src/lib/jobs/ai-job-campaign-step.js +340 -0
- package/src/lib/jobs/ai-job-campaign-step.js.map +1 -0
- package/src/lib/jobs/ai-job-component-checks.d.ts +74 -0
- package/src/lib/jobs/ai-job-component-checks.js +442 -0
- package/src/lib/jobs/ai-job-component-checks.js.map +1 -0
- package/src/lib/jobs/ai-job-component-step.d.ts +75 -0
- package/src/lib/jobs/ai-job-component-step.js +262 -0
- package/src/lib/jobs/ai-job-component-step.js.map +1 -0
- package/src/lib/jobs/ai-job-crm-step.d.ts +192 -0
- package/src/lib/jobs/ai-job-crm-step.js +734 -0
- package/src/lib/jobs/ai-job-crm-step.js.map +1 -0
- package/src/lib/jobs/ai-job-draft-ids.d.ts +62 -0
- package/src/lib/jobs/ai-job-draft-ids.js +132 -0
- package/src/lib/jobs/ai-job-draft-ids.js.map +1 -0
- package/src/lib/jobs/ai-job-drafts.d.ts +304 -0
- package/src/lib/jobs/ai-job-drafts.js +557 -0
- package/src/lib/jobs/ai-job-drafts.js.map +1 -0
- package/src/lib/jobs/ai-job-email-step.d.ts +195 -0
- package/src/lib/jobs/ai-job-email-step.js +547 -0
- package/src/lib/jobs/ai-job-email-step.js.map +1 -0
- package/src/lib/jobs/ai-job-experiment-step.d.ts +105 -0
- package/src/lib/jobs/ai-job-experiment-step.js +445 -0
- package/src/lib/jobs/ai-job-experiment-step.js.map +1 -0
- package/src/lib/jobs/ai-job-form-step.d.ts +250 -0
- package/src/lib/jobs/ai-job-form-step.js +634 -0
- package/src/lib/jobs/ai-job-form-step.js.map +1 -0
- package/src/lib/jobs/ai-job-generation.d.ts +114 -0
- package/src/lib/jobs/ai-job-generation.js +384 -0
- package/src/lib/jobs/ai-job-generation.js.map +1 -0
- package/src/lib/jobs/ai-job-insight-budget.d.ts +41 -0
- package/src/lib/jobs/ai-job-insight-budget.js +46 -0
- package/src/lib/jobs/ai-job-insight-budget.js.map +1 -0
- package/src/lib/jobs/ai-job-insight-step.d.ts +58 -0
- package/src/lib/jobs/ai-job-insight-step.js +350 -0
- package/src/lib/jobs/ai-job-insight-step.js.map +1 -0
- package/src/lib/jobs/ai-job-layout-step.d.ts +103 -0
- package/src/lib/jobs/ai-job-layout-step.js +340 -0
- package/src/lib/jobs/ai-job-layout-step.js.map +1 -0
- package/src/lib/jobs/ai-job-page-budget.d.ts +57 -0
- package/src/lib/jobs/ai-job-page-budget.js +60 -0
- package/src/lib/jobs/ai-job-page-budget.js.map +1 -0
- package/src/lib/jobs/ai-job-page-sections.d.ts +150 -0
- package/src/lib/jobs/ai-job-page-sections.js +450 -0
- package/src/lib/jobs/ai-job-page-sections.js.map +1 -0
- package/src/lib/jobs/ai-job-page-step.d.ts +198 -0
- package/src/lib/jobs/ai-job-page-step.js +667 -0
- package/src/lib/jobs/ai-job-page-step.js.map +1 -0
- package/src/lib/jobs/ai-job-plan-conformance.d.ts +107 -0
- package/src/lib/jobs/ai-job-plan-conformance.js +164 -0
- package/src/lib/jobs/ai-job-plan-conformance.js.map +1 -0
- package/src/lib/jobs/ai-job-plan-step.d.ts +196 -0
- package/src/lib/jobs/ai-job-plan-step.js +458 -0
- package/src/lib/jobs/ai-job-plan-step.js.map +1 -0
- package/src/lib/jobs/ai-job-plugin-drafts.d.ts +76 -0
- package/src/lib/jobs/ai-job-plugin-drafts.js +91 -0
- package/src/lib/jobs/ai-job-plugin-drafts.js.map +1 -0
- package/src/lib/jobs/ai-job-products-step.d.ts +106 -0
- package/src/lib/jobs/ai-job-products-step.js +436 -0
- package/src/lib/jobs/ai-job-products-step.js.map +1 -0
- package/src/lib/jobs/ai-job-seo-budget.d.ts +52 -0
- package/src/lib/jobs/ai-job-seo-budget.js +63 -0
- package/src/lib/jobs/ai-job-seo-budget.js.map +1 -0
- package/src/lib/jobs/ai-job-seo-step.d.ts +145 -0
- package/src/lib/jobs/ai-job-seo-step.js +809 -0
- package/src/lib/jobs/ai-job-seo-step.js.map +1 -0
- package/src/lib/jobs/ai-job-site-step.d.ts +252 -0
- package/src/lib/jobs/ai-job-site-step.js +538 -0
- package/src/lib/jobs/ai-job-site-step.js.map +1 -0
- package/src/lib/jobs/ai-job-template-step.d.ts +105 -0
- package/src/lib/jobs/ai-job-template-step.js +391 -0
- package/src/lib/jobs/ai-job-template-step.js.map +1 -0
- package/src/lib/jobs/ai-job-text-step.d.ts +125 -0
- package/src/lib/jobs/ai-job-text-step.js +128 -0
- package/src/lib/jobs/ai-job-text-step.js.map +1 -0
- package/src/lib/jobs/ai-job-theme-budget.d.ts +38 -0
- package/src/lib/jobs/ai-job-theme-budget.js +43 -0
- package/src/lib/jobs/ai-job-theme-budget.js.map +1 -0
- package/src/lib/jobs/ai-job-theme-step.d.ts +115 -0
- package/src/lib/jobs/ai-job-theme-step.js +337 -0
- package/src/lib/jobs/ai-job-theme-step.js.map +1 -0
- package/src/lib/jobs/ai-job-workflow-step.d.ts +139 -0
- package/src/lib/jobs/ai-job-workflow-step.js +530 -0
- package/src/lib/jobs/ai-job-workflow-step.js.map +1 -0
- package/src/lib/jobs/ai-jobs-beat.d.ts +78 -0
- package/src/lib/jobs/ai-jobs-beat.js +93 -0
- package/src/lib/jobs/ai-jobs-beat.js.map +1 -0
- package/src/lib/jobs/ai-jobs-pause.d.ts +38 -0
- package/src/lib/jobs/ai-jobs-pause.js +45 -0
- package/src/lib/jobs/ai-jobs-pause.js.map +1 -0
- package/src/lib/jobs/ai-jobs.d.ts +558 -0
- package/src/lib/jobs/ai-jobs.js +1410 -0
- package/src/lib/jobs/ai-jobs.js.map +1 -0
- package/src/lib/jobs/ai-media-asset-server.d.ts +34 -0
- package/src/lib/jobs/ai-media-asset-server.js +34 -0
- package/src/lib/jobs/ai-media-asset-server.js.map +1 -0
- package/src/lib/jobs/ai-media-asset.d.ts +59 -0
- package/src/lib/jobs/ai-media-asset.js +86 -0
- package/src/lib/jobs/ai-media-asset.js.map +1 -0
- package/src/lib/jobs/ai-product-image.d.ts +78 -0
- package/src/lib/jobs/ai-product-image.js +113 -0
- package/src/lib/jobs/ai-product-image.js.map +1 -0
- package/src/lib/jobs/ai-theme-brand-inputs.d.ts +125 -0
- package/src/lib/jobs/ai-theme-brand-inputs.js +378 -0
- package/src/lib/jobs/ai-theme-brand-inputs.js.map +1 -0
- package/src/lib/jobs/ai-theme-brand-server.d.ts +33 -0
- package/src/lib/jobs/ai-theme-brand-server.js +33 -0
- package/src/lib/jobs/ai-theme-brand-server.js.map +1 -0
- package/src/lib/jobs/ai-workflow-records.d.ts +84 -0
- package/src/lib/jobs/ai-workflow-records.js +158 -0
- package/src/lib/jobs/ai-workflow-records.js.map +1 -0
- package/src/lib/jobs/fixtures/ai-free-page-built-recording.d.ts +31 -0
- package/src/lib/jobs/fixtures/ai-free-page-built-recording.js +367 -0
- package/src/lib/jobs/fixtures/ai-free-page-built-recording.js.map +1 -0
- package/src/lib/jobs/fixtures/ai-free-page-recording.d.ts +69 -0
- package/src/lib/jobs/fixtures/ai-free-page-recording.js +442 -0
- package/src/lib/jobs/fixtures/ai-free-page-recording.js.map +1 -0
- package/src/lib/jobs/fixtures/ai-page-briefs.d.ts +146 -0
- package/src/lib/jobs/fixtures/ai-page-briefs.js +1850 -0
- package/src/lib/jobs/fixtures/ai-page-briefs.js.map +1 -0
- package/src/lib/model/ai-allotments.d.ts +208 -0
- package/src/lib/model/ai-allotments.js +269 -0
- package/src/lib/model/ai-allotments.js.map +1 -0
- package/src/lib/model/ai-automation-draft.d.ts +74 -0
- package/src/lib/model/ai-automation-draft.js +310 -0
- package/src/lib/model/ai-automation-draft.js.map +1 -0
- package/src/lib/model/ai-automation-outline.d.ts +50 -0
- package/src/lib/model/ai-automation-outline.js +262 -0
- package/src/lib/model/ai-automation-outline.js.map +1 -0
- package/src/lib/model/ai-build-plan.d.ts +197 -0
- package/src/lib/model/ai-build-plan.js +438 -0
- package/src/lib/model/ai-build-plan.js.map +1 -0
- package/src/lib/model/ai-crm.d.ts +237 -0
- package/src/lib/model/ai-crm.js +225 -0
- package/src/lib/model/ai-crm.js.map +1 -0
- package/src/lib/model/ai-experiment-proposal.d.ts +68 -0
- package/src/lib/model/ai-experiment-proposal.js +146 -0
- package/src/lib/model/ai-experiment-proposal.js.map +1 -0
- package/src/lib/model/ai-experiment.d.ts +309 -0
- package/src/lib/model/ai-experiment.js +395 -0
- package/src/lib/model/ai-experiment.js.map +1 -0
- package/src/lib/model/ai-insight.d.ts +178 -0
- package/src/lib/model/ai-insight.js +201 -0
- package/src/lib/model/ai-insight.js.map +1 -0
- package/src/lib/model/ai-jobs.types.d.ts +412 -0
- package/src/lib/model/ai-jobs.types.js +42 -0
- package/src/lib/model/ai-jobs.types.js.map +1 -0
- package/src/lib/model/ai-page-job.d.ts +92 -0
- package/src/lib/model/ai-page-job.js +159 -0
- package/src/lib/model/ai-page-job.js.map +1 -0
- package/src/lib/model/ai-permissions.d.ts +49 -0
- package/src/lib/model/ai-permissions.js +97 -0
- package/src/lib/model/ai-permissions.js.map +1 -0
- package/src/lib/model/ai-plan-capabilities.d.ts +139 -0
- package/src/lib/model/ai-plan-capabilities.js +149 -0
- package/src/lib/model/ai-plan-capabilities.js.map +1 -0
- package/src/lib/model/ai-products.d.ts +251 -0
- package/src/lib/model/ai-products.js +253 -0
- package/src/lib/model/ai-products.js.map +1 -0
- package/src/lib/model/ai-seo.d.ts +208 -0
- package/src/lib/model/ai-seo.js +150 -0
- package/src/lib/model/ai-seo.js.map +1 -0
- package/src/lib/model/ai-site-inventory.d.ts +164 -0
- package/src/lib/model/ai-site-inventory.js +145 -0
- package/src/lib/model/ai-site-inventory.js.map +1 -0
- package/src/lib/model/ai-site-job.d.ts +247 -0
- package/src/lib/model/ai-site-job.js +314 -0
- package/src/lib/model/ai-site-job.js.map +1 -0
- package/src/lib/model/ai-site-start-seo.d.ts +103 -0
- package/src/lib/model/ai-site-start-seo.js +154 -0
- package/src/lib/model/ai-site-start-seo.js.map +1 -0
- package/src/lib/model/ai-site-start.d.ts +122 -0
- package/src/lib/model/ai-site-start.js +159 -0
- package/src/lib/model/ai-site-start.js.map +1 -0
- package/src/lib/model/ai-site-switch.d.ts +56 -0
- package/src/lib/model/ai-site-switch.js +73 -0
- package/src/lib/model/ai-site-switch.js.map +1 -0
- package/src/lib/model/ai-storefront-claims.d.ts +70 -0
- package/src/lib/model/ai-storefront-claims.js +130 -0
- package/src/lib/model/ai-storefront-claims.js.map +1 -0
- package/src/lib/model/ai-template-subjects.d.ts +82 -0
- package/src/lib/model/ai-template-subjects.js +136 -0
- package/src/lib/model/ai-template-subjects.js.map +1 -0
- package/src/lib/model/ai-theme-proposal.d.ts +210 -0
- package/src/lib/model/ai-theme-proposal.js +506 -0
- package/src/lib/model/ai-theme-proposal.js.map +1 -0
- package/src/lib/model/ai-tokens.d.ts +96 -0
- package/src/lib/model/ai-tokens.js +117 -0
- package/src/lib/model/ai-tokens.js.map +1 -0
- package/src/lib/model/ai-usage-by-user.d.ts +120 -0
- package/src/lib/model/ai-usage-by-user.js +139 -0
- package/src/lib/model/ai-usage-by-user.js.map +1 -0
- package/src/lib/model/ai-workflow-job.d.ts +111 -0
- package/src/lib/model/ai-workflow-job.js +183 -0
- package/src/lib/model/ai-workflow-job.js.map +1 -0
- package/src/lib/model/assist-edit.d.ts +261 -0
- package/src/lib/model/assist-edit.js +175 -0
- package/src/lib/model/assist-edit.js.map +1 -0
- package/src/lib/plugin-config.d.ts +33 -0
- package/src/lib/plugin-config.js +118 -0
- package/src/lib/plugin-config.js.map +1 -0
- package/src/lib/plugin.d.ts +30 -0
- package/src/lib/plugin.js +525 -0
- package/src/lib/plugin.js.map +1 -0
- package/src/lib/providers/anthropic.d.ts +84 -0
- package/src/lib/providers/anthropic.js +432 -0
- package/src/lib/providers/anthropic.js.map +1 -0
- package/src/lib/providers/catalog.d.ts +197 -0
- package/src/lib/providers/catalog.js +312 -0
- package/src/lib/providers/catalog.js.map +1 -0
- package/src/lib/providers/contract.d.ts +464 -0
- package/src/lib/providers/contract.js +274 -0
- package/src/lib/providers/contract.js.map +1 -0
- package/src/lib/providers/model-choice.d.ts +119 -0
- package/src/lib/providers/model-choice.js +416 -0
- package/src/lib/providers/model-choice.js.map +1 -0
- package/src/lib/providers/openai-compatible.d.ts +58 -0
- package/src/lib/providers/openai-compatible.js +361 -0
- package/src/lib/providers/openai-compatible.js.map +1 -0
- package/src/lib/providers/registry.d.ts +49 -0
- package/src/lib/providers/registry.js +71 -0
- package/src/lib/providers/registry.js.map +1 -0
- package/src/lib/providers/routing.d.ts +98 -0
- package/src/lib/providers/routing.js +450 -0
- package/src/lib/providers/routing.js.map +1 -0
- package/src/lib/runtime/ai-abuse-guards.d.ts +113 -0
- package/src/lib/runtime/ai-abuse-guards.js +148 -0
- package/src/lib/runtime/ai-abuse-guards.js.map +1 -0
- package/src/lib/runtime/ai-component-bindings.d.ts +67 -0
- package/src/lib/runtime/ai-component-bindings.js +106 -0
- package/src/lib/runtime/ai-component-bindings.js.map +1 -0
- package/src/lib/runtime/ai-device-audit.d.ts +109 -0
- package/src/lib/runtime/ai-device-audit.js +97 -0
- package/src/lib/runtime/ai-device-audit.js.map +1 -0
- package/src/lib/runtime/ai-doctrine-validators.d.ts +720 -0
- package/src/lib/runtime/ai-doctrine-validators.js +3133 -0
- package/src/lib/runtime/ai-doctrine-validators.js.map +1 -0
- package/src/lib/runtime/ai-doctrine.d.ts +372 -0
- package/src/lib/runtime/ai-doctrine.js +944 -0
- package/src/lib/runtime/ai-doctrine.js.map +1 -0
- package/src/lib/runtime/ai-eval-live.d.ts +321 -0
- package/src/lib/runtime/ai-eval-live.js +1257 -0
- package/src/lib/runtime/ai-eval-live.js.map +1 -0
- package/src/lib/runtime/ai-eval-memory-firestore.d.ts +51 -0
- package/src/lib/runtime/ai-eval-memory-firestore.js +183 -0
- package/src/lib/runtime/ai-eval-memory-firestore.js.map +1 -0
- package/src/lib/runtime/ai-eval.d.ts +441 -0
- package/src/lib/runtime/ai-eval.js +1151 -0
- package/src/lib/runtime/ai-eval.js.map +1 -0
- package/src/lib/runtime/ai-gate.d.ts +130 -0
- package/src/lib/runtime/ai-gate.js +272 -0
- package/src/lib/runtime/ai-gate.js.map +1 -0
- package/src/lib/runtime/ai-generation-bounds.d.ts +24 -0
- package/src/lib/runtime/ai-generation-bounds.js +23 -0
- package/src/lib/runtime/ai-generation-bounds.js.map +1 -0
- package/src/lib/runtime/ai-insight-check.d.ts +76 -0
- package/src/lib/runtime/ai-insight-check.js +281 -0
- package/src/lib/runtime/ai-insight-check.js.map +1 -0
- package/src/lib/runtime/ai-node-tree.d.ts +181 -0
- package/src/lib/runtime/ai-node-tree.js +931 -0
- package/src/lib/runtime/ai-node-tree.js.map +1 -0
- package/src/lib/runtime/ai-page-links.d.ts +79 -0
- package/src/lib/runtime/ai-page-links.js +135 -0
- package/src/lib/runtime/ai-page-links.js.map +1 -0
- package/src/lib/runtime/ai-palette.d.ts +252 -0
- package/src/lib/runtime/ai-palette.generated.d.ts +34 -0
- package/src/lib/runtime/ai-palette.generated.js +5263 -0
- package/src/lib/runtime/ai-palette.generated.js.map +1 -0
- package/src/lib/runtime/ai-palette.js +187 -0
- package/src/lib/runtime/ai-palette.js.map +1 -0
- package/src/lib/runtime/ai-products-generation.d.ts +107 -0
- package/src/lib/runtime/ai-products-generation.js +250 -0
- package/src/lib/runtime/ai-products-generation.js.map +1 -0
- package/src/lib/runtime/ai-repeated-items.d.ts +95 -0
- package/src/lib/runtime/ai-repeated-items.js +397 -0
- package/src/lib/runtime/ai-repeated-items.js.map +1 -0
- package/src/lib/runtime/ai-runtime.d.ts +148 -0
- package/src/lib/runtime/ai-runtime.js +237 -0
- package/src/lib/runtime/ai-runtime.js.map +1 -0
- package/src/lib/runtime/ai-template-examples.d.ts +71 -0
- package/src/lib/runtime/ai-template-examples.js +135 -0
- package/src/lib/runtime/ai-template-examples.js.map +1 -0
- package/src/lib/runtime/assist-answer-cache.d.ts +80 -0
- package/src/lib/runtime/assist-answer-cache.js +184 -0
- package/src/lib/runtime/assist-answer-cache.js.map +1 -0
- package/src/lib/runtime/seo-audit.d.ts +93 -0
- package/src/lib/runtime/seo-audit.js +260 -0
- package/src/lib/runtime/seo-audit.js.map +1 -0
- package/src/lib/runtime/seo-content-fixes.d.ts +41 -0
- package/src/lib/runtime/seo-content-fixes.js +168 -0
- package/src/lib/runtime/seo-content-fixes.js.map +1 -0
- package/src/lib/runtime/seo-fields.d.ts +152 -0
- package/src/lib/runtime/seo-fields.js +215 -0
- package/src/lib/runtime/seo-fields.js.map +1 -0
- package/src/lib/runtime/seo-page-facts.d.ts +61 -0
- package/src/lib/runtime/seo-page-facts.js +150 -0
- package/src/lib/runtime/seo-page-facts.js.map +1 -0
- package/src/lib/runtime/site-inventory.d.ts +63 -0
- package/src/lib/runtime/site-inventory.js +230 -0
- package/src/lib/runtime/site-inventory.js.map +1 -0
- package/src/lib/server/ai-admin-org.d.ts +33 -0
- package/src/lib/server/ai-admin-org.js +381 -0
- package/src/lib/server/ai-admin-org.js.map +1 -0
- package/src/lib/server/ai-admin-orgs-spend.d.ts +40 -0
- package/src/lib/server/ai-admin-orgs-spend.js +129 -0
- package/src/lib/server/ai-admin-orgs-spend.js.map +1 -0
- package/src/lib/server/ai-admin-overage.d.ts +19 -0
- package/src/lib/server/ai-admin-overage.js +246 -0
- package/src/lib/server/ai-admin-overage.js.map +1 -0
- package/src/lib/server/ai-admin-signals.d.ts +34 -0
- package/src/lib/server/ai-admin-signals.js +330 -0
- package/src/lib/server/ai-admin-signals.js.map +1 -0
- package/src/lib/server/ai-admin-user.d.ts +27 -0
- package/src/lib/server/ai-admin-user.js +128 -0
- package/src/lib/server/ai-admin-user.js.map +1 -0
- package/src/lib/server/ai-allotments.d.ts +27 -0
- package/src/lib/server/ai-allotments.js +544 -0
- package/src/lib/server/ai-allotments.js.map +1 -0
- package/src/lib/server/ai-assist-prompts.d.ts +102 -0
- package/src/lib/server/ai-assist-prompts.js +207 -0
- package/src/lib/server/ai-assist-prompts.js.map +1 -0
- package/src/lib/server/ai-assist.d.ts +119 -0
- package/src/lib/server/ai-assist.js +517 -0
- package/src/lib/server/ai-assist.js.map +1 -0
- package/src/lib/server/ai-crm-answer.d.ts +30 -0
- package/src/lib/server/ai-crm-answer.js +98 -0
- package/src/lib/server/ai-crm-answer.js.map +1 -0
- package/src/lib/server/ai-generate-component.d.ts +111 -0
- package/src/lib/server/ai-generate-component.js +643 -0
- package/src/lib/server/ai-generate-component.js.map +1 -0
- package/src/lib/server/ai-host-permissions.d.ts +46 -0
- package/src/lib/server/ai-host-permissions.js +204 -0
- package/src/lib/server/ai-host-permissions.js.map +1 -0
- package/src/lib/server/ai-insight-answer.d.ts +30 -0
- package/src/lib/server/ai-insight-answer.js +83 -0
- package/src/lib/server/ai-insight-answer.js.map +1 -0
- package/src/lib/server/ai-insight-digest-route.d.ts +30 -0
- package/src/lib/server/ai-insight-digest-route.js +156 -0
- package/src/lib/server/ai-insight-digest-route.js.map +1 -0
- package/src/lib/server/ai-jobs-batch.d.ts +48 -0
- package/src/lib/server/ai-jobs-batch.js +306 -0
- package/src/lib/server/ai-jobs-batch.js.map +1 -0
- package/src/lib/server/ai-jobs-beat-route.d.ts +36 -0
- package/src/lib/server/ai-jobs-beat-route.js +86 -0
- package/src/lib/server/ai-jobs-beat-route.js.map +1 -0
- package/src/lib/server/ai-jobs-cancel.d.ts +30 -0
- package/src/lib/server/ai-jobs-cancel.js +74 -0
- package/src/lib/server/ai-jobs-cancel.js.map +1 -0
- package/src/lib/server/ai-jobs-events-route.d.ts +31 -0
- package/src/lib/server/ai-jobs-events-route.js +51 -0
- package/src/lib/server/ai-jobs-events-route.js.map +1 -0
- package/src/lib/server/ai-jobs-events.d.ts +55 -0
- package/src/lib/server/ai-jobs-events.js +144 -0
- package/src/lib/server/ai-jobs-events.js.map +1 -0
- package/src/lib/server/ai-jobs-gate.d.ts +47 -0
- package/src/lib/server/ai-jobs-gate.js +106 -0
- package/src/lib/server/ai-jobs-gate.js.map +1 -0
- package/src/lib/server/ai-jobs-resume.d.ts +23 -0
- package/src/lib/server/ai-jobs-resume.js +209 -0
- package/src/lib/server/ai-jobs-resume.js.map +1 -0
- package/src/lib/server/ai-jobs-route.d.ts +32 -0
- package/src/lib/server/ai-jobs-route.js +307 -0
- package/src/lib/server/ai-jobs-route.js.map +1 -0
- package/src/lib/server/ai-models.d.ts +18 -0
- package/src/lib/server/ai-models.js +134 -0
- package/src/lib/server/ai-models.js.map +1 -0
- package/src/lib/server/ai-seo-apply.d.ts +53 -0
- package/src/lib/server/ai-seo-apply.js +294 -0
- package/src/lib/server/ai-seo-apply.js.map +1 -0
- package/src/lib/server/ai-usage.d.ts +18 -0
- package/src/lib/server/ai-usage.js +220 -0
- package/src/lib/server/ai-usage.js.map +1 -0
- package/src/lib/server/assist-chat.d.ts +234 -0
- package/src/lib/server/assist-chat.js +1446 -0
- package/src/lib/server/assist-chat.js.map +1 -0
- package/src/lib/server/assist-edit-applied.d.ts +22 -0
- package/src/lib/server/assist-edit-applied.js +239 -0
- package/src/lib/server/assist-edit-applied.js.map +1 -0
- package/src/lib/server/assist-edit.d.ts +124 -0
- package/src/lib/server/assist-edit.js +1000 -0
- package/src/lib/server/assist-edit.js.map +1 -0
- package/src/lib/server/assist-feedback.d.ts +31 -0
- package/src/lib/server/assist-feedback.js +115 -0
- package/src/lib/server/assist-feedback.js.map +1 -0
- package/src/lib/server/assist-view-context.d.ts +343 -0
- package/src/lib/server/assist-view-context.js +690 -0
- package/src/lib/server/assist-view-context.js.map +1 -0
- package/src/lib/server/billing-credits.d.ts +59 -0
- package/src/lib/server/billing-credits.js +146 -0
- package/src/lib/server/billing-credits.js.map +1 -0
- package/src/lib/server/billing-overage.d.ts +19 -0
- package/src/lib/server/billing-overage.js +337 -0
- package/src/lib/server/billing-overage.js.map +1 -0
- package/src/lib/server.d.ts +32 -0
- package/src/lib/server.js +265 -0
- package/src/lib/server.js.map +1 -0
- package/src/lib/subprocessors.d.ts +18 -0
- package/src/lib/subprocessors.js +52 -0
- package/src/lib/subprocessors.js.map +1 -0
- package/src/lib/tools/ai-component-tool.d.ts +99 -0
- package/src/lib/tools/ai-component-tool.js +369 -0
- package/src/lib/tools/ai-component-tool.js.map +1 -0
- package/src/lib/tools/ai-crm-tool.d.ts +106 -0
- package/src/lib/tools/ai-crm-tool.js +488 -0
- package/src/lib/tools/ai-crm-tool.js.map +1 -0
- package/src/lib/tools/ai-duplicate-resource-tool.d.ts +71 -0
- package/src/lib/tools/ai-duplicate-resource-tool.js +164 -0
- package/src/lib/tools/ai-duplicate-resource-tool.js.map +1 -0
- package/src/lib/tools/ai-experiment-tool.d.ts +40 -0
- package/src/lib/tools/ai-experiment-tool.js +155 -0
- package/src/lib/tools/ai-experiment-tool.js.map +1 -0
- package/src/lib/tools/ai-insight-tool.d.ts +46 -0
- package/src/lib/tools/ai-insight-tool.js +200 -0
- package/src/lib/tools/ai-insight-tool.js.map +1 -0
- package/src/lib/tools/ai-inventory-lookup-tool.d.ts +86 -0
- package/src/lib/tools/ai-inventory-lookup-tool.js +164 -0
- package/src/lib/tools/ai-inventory-lookup-tool.js.map +1 -0
- package/src/lib/tools/ai-products-tool.d.ts +65 -0
- package/src/lib/tools/ai-products-tool.js +644 -0
- package/src/lib/tools/ai-products-tool.js.map +1 -0
- package/src/lib/tools/ai-seo-tool.d.ts +162 -0
- package/src/lib/tools/ai-seo-tool.js +546 -0
- package/src/lib/tools/ai-seo-tool.js.map +1 -0
- package/src/lib/tools/ai-theme-tool.d.ts +101 -0
- package/src/lib/tools/ai-theme-tool.js +562 -0
- package/src/lib/tools/ai-theme-tool.js.map +1 -0
- package/src/lib/tools/ai-workflow-tool.d.ts +166 -0
- package/src/lib/tools/ai-workflow-tool.js +860 -0
- package/src/lib/tools/ai-workflow-tool.js.map +1 -0
- package/src/lib/usage/ai-allotment-alerts.d.ts +72 -0
- package/src/lib/usage/ai-allotment-alerts.js +157 -0
- package/src/lib/usage/ai-allotment-alerts.js.map +1 -0
- package/src/lib/usage/ai-allotments.d.ts +125 -0
- package/src/lib/usage/ai-allotments.js +239 -0
- package/src/lib/usage/ai-allotments.js.map +1 -0
- package/src/lib/usage/ai-model-sample.d.ts +36 -0
- package/src/lib/usage/ai-model-sample.js +68 -0
- package/src/lib/usage/ai-model-sample.js.map +1 -0
- package/src/lib/usage/ai-usage-alerts.d.ts +55 -0
- package/src/lib/usage/ai-usage-alerts.js +114 -0
- package/src/lib/usage/ai-usage-alerts.js.map +1 -0
- package/src/lib/usage/ai-usage-by-user.d.ts +161 -0
- package/src/lib/usage/ai-usage-by-user.js +211 -0
- package/src/lib/usage/ai-usage-by-user.js.map +1 -0
- package/src/lib/usage/ai-usage-eraser.d.ts +29 -0
- package/src/lib/usage/ai-usage-eraser.js +40 -0
- package/src/lib/usage/ai-usage-eraser.js.map +1 -0
- package/src/lib/usage/ai-usage-meter.d.ts +39 -0
- package/src/lib/usage/ai-usage-meter.js +85 -0
- package/src/lib/usage/ai-usage-meter.js.map +1 -0
- package/src/lib/usage/ai-usage-wire.d.ts +184 -0
- package/src/lib/usage/ai-usage-wire.js +98 -0
- package/src/lib/usage/ai-usage-wire.js.map +1 -0
- package/src/lib/usage/assist-ceiling.d.ts +87 -0
- package/src/lib/usage/assist-ceiling.js +110 -0
- package/src/lib/usage/assist-ceiling.js.map +1 -0
- package/src/lib/usage/assist-free-taste.d.ts +225 -0
- package/src/lib/usage/assist-free-taste.js +308 -0
- package/src/lib/usage/assist-free-taste.js.map +1 -0
- package/src/lib/usage/assist-refusals.d.ts +69 -0
- package/src/lib/usage/assist-refusals.js +79 -0
- package/src/lib/usage/assist-refusals.js.map +1 -0
- package/src/lib/usage/assist-signal-mining.d.ts +375 -0
- package/src/lib/usage/assist-signal-mining.js +344 -0
- package/src/lib/usage/assist-signal-mining.js.map +1 -0
- package/src/lib/usage/assist-usage.d.ts +571 -0
- package/src/lib/usage/assist-usage.js +978 -0
- package/src/lib/usage/assist-usage.js.map +1 -0
- package/src/lib/usage/staff-org-ai.d.ts +242 -0
- package/src/lib/usage/staff-org-ai.js +173 -0
- package/src/lib/usage/staff-org-ai.js.map +1 -0
- package/src/lib/usage/staff-org-usage-ai.d.ts +83 -0
- package/src/lib/usage/staff-org-usage-ai.js +59 -0
- package/src/lib/usage/staff-org-usage-ai.js.map +1 -0
- package/src/lib/usage/staff-orgs-ai-spend.d.ts +83 -0
- package/src/lib/usage/staff-orgs-ai-spend.js +114 -0
- package/src/lib/usage/staff-orgs-ai-spend.js.map +1 -0
|
@@ -0,0 +1,91 @@
|
|
|
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 { isHostPluginEnabled } from "@aglyn/aglyn/plugin-manager/enabled-plugins";
|
|
17
|
+
import { pluginResourceDraftWriter } from "@aglyn/aglyn/plugin-manager/plugin-resource-drafts";
|
|
18
|
+
import { filterEnabledPluginsByReleaseFlags } from "@aglyn/tenant-data-admin/server/release-flags";
|
|
19
|
+
import { resolveOrgIdForHost } from "@aglyn/tenant-data-admin/server/organizations";
|
|
20
|
+
/** The registered writer for a resource, or `null` when no plugin writes it here. */ export const aiPluginDraftWriter = (resource)=>{
|
|
21
|
+
var _ref;
|
|
22
|
+
var _pluginResourceDraftWriter;
|
|
23
|
+
return (_ref = (_pluginResourceDraftWriter = pluginResourceDraftWriter(resource)) == null ? void 0 : _pluginResourceDraftWriter.writer) != null ? _ref : null;
|
|
24
|
+
};
|
|
25
|
+
/** What a person is told when the plugin that owns a draft does not run here. */ export function aiPluginDraftUnavailable(label) {
|
|
26
|
+
return `Turn on ${label} for this site before starting the job.`;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Whether a job of this kind may start on this site for this member; `null`
|
|
30
|
+
* admits it. Nothing here writes, and nothing here spends.
|
|
31
|
+
*/ export async function aiPluginDraftAdmissionRefusal(context, input) {
|
|
32
|
+
var _input_writerFor, _data, _input_now;
|
|
33
|
+
const { hostId } = context;
|
|
34
|
+
if (!hostId) {
|
|
35
|
+
return {
|
|
36
|
+
status: 400,
|
|
37
|
+
error: `Open the site the ${input.kind} is for before starting the job`
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const owner = await resolveOrgIdForHost(hostId);
|
|
41
|
+
if (!owner || owner !== context.orgId) return {
|
|
42
|
+
status: 404,
|
|
43
|
+
error: 'Unknown site'
|
|
44
|
+
};
|
|
45
|
+
const writerFor = (_input_writerFor = input.writerFor) != null ? _input_writerFor : aiPluginDraftWriter;
|
|
46
|
+
const host = (_data = (await context.firestore.collection('hosts').doc(hostId).get()).data()) != null ? _data : null;
|
|
47
|
+
const org = context.org;
|
|
48
|
+
// One release-flag read for every owner at once: the answer is per org, and
|
|
49
|
+
// a plugin subtracted here is one the site cannot reach at all.
|
|
50
|
+
const released = new Set(await filterEnabledPluginsByReleaseFlags(input.drafts.map((draft)=>draft.pluginId), {
|
|
51
|
+
orgId: context.orgId,
|
|
52
|
+
authorization: null
|
|
53
|
+
}));
|
|
54
|
+
const writers = [];
|
|
55
|
+
for (const draft of input.drafts){
|
|
56
|
+
const writer = writerFor(draft.resource);
|
|
57
|
+
if (!writer || !released.has(draft.pluginId) || !isHostPluginEnabled(org, host, draft.pluginId)) {
|
|
58
|
+
return {
|
|
59
|
+
status: 403,
|
|
60
|
+
error: aiPluginDraftUnavailable(draft.label)
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
writers.push(writer);
|
|
64
|
+
}
|
|
65
|
+
const own = await (input.ownCheck == null ? void 0 : input.ownCheck.call(input, hostId));
|
|
66
|
+
if (own) return own;
|
|
67
|
+
// Whether this member may create one of each, in the owner's own words. A
|
|
68
|
+
// door that names no member — the machine re-checking a job it stored —
|
|
69
|
+
// asks nothing here, because there is nobody to ask about.
|
|
70
|
+
const uid = context.uid;
|
|
71
|
+
if (!uid) return null;
|
|
72
|
+
const now = (_input_now = input.now) != null ? _input_now : new Date();
|
|
73
|
+
for (const writer of writers){
|
|
74
|
+
const refusal = await writer.refusal({
|
|
75
|
+
orgId: context.orgId,
|
|
76
|
+
hostId,
|
|
77
|
+
uid,
|
|
78
|
+
org,
|
|
79
|
+
now
|
|
80
|
+
});
|
|
81
|
+
// The seam's 409 is "one already exists", which for an admission is a
|
|
82
|
+
// room-to-create answer rather than a fault the door can act on.
|
|
83
|
+
if (refusal) return {
|
|
84
|
+
status: refusal.status === 409 ? 403 : refusal.status,
|
|
85
|
+
error: refusal.error
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
//# sourceMappingURL=ai-job-plugin-drafts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-job-plugin-drafts.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 { isHostPluginEnabled } from '@aglyn/aglyn/plugin-manager/enabled-plugins'\nimport {\n pluginResourceDraftWriter,\n type PluginResourceDraftWriter,\n} from '@aglyn/aglyn/plugin-manager/plugin-resource-drafts'\nimport { filterEnabledPluginsByReleaseFlags } from '@aglyn/tenant-data-admin/server/release-flags'\nimport { resolveOrgIdForHost } from '@aglyn/tenant-data-admin/server/organizations'\nimport type { AiJobKind } from '../model/ai-jobs.types'\nimport type { AiJobAdmissionContext, AiJobAdmissionRefusal } from './ai-job-admission'\n\n/**\n * Admitting a job whose drafts ANOTHER plugin writes (AGL-2912).\n *\n * `aiDraftAdmissionRefusal` admits the kinds this plugin writes itself, where\n * the allowance is one it can read. An email job writes no document of its\n * own: the email plugin owns the email design and the marketing plugin owns\n * the campaign, and each registers a writer on the `plugin-resource-drafts`\n * seam. So the question this answers is different, and it is the caller's\n * half of that seam's contract — the seam carries no authorization of the\n * caller, so a caller establishes, before it asks for anything:\n *\n * 1. a site is named, and it is the job's own org's;\n * 2. the owning plugin runs on that site — switched on for the workspace,\n * not switched off for the site, and past its release flag — and has\n * actually registered its writer in this process;\n * 3. whatever the kind checks of its own, such as the plan a campaign needs;\n * 4. that the member the drafts are for may create one of each, which only\n * the owner can answer, and does, through `refusal`.\n *\n * Asked at the create door before the job exists and again at the resume door\n * before a confirmed plan runs, so a plugin switched off, or an allowance used\n * up, in between is caught before the job spends. A refusal is the owner's own\n * sentence wherever there is one, so a person reads what the console would\n * have told them.\n */\n\n/** How a resource's draft writer is found; the core's registry by default. */\nexport type AiPluginDraftWriterLookup = (resource: string) => PluginResourceDraftWriter | null\n\n/** The registered writer for a resource, or `null` when no plugin writes it here. */\nexport const aiPluginDraftWriter: AiPluginDraftWriterLookup = (resource) =>\n pluginResourceDraftWriter(resource)?.writer ?? null\n\n/** One draft a job kind needs written, and who owns it. */\nexport interface AiPluginDraftNeed {\n /** The resource name the owner registered its writer under. */\n resource: string\n /** The owning plugin, as `plugins.config.json` names it. */\n pluginId: string\n /** What the site's plugin list calls it, for the sentence a person reads. */\n label: string\n}\n\nexport interface AiPluginDraftAdmissionInput {\n /** The job kind, named in the refusal that asks for a site. */\n kind: AiJobKind\n /** Every draft the kind writes, each checked in turn. */\n drafts: readonly AiPluginDraftNeed[]\n /** The kind's own check, asked once the site and its plugins are known good. */\n ownCheck?: (hostId: string) => Promise<AiJobAdmissionRefusal | null>\n /** How a writer is found; the registry otherwise. */\n writerFor?: AiPluginDraftWriterLookup\n /** The instant the owner's allowance is read against; now otherwise. */\n now?: Date\n}\n\n/** What a person is told when the plugin that owns a draft does not run here. */\nexport function aiPluginDraftUnavailable(label: string): string {\n return `Turn on ${label} for this site before starting the job.`\n}\n\n/**\n * Whether a job of this kind may start on this site for this member; `null`\n * admits it. Nothing here writes, and nothing here spends.\n */\nexport async function aiPluginDraftAdmissionRefusal(\n context: AiJobAdmissionContext,\n input: AiPluginDraftAdmissionInput,\n): Promise<AiJobAdmissionRefusal | null> {\n const { hostId } = context\n if (!hostId) {\n return { status: 400, error: `Open the site the ${input.kind} is for before starting the job` }\n }\n const owner = await resolveOrgIdForHost(hostId)\n if (!owner || owner !== context.orgId) return { status: 404, error: 'Unknown site' }\n\n const writerFor = input.writerFor ?? aiPluginDraftWriter\n const host = (await context.firestore.collection('hosts').doc(hostId).get()).data() ?? null\n const org = context.org as { enabledPlugins?: string[] } | null\n // One release-flag read for every owner at once: the answer is per org, and\n // a plugin subtracted here is one the site cannot reach at all.\n const released = new Set(\n await filterEnabledPluginsByReleaseFlags(\n input.drafts.map((draft) => draft.pluginId),\n { orgId: context.orgId, authorization: null },\n ),\n )\n const writers: PluginResourceDraftWriter[] = []\n for (const draft of input.drafts) {\n const writer = writerFor(draft.resource)\n if (\n !writer ||\n !released.has(draft.pluginId) ||\n !isHostPluginEnabled(org, host, draft.pluginId)\n ) {\n return { status: 403, error: aiPluginDraftUnavailable(draft.label) }\n }\n writers.push(writer)\n }\n\n const own = await input.ownCheck?.(hostId)\n if (own) return own\n\n // Whether this member may create one of each, in the owner's own words. A\n // door that names no member — the machine re-checking a job it stored —\n // asks nothing here, because there is nobody to ask about.\n const uid = context.uid\n if (!uid) return null\n const now = input.now ?? new Date()\n for (const writer of writers) {\n const refusal = await writer.refusal({ orgId: context.orgId, hostId, uid, org, now })\n // The seam's 409 is \"one already exists\", which for an admission is a\n // room-to-create answer rather than a fault the door can act on.\n if (refusal) return { status: refusal.status === 409 ? 403 : refusal.status, error: refusal.error }\n }\n return null\n}\n"],"names":["isHostPluginEnabled","pluginResourceDraftWriter","filterEnabledPluginsByReleaseFlags","resolveOrgIdForHost","aiPluginDraftWriter","resource","writer","aiPluginDraftUnavailable","label","aiPluginDraftAdmissionRefusal","context","input","hostId","status","error","kind","owner","orgId","writerFor","host","firestore","collection","doc","get","data","org","released","Set","drafts","map","draft","pluginId","authorization","writers","has","push","own","ownCheck","uid","now","Date","refusal"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,mBAAmB,QAAQ,8CAA6C;AACjF,SACEC,yBAAyB,QAEpB,qDAAoD;AAC3D,SAASC,kCAAkC,QAAQ,gDAA+C;AAClG,SAASC,mBAAmB,QAAQ,gDAA+C;AAiCnF,mFAAmF,GACnF,OAAO,MAAMC,sBAAiD,CAACC;;QAC7DJ;oBAAAA,6BAAAA,0BAA0BI,8BAA1BJ,2BAAqCK,MAAM,mBAAI;EAAI;AAyBrD,+EAA+E,GAC/E,OAAO,SAASC,yBAAyBC,KAAa;IACpD,OAAO,CAAC,QAAQ,EAAEA,MAAM,uCAAuC,CAAC;AAClE;AAEA;;;CAGC,GACD,OAAO,eAAeC,8BACpBC,OAA8B,EAC9BC,KAAkC;QAShBA,kBACL,OA+BDA;IAvCZ,MAAM,EAAEC,MAAM,EAAE,GAAGF;IACnB,IAAI,CAACE,QAAQ;QACX,OAAO;YAAEC,QAAQ;YAAKC,OAAO,CAAC,kBAAkB,EAAEH,MAAMI,IAAI,CAAC,+BAA+B,CAAC;QAAC;IAChG;IACA,MAAMC,QAAQ,MAAMb,oBAAoBS;IACxC,IAAI,CAACI,SAASA,UAAUN,QAAQO,KAAK,EAAE,OAAO;QAAEJ,QAAQ;QAAKC,OAAO;IAAe;IAEnF,MAAMI,aAAYP,mBAAAA,MAAMO,SAAS,YAAfP,mBAAmBP;IACrC,MAAMe,QAAO,QAAA,AAAC,CAAA,MAAMT,QAAQU,SAAS,CAACC,UAAU,CAAC,SAASC,GAAG,CAACV,QAAQW,GAAG,EAAC,EAAGC,IAAI,cAApE,QAA0E;IACvF,MAAMC,MAAMf,QAAQe,GAAG;IACvB,4EAA4E;IAC5E,gEAAgE;IAChE,MAAMC,WAAW,IAAIC,IACnB,MAAMzB,mCACJS,MAAMiB,MAAM,CAACC,GAAG,CAAC,CAACC,QAAUA,MAAMC,QAAQ,GAC1C;QAAEd,OAAOP,QAAQO,KAAK;QAAEe,eAAe;IAAK;IAGhD,MAAMC,UAAuC,EAAE;IAC/C,KAAK,MAAMH,SAASnB,MAAMiB,MAAM,CAAE;QAChC,MAAMtB,SAASY,UAAUY,MAAMzB,QAAQ;QACvC,IACE,CAACC,UACD,CAACoB,SAASQ,GAAG,CAACJ,MAAMC,QAAQ,KAC5B,CAAC/B,oBAAoByB,KAAKN,MAAMW,MAAMC,QAAQ,GAC9C;YACA,OAAO;gBAAElB,QAAQ;gBAAKC,OAAOP,yBAAyBuB,MAAMtB,KAAK;YAAE;QACrE;QACAyB,QAAQE,IAAI,CAAC7B;IACf;IAEA,MAAM8B,MAAM,OAAMzB,MAAM0B,QAAQ,oBAAd1B,MAAM0B,QAAQ,MAAd1B,OAAiBC;IACnC,IAAIwB,KAAK,OAAOA;IAEhB,0EAA0E;IAC1E,wEAAwE;IACxE,2DAA2D;IAC3D,MAAME,MAAM5B,QAAQ4B,GAAG;IACvB,IAAI,CAACA,KAAK,OAAO;IACjB,MAAMC,OAAM5B,aAAAA,MAAM4B,GAAG,YAAT5B,aAAa,IAAI6B;IAC7B,KAAK,MAAMlC,UAAU2B,QAAS;QAC5B,MAAMQ,UAAU,MAAMnC,OAAOmC,OAAO,CAAC;YAAExB,OAAOP,QAAQO,KAAK;YAAEL;YAAQ0B;YAAKb;YAAKc;QAAI;QACnF,sEAAsE;QACtE,iEAAiE;QACjE,IAAIE,SAAS,OAAO;YAAE5B,QAAQ4B,QAAQ5B,MAAM,KAAK,MAAM,MAAM4B,QAAQ5B,MAAM;YAAEC,OAAO2B,QAAQ3B,KAAK;QAAC;IACpG;IACA,OAAO;AACT"}
|
|
@@ -0,0 +1,106 @@
|
|
|
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 { AiJob } from '../model/ai-jobs.types';
|
|
18
|
+
import { type AiProductPhotoRead } from '../model/ai-products';
|
|
19
|
+
import { type AiJobAdmission } from './ai-job-admission';
|
|
20
|
+
import { type AiProductImageSeams } from './ai-product-image';
|
|
21
|
+
import type { AiJobStepRunner } from './ai-job-text-step';
|
|
22
|
+
/**
|
|
23
|
+
* The `products` step (AGL-2916): commerce by AI, as proposals.
|
|
24
|
+
*
|
|
25
|
+
* `inputs.target` names the work (`model/ai-products.ts`): one product's copy
|
|
26
|
+
* from what its editor holds, the copy of many saved products one a pass, a
|
|
27
|
+
* store's first products from a brief, or its categories and a first set of
|
|
28
|
+
* discounts from a brief.
|
|
29
|
+
*
|
|
30
|
+
* ## It writes nothing
|
|
31
|
+
*
|
|
32
|
+
* Like every runner, this reads, asks and returns. Every output is a
|
|
33
|
+
* `product` proposal, and the commerce plugin's own surfaces write what a
|
|
34
|
+
* person accepts: the product editor's Save, the products card's apply, and
|
|
35
|
+
* the create paths the catalog and discount cards already use — each with the
|
|
36
|
+
* allowance, role and seed checks those paths carry. A proposed product is
|
|
37
|
+
* created as a draft with no price, and a proposed discount is created
|
|
38
|
+
* switched off.
|
|
39
|
+
*
|
|
40
|
+
* ## A bulk job, a product at a time
|
|
41
|
+
*
|
|
42
|
+
* A bulk job's pass writes one product's copy and asks the machine to
|
|
43
|
+
* continue while products remain, so each product is one reservation and one
|
|
44
|
+
* provider exchange, and a job that runs out of credits resumes at the
|
|
45
|
+
* product where it stopped. Which product is next is read from the job's own
|
|
46
|
+
* outputs, one a product, so nothing is kept anywhere else. A product that is
|
|
47
|
+
* gone, or whose copy cannot be held to the rules, is reported and passed
|
|
48
|
+
* over rather than failing the products after it.
|
|
49
|
+
*
|
|
50
|
+
* ## What the model is shown
|
|
51
|
+
*
|
|
52
|
+
* The product's name, type, text, tags, options and current search listing,
|
|
53
|
+
* the names of the site's categories, the store's name, and — for a model that
|
|
54
|
+
* reads pictures — the product's first photo, read from the site's own media
|
|
55
|
+
* library as `ai-product-image.ts` describes. A catalog or categories request
|
|
56
|
+
* carries the brief and the store's name, and the second its existing category
|
|
57
|
+
* names. No price, stock, order, customer or other product is read for any of
|
|
58
|
+
* them.
|
|
59
|
+
*/
|
|
60
|
+
export declare const AI_PRODUCTS_NO_SITE_COPY = "Open the store this job is for before starting it.";
|
|
61
|
+
export declare const AI_PRODUCTS_UNKNOWN_SITE_COPY = "This AI job names a site this workspace does not have.";
|
|
62
|
+
export declare const AI_PRODUCTS_NOT_ENTITLED_COPY = "Your plan does not include selling products. See Billing.";
|
|
63
|
+
export declare const AI_PRODUCTS_COMMERCE_OFF_COPY = "Turn on Commerce for this site before starting the job.";
|
|
64
|
+
export declare const AI_PRODUCTS_GONE_COPY = "This product is no longer in the catalog.";
|
|
65
|
+
export declare const AI_PRODUCTS_DECLINED_COPY = "The model declined to write copy for this product.";
|
|
66
|
+
/** The notes a proposal carries about its product's photo. */
|
|
67
|
+
export declare const AI_PRODUCT_PHOTO_NOTES: Readonly<Partial<Record<AiProductPhotoRead, string>>>;
|
|
68
|
+
/**
|
|
69
|
+
* ASSUMED: how long a catalog or categories pass reads the site before it
|
|
70
|
+
* asks: the host document and, for categories, the category names.
|
|
71
|
+
*/
|
|
72
|
+
export declare const AI_PRODUCTS_SITE_READ_MS = 1000;
|
|
73
|
+
/**
|
|
74
|
+
* One product's copy (AGL-3035): its generation and re-ask at the copy's own
|
|
75
|
+
* ceiling on the tier `job.products` is served from, with the photo read. The
|
|
76
|
+
* least any pass of the step needs, and so what the step registers.
|
|
77
|
+
*/
|
|
78
|
+
export declare const AI_JOB_PRODUCT_COPY_BUDGET: import("./ai-job-budget").AiJobStepBudget;
|
|
79
|
+
/** A catalog: the largest answer the step asks for, at the routing table's ceiling. */
|
|
80
|
+
export declare const AI_JOB_CATALOG_BUDGET: import("./ai-job-budget").AiJobStepBudget;
|
|
81
|
+
/** Categories and discounts. */
|
|
82
|
+
export declare const AI_JOB_CATEGORIES_BUDGET: import("./ai-job-budget").AiJobStepBudget;
|
|
83
|
+
/** What the `products` step registers: the least any of its passes needs. */
|
|
84
|
+
export declare const AI_JOB_PRODUCTS_STEP_BUDGET: import("./ai-job-budget").AiJobStepBudget;
|
|
85
|
+
/** The least time the next pass of a job needs, by what the job asks for. */
|
|
86
|
+
export declare function aiProductsRunMinimumMs(job: Pick<AiJob, 'inputs'>): number;
|
|
87
|
+
export interface AiJobProductsStepDeps {
|
|
88
|
+
image?: AiProductImageSeams;
|
|
89
|
+
/** Whether a model reads pictures; the provider's own descriptor otherwise. */
|
|
90
|
+
readsImages?: (model: string) => boolean;
|
|
91
|
+
}
|
|
92
|
+
/** The step, with its reads replaceable where a spec needs them. */
|
|
93
|
+
export declare function createAiJobProductsStep(deps?: AiJobProductsStepDeps): AiJobStepRunner;
|
|
94
|
+
export declare const runAiJobProductsStep: AiJobStepRunner;
|
|
95
|
+
/**
|
|
96
|
+
* Whether a `products` job may start: inputs it can run, a site of the job's
|
|
97
|
+
* own org, a plan that sells products, and Commerce on for the site and past
|
|
98
|
+
* its release flag. Asked by the create door before the job exists, so a
|
|
99
|
+
* refusal spends nothing.
|
|
100
|
+
*/
|
|
101
|
+
export declare const aiProductsJobAdmission: AiJobAdmission;
|
|
102
|
+
/**
|
|
103
|
+
* Registers the `products` step, the least time each of its passes needs, its
|
|
104
|
+
* pass bound and its admission.
|
|
105
|
+
*/
|
|
106
|
+
export declare function registerAiProductsJob(): void;
|
|
@@ -0,0 +1,436 @@
|
|
|
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
|
+
*/ import { checkEntitlement } from "@aglyn/aglyn/app-utils/plan-entitlements";
|
|
18
|
+
import { isHostPluginEnabled } from "@aglyn/aglyn/plugin-manager/enabled-plugins";
|
|
19
|
+
import { resolveOrgIdForHost } from "@aglyn/tenant-data-admin/server/organizations";
|
|
20
|
+
import { filterEnabledPluginsByReleaseFlags } from "@aglyn/tenant-data-admin/server/release-flags";
|
|
21
|
+
import { AI_PRODUCT_CATEGORY_LIST_MAX, AI_PRODUCT_OPTIONS_MAX, AI_PRODUCT_OPTION_VALUES_MAX, AI_PRODUCT_TEXT_MAX_CHARS, AI_PRODUCT_TYPES, AI_PRODUCTS_BULK_MAX, AI_PRODUCTS_OUTPUT_IDS, aiProductGaps, aiProductsProposalOf, parseAiProductsJobInputs } from "../model/ai-products.js";
|
|
22
|
+
import { AI_STEP_TIERS } from "../providers/catalog.js";
|
|
23
|
+
import { aiModelForStep } from "../providers/routing.js";
|
|
24
|
+
import { AI_CATALOG_MAX_TOKENS, AI_PRODUCT_CATEGORIES_MAX_TOKENS, AI_PRODUCT_COPY_MAX_TOKENS, AI_PRODUCTS_STEP, generateAiCatalog, generateAiCategories, generateAiProductCopy } from "../runtime/ai-products-generation.js";
|
|
25
|
+
import { aiRouteReadsImages } from "../runtime/ai-runtime.js";
|
|
26
|
+
import { registerAiJobAdmission } from "./ai-job-admission.js";
|
|
27
|
+
import { aiJobStepBudget } from "./ai-job-budget.js";
|
|
28
|
+
import { aiGenerationSpent, aiUnspentOutcome } from "./ai-job-generation.js";
|
|
29
|
+
import { AI_PRODUCT_IMAGE_READ_MS, readAiProductImage } from "./ai-product-image.js";
|
|
30
|
+
import { registerAiJobStep, registerAiJobStepPasses } from "./ai-jobs.js";
|
|
31
|
+
/**
|
|
32
|
+
* The `products` step (AGL-2916): commerce by AI, as proposals.
|
|
33
|
+
*
|
|
34
|
+
* `inputs.target` names the work (`model/ai-products.ts`): one product's copy
|
|
35
|
+
* from what its editor holds, the copy of many saved products one a pass, a
|
|
36
|
+
* store's first products from a brief, or its categories and a first set of
|
|
37
|
+
* discounts from a brief.
|
|
38
|
+
*
|
|
39
|
+
* ## It writes nothing
|
|
40
|
+
*
|
|
41
|
+
* Like every runner, this reads, asks and returns. Every output is a
|
|
42
|
+
* `product` proposal, and the commerce plugin's own surfaces write what a
|
|
43
|
+
* person accepts: the product editor's Save, the products card's apply, and
|
|
44
|
+
* the create paths the catalog and discount cards already use — each with the
|
|
45
|
+
* allowance, role and seed checks those paths carry. A proposed product is
|
|
46
|
+
* created as a draft with no price, and a proposed discount is created
|
|
47
|
+
* switched off.
|
|
48
|
+
*
|
|
49
|
+
* ## A bulk job, a product at a time
|
|
50
|
+
*
|
|
51
|
+
* A bulk job's pass writes one product's copy and asks the machine to
|
|
52
|
+
* continue while products remain, so each product is one reservation and one
|
|
53
|
+
* provider exchange, and a job that runs out of credits resumes at the
|
|
54
|
+
* product where it stopped. Which product is next is read from the job's own
|
|
55
|
+
* outputs, one a product, so nothing is kept anywhere else. A product that is
|
|
56
|
+
* gone, or whose copy cannot be held to the rules, is reported and passed
|
|
57
|
+
* over rather than failing the products after it.
|
|
58
|
+
*
|
|
59
|
+
* ## What the model is shown
|
|
60
|
+
*
|
|
61
|
+
* The product's name, type, text, tags, options and current search listing,
|
|
62
|
+
* the names of the site's categories, the store's name, and — for a model that
|
|
63
|
+
* reads pictures — the product's first photo, read from the site's own media
|
|
64
|
+
* library as `ai-product-image.ts` describes. A catalog or categories request
|
|
65
|
+
* carries the brief and the store's name, and the second its existing category
|
|
66
|
+
* names. No price, stock, order, customer or other product is read for any of
|
|
67
|
+
* them.
|
|
68
|
+
*/ export const AI_PRODUCTS_NO_SITE_COPY = 'Open the store this job is for before starting it.';
|
|
69
|
+
export const AI_PRODUCTS_UNKNOWN_SITE_COPY = 'This AI job names a site this workspace does not have.';
|
|
70
|
+
export const AI_PRODUCTS_NOT_ENTITLED_COPY = 'Your plan does not include selling products. See Billing.';
|
|
71
|
+
export const AI_PRODUCTS_COMMERCE_OFF_COPY = 'Turn on Commerce for this site before starting the job.';
|
|
72
|
+
export const AI_PRODUCTS_GONE_COPY = 'This product is no longer in the catalog.';
|
|
73
|
+
export const AI_PRODUCTS_DECLINED_COPY = 'The model declined to write copy for this product.';
|
|
74
|
+
/** The notes a proposal carries about its product's photo. */ export const AI_PRODUCT_PHOTO_NOTES = {
|
|
75
|
+
'not-in-library': 'The photo was not read: it is not in this site’s media library. The copy is written from the product’s words.',
|
|
76
|
+
unreadable: 'The photo could not be read, so the copy is written from the product’s words.',
|
|
77
|
+
model: 'The photo was not read: the model this job ran on does not read pictures.'
|
|
78
|
+
};
|
|
79
|
+
/** The commerce plugin, as `plugins.config.json` names it. */ const COMMERCE_PLUGIN_ID = 'commerce';
|
|
80
|
+
/**
|
|
81
|
+
* ASSUMED: how long a catalog or categories pass reads the site before it
|
|
82
|
+
* asks: the host document and, for categories, the category names.
|
|
83
|
+
*/ export const AI_PRODUCTS_SITE_READ_MS = 1000;
|
|
84
|
+
const TIER = AI_STEP_TIERS[AI_PRODUCTS_STEP];
|
|
85
|
+
/**
|
|
86
|
+
* One product's copy (AGL-3035): its generation and re-ask at the copy's own
|
|
87
|
+
* ceiling on the tier `job.products` is served from, with the photo read. The
|
|
88
|
+
* least any pass of the step needs, and so what the step registers.
|
|
89
|
+
*/ export const AI_JOB_PRODUCT_COPY_BUDGET = aiJobStepBudget({
|
|
90
|
+
tier: TIER,
|
|
91
|
+
maxTokens: AI_PRODUCT_COPY_MAX_TOKENS,
|
|
92
|
+
lookups: 0,
|
|
93
|
+
ownReadsMs: AI_PRODUCT_IMAGE_READ_MS
|
|
94
|
+
});
|
|
95
|
+
/** A catalog: the largest answer the step asks for, at the routing table's ceiling. */ export const AI_JOB_CATALOG_BUDGET = aiJobStepBudget({
|
|
96
|
+
tier: TIER,
|
|
97
|
+
maxTokens: AI_CATALOG_MAX_TOKENS,
|
|
98
|
+
lookups: 0,
|
|
99
|
+
ownReadsMs: AI_PRODUCTS_SITE_READ_MS
|
|
100
|
+
});
|
|
101
|
+
/** Categories and discounts. */ export const AI_JOB_CATEGORIES_BUDGET = aiJobStepBudget({
|
|
102
|
+
tier: TIER,
|
|
103
|
+
maxTokens: AI_PRODUCT_CATEGORIES_MAX_TOKENS,
|
|
104
|
+
lookups: 0,
|
|
105
|
+
ownReadsMs: AI_PRODUCTS_SITE_READ_MS
|
|
106
|
+
});
|
|
107
|
+
/** What the `products` step registers: the least any of its passes needs. */ export const AI_JOB_PRODUCTS_STEP_BUDGET = AI_JOB_PRODUCT_COPY_BUDGET;
|
|
108
|
+
/** The least time the next pass of a job needs, by what the job asks for. */ export function aiProductsRunMinimumMs(job) {
|
|
109
|
+
const inputs = parseAiProductsJobInputs(job.inputs);
|
|
110
|
+
if (typeof inputs === 'string') return AI_JOB_PRODUCT_COPY_BUDGET.minimumMs;
|
|
111
|
+
if (inputs.target === 'catalog') return AI_JOB_CATALOG_BUDGET.minimumMs;
|
|
112
|
+
if (inputs.target === 'categories') return AI_JOB_CATEGORIES_BUDGET.minimumMs;
|
|
113
|
+
return AI_JOB_PRODUCT_COPY_BUDGET.minimumMs;
|
|
114
|
+
}
|
|
115
|
+
const str = (value)=>typeof value === 'string' ? value.trim() : '';
|
|
116
|
+
/** Through JSON, so no `undefined` reaches the job document's write. */ const plain = (value)=>JSON.parse(JSON.stringify(value));
|
|
117
|
+
/** The site a job names, read and checked against the job's org. */ async function loadStore(firestore, job) {
|
|
118
|
+
var _host_seo;
|
|
119
|
+
if (!job.hostId) return {
|
|
120
|
+
failure: AI_PRODUCTS_NO_SITE_COPY
|
|
121
|
+
};
|
|
122
|
+
const snapshot = await firestore.collection('hosts').doc(job.hostId).get();
|
|
123
|
+
const host = snapshot.exists ? snapshot.data() : null;
|
|
124
|
+
// The door checks the caller's membership of the org the job is metered
|
|
125
|
+
// against; a site of another org is refused here, before anything of it
|
|
126
|
+
// reaches a prompt.
|
|
127
|
+
if (!host || host['orgId'] !== job.orgId) return {
|
|
128
|
+
failure: AI_PRODUCTS_UNKNOWN_SITE_COPY
|
|
129
|
+
};
|
|
130
|
+
const seo = (_host_seo = host['seo']) != null ? _host_seo : {};
|
|
131
|
+
const subdomain = str(host['subdomain']) || null;
|
|
132
|
+
return {
|
|
133
|
+
hostId: job.hostId,
|
|
134
|
+
subdomain,
|
|
135
|
+
name: str(seo['title']) || str(host['displayName']) || subdomain || ''
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/** The site's categories by name, as many as a request lists. */ async function readCategories(firestore, hostId) {
|
|
139
|
+
const snapshot = await firestore.collection('hosts').doc(hostId).collection('productCategories').select('name').limit(AI_PRODUCT_CATEGORY_LIST_MAX).get();
|
|
140
|
+
return snapshot.docs.map((doc)=>({
|
|
141
|
+
id: doc.id,
|
|
142
|
+
name: str(doc.get('name'))
|
|
143
|
+
})).filter((category)=>category.name).sort((a, b)=>a.name.localeCompare(b.name));
|
|
144
|
+
}
|
|
145
|
+
/** A saved product's facts, as a bulk pass reads them; `null` when it is gone. */ async function readProductFacts(firestore, hostId, productId) {
|
|
146
|
+
var _data_seo;
|
|
147
|
+
const snapshot = await firestore.collection('hosts').doc(hostId).collection('products').doc(productId).get();
|
|
148
|
+
const data = snapshot.exists ? snapshot.data() : null;
|
|
149
|
+
if (!data || data['deletedAt']) return null;
|
|
150
|
+
const name = str(data['name']);
|
|
151
|
+
if (!name) return null;
|
|
152
|
+
const type = data['type'];
|
|
153
|
+
const seo = (_data_seo = data['seo']) != null ? _data_seo : {};
|
|
154
|
+
const mediaUrls = Array.isArray(data['mediaUrls']) ? data['mediaUrls'] : [];
|
|
155
|
+
return {
|
|
156
|
+
id: productId,
|
|
157
|
+
name,
|
|
158
|
+
type: AI_PRODUCT_TYPES.includes(type) ? type : 'physical',
|
|
159
|
+
text: str(data['description']).slice(0, AI_PRODUCT_TEXT_MAX_CHARS),
|
|
160
|
+
tags: (Array.isArray(data['tags']) ? data['tags'] : []).map(str).filter(Boolean),
|
|
161
|
+
categoryIds: (Array.isArray(data['categoryIds']) ? data['categoryIds'] : []).map(str).filter(Boolean),
|
|
162
|
+
options: (Array.isArray(data['options']) ? data['options'] : []).slice(0, AI_PRODUCT_OPTIONS_MAX).map((option)=>{
|
|
163
|
+
const record = option != null ? option : {};
|
|
164
|
+
return {
|
|
165
|
+
name: str(record['name']),
|
|
166
|
+
values: (Array.isArray(record['values']) ? record['values'] : []).map(str).filter(Boolean).slice(0, AI_PRODUCT_OPTION_VALUES_MAX)
|
|
167
|
+
};
|
|
168
|
+
}).filter((option)=>option.name),
|
|
169
|
+
imageUrl: str(mediaUrls[0]) || str(data['imageUrl']) || null,
|
|
170
|
+
seoTitle: str(seo['title']),
|
|
171
|
+
seoDescription: str(seo['description'])
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function modelOf(context) {
|
|
175
|
+
var _ref;
|
|
176
|
+
return (_ref = context.modelFor == null ? void 0 : context.modelFor.call(context, AI_PRODUCTS_STEP)) != null ? _ref : aiModelForStep(AI_PRODUCTS_STEP);
|
|
177
|
+
}
|
|
178
|
+
/** An output addressed to the site, so its link opens the site's products. */ function output(site, id, label, proposal) {
|
|
179
|
+
return {
|
|
180
|
+
resource: 'product',
|
|
181
|
+
id,
|
|
182
|
+
hostId: site.hostId,
|
|
183
|
+
hostSubdomain: site.subdomain,
|
|
184
|
+
label,
|
|
185
|
+
proposal: plain(proposal)
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
/** Ask for one product's copy, and build its proposal from the answer. */ async function writeProductCopy(context, model, site, product, deps) {
|
|
189
|
+
var _ref;
|
|
190
|
+
const { job, firestore, signal } = context;
|
|
191
|
+
const categories = await readCategories(firestore, site.hostId);
|
|
192
|
+
let photo = 'none';
|
|
193
|
+
let image = null;
|
|
194
|
+
if (product.imageUrl) {
|
|
195
|
+
var _deps_readsImages;
|
|
196
|
+
if (((_deps_readsImages = deps.readsImages) != null ? _deps_readsImages : aiRouteReadsImages)(model)) {
|
|
197
|
+
const read = await readAiProductImage(firestore, {
|
|
198
|
+
value: product.imageUrl,
|
|
199
|
+
hostId: site.hostId,
|
|
200
|
+
orgId: job.orgId
|
|
201
|
+
}, deps.image);
|
|
202
|
+
photo = read.status;
|
|
203
|
+
image = read.status === 'read' ? read.image : null;
|
|
204
|
+
} else {
|
|
205
|
+
photo = 'model';
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const generation = await generateAiProductCopy(_extends({
|
|
209
|
+
store: site.name,
|
|
210
|
+
product,
|
|
211
|
+
categories,
|
|
212
|
+
photo: Boolean(image),
|
|
213
|
+
image,
|
|
214
|
+
model,
|
|
215
|
+
maxTokens: AI_JOB_PRODUCT_COPY_BUDGET.maxTokens(model)
|
|
216
|
+
}, signal ? {
|
|
217
|
+
signal
|
|
218
|
+
} : {}));
|
|
219
|
+
const values = generation.status === 'ok' ? generation.value : null;
|
|
220
|
+
const names = new Map(categories.map((category)=>[
|
|
221
|
+
category.id,
|
|
222
|
+
category.name
|
|
223
|
+
]));
|
|
224
|
+
const note = AI_PRODUCT_PHOTO_NOTES[photo];
|
|
225
|
+
return {
|
|
226
|
+
generation,
|
|
227
|
+
proposal: {
|
|
228
|
+
kind: 'copy',
|
|
229
|
+
product: {
|
|
230
|
+
id: product.id,
|
|
231
|
+
name: product.name
|
|
232
|
+
},
|
|
233
|
+
values,
|
|
234
|
+
categories: ((_ref = values == null ? void 0 : values.categoryIds) != null ? _ref : []).map((id)=>{
|
|
235
|
+
var _names_get;
|
|
236
|
+
return {
|
|
237
|
+
id,
|
|
238
|
+
name: (_names_get = names.get(id)) != null ? _names_get : id
|
|
239
|
+
};
|
|
240
|
+
}),
|
|
241
|
+
optionNamesBefore: product.options.map((option)=>option.name),
|
|
242
|
+
gaps: values ? aiProductGaps(values.description) : [],
|
|
243
|
+
photo,
|
|
244
|
+
skipped: null,
|
|
245
|
+
notes: note ? [
|
|
246
|
+
note
|
|
247
|
+
] : []
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
/** The step, with its reads replaceable where a spec needs them. */ export function createAiJobProductsStep(deps = {}) {
|
|
252
|
+
return async (context)=>{
|
|
253
|
+
const { job, firestore, signal } = context;
|
|
254
|
+
const model = modelOf(context);
|
|
255
|
+
const inputs = parseAiProductsJobInputs(job.inputs);
|
|
256
|
+
if (typeof inputs === 'string') return _extends({}, aiUnspentOutcome(model), {
|
|
257
|
+
failure: inputs
|
|
258
|
+
});
|
|
259
|
+
const site = await loadStore(firestore, job);
|
|
260
|
+
if ('failure' in site) return _extends({}, aiUnspentOutcome(model), {
|
|
261
|
+
failure: site.failure
|
|
262
|
+
});
|
|
263
|
+
if (inputs.target === 'product') {
|
|
264
|
+
const { generation, proposal } = await writeProductCopy(context, model, site, inputs.product, deps);
|
|
265
|
+
const spent = aiGenerationSpent(generation);
|
|
266
|
+
if (generation.status === 'refused') return _extends({}, spent, {
|
|
267
|
+
refused: true
|
|
268
|
+
});
|
|
269
|
+
if (generation.status === 'needs_input') return _extends({}, spent, {
|
|
270
|
+
failure: generation.message
|
|
271
|
+
});
|
|
272
|
+
return _extends({}, spent, {
|
|
273
|
+
outputs: [
|
|
274
|
+
output(site, AI_PRODUCTS_OUTPUT_IDS.copy(inputs.product.id), `Product copy · ${inputs.product.name}`, proposal)
|
|
275
|
+
]
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
if (inputs.target === 'bulk') {
|
|
279
|
+
var _job_outputs;
|
|
280
|
+
const done = ((_job_outputs = job.outputs) != null ? _job_outputs : []).filter((entry)=>{
|
|
281
|
+
var _aiProductsProposalOf;
|
|
282
|
+
return ((_aiProductsProposalOf = aiProductsProposalOf(entry)) == null ? void 0 : _aiProductsProposalOf.kind) === 'copy';
|
|
283
|
+
}).length;
|
|
284
|
+
const productId = inputs.productIds[done];
|
|
285
|
+
if (!productId) return aiUnspentOutcome(model);
|
|
286
|
+
const more = done + 1 < inputs.productIds.length;
|
|
287
|
+
const product = await readProductFacts(firestore, site.hostId, productId);
|
|
288
|
+
if (!product) {
|
|
289
|
+
const skipped = {
|
|
290
|
+
kind: 'copy',
|
|
291
|
+
product: {
|
|
292
|
+
id: productId,
|
|
293
|
+
name: productId
|
|
294
|
+
},
|
|
295
|
+
values: null,
|
|
296
|
+
categories: [],
|
|
297
|
+
optionNamesBefore: [],
|
|
298
|
+
gaps: [],
|
|
299
|
+
photo: 'none',
|
|
300
|
+
skipped: AI_PRODUCTS_GONE_COPY,
|
|
301
|
+
notes: []
|
|
302
|
+
};
|
|
303
|
+
return _extends({}, aiUnspentOutcome(model, {
|
|
304
|
+
outputs: [
|
|
305
|
+
output(site, AI_PRODUCTS_OUTPUT_IDS.copy(productId), `Product copy · ${productId}`, skipped)
|
|
306
|
+
]
|
|
307
|
+
}), {
|
|
308
|
+
continue: more
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
const { generation, proposal } = await writeProductCopy(context, model, site, product, deps);
|
|
312
|
+
const spent = aiGenerationSpent(generation);
|
|
313
|
+
// One product the rules could not hold, or the model declined, is
|
|
314
|
+
// reported and passed over: its tokens are metered with the pass, and
|
|
315
|
+
// the products after it still get their copy.
|
|
316
|
+
const reported = generation.status === 'ok' ? proposal : _extends({}, proposal, {
|
|
317
|
+
skipped: generation.status === 'needs_input' ? generation.message : AI_PRODUCTS_DECLINED_COPY
|
|
318
|
+
});
|
|
319
|
+
return _extends({}, spent, {
|
|
320
|
+
outputs: [
|
|
321
|
+
output(site, AI_PRODUCTS_OUTPUT_IDS.copy(productId), `Product copy · ${product.name}`, reported)
|
|
322
|
+
],
|
|
323
|
+
continue: more
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
if (inputs.target === 'catalog') {
|
|
327
|
+
const generation = await generateAiCatalog(_extends({
|
|
328
|
+
store: site.name,
|
|
329
|
+
brief: job.brief,
|
|
330
|
+
model,
|
|
331
|
+
maxTokens: AI_JOB_CATALOG_BUDGET.maxTokens(model)
|
|
332
|
+
}, signal ? {
|
|
333
|
+
signal
|
|
334
|
+
} : {}));
|
|
335
|
+
const spent = aiGenerationSpent(generation);
|
|
336
|
+
if (generation.status === 'refused') return _extends({}, spent, {
|
|
337
|
+
refused: true
|
|
338
|
+
});
|
|
339
|
+
if (generation.status === 'needs_input') return _extends({}, spent, {
|
|
340
|
+
failure: generation.message
|
|
341
|
+
});
|
|
342
|
+
const proposal = {
|
|
343
|
+
kind: 'catalog',
|
|
344
|
+
products: generation.value,
|
|
345
|
+
notes: []
|
|
346
|
+
};
|
|
347
|
+
return _extends({}, spent, {
|
|
348
|
+
outputs: [
|
|
349
|
+
output(site, AI_PRODUCTS_OUTPUT_IDS.catalog, `Proposed products · ${generation.value.length}`, proposal)
|
|
350
|
+
]
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
const existing = await readCategories(firestore, site.hostId);
|
|
354
|
+
const generation = await generateAiCategories(_extends({
|
|
355
|
+
store: site.name,
|
|
356
|
+
brief: job.brief,
|
|
357
|
+
existingCategoryNames: existing.map((category)=>category.name),
|
|
358
|
+
model,
|
|
359
|
+
maxTokens: AI_JOB_CATEGORIES_BUDGET.maxTokens(model)
|
|
360
|
+
}, signal ? {
|
|
361
|
+
signal
|
|
362
|
+
} : {}));
|
|
363
|
+
const spent = aiGenerationSpent(generation);
|
|
364
|
+
if (generation.status === 'refused') return _extends({}, spent, {
|
|
365
|
+
refused: true
|
|
366
|
+
});
|
|
367
|
+
if (generation.status === 'needs_input') return _extends({}, spent, {
|
|
368
|
+
failure: generation.message
|
|
369
|
+
});
|
|
370
|
+
const proposal = _extends({
|
|
371
|
+
kind: 'categories'
|
|
372
|
+
}, generation.value, {
|
|
373
|
+
notes: []
|
|
374
|
+
});
|
|
375
|
+
return _extends({}, spent, {
|
|
376
|
+
outputs: [
|
|
377
|
+
output(site, AI_PRODUCTS_OUTPUT_IDS.categories, 'Proposed categories and discounts', proposal)
|
|
378
|
+
]
|
|
379
|
+
});
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
export const runAiJobProductsStep = createAiJobProductsStep();
|
|
383
|
+
/**
|
|
384
|
+
* Whether a `products` job may start: inputs it can run, a site of the job's
|
|
385
|
+
* own org, a plan that sells products, and Commerce on for the site and past
|
|
386
|
+
* its release flag. Asked by the create door before the job exists, so a
|
|
387
|
+
* refusal spends nothing.
|
|
388
|
+
*/ export const aiProductsJobAdmission = async (context)=>{
|
|
389
|
+
var _data;
|
|
390
|
+
const inputs = parseAiProductsJobInputs(context.inputs);
|
|
391
|
+
if (typeof inputs === 'string') return {
|
|
392
|
+
status: 400,
|
|
393
|
+
error: inputs
|
|
394
|
+
};
|
|
395
|
+
if (!context.hostId) return {
|
|
396
|
+
status: 400,
|
|
397
|
+
error: AI_PRODUCTS_NO_SITE_COPY
|
|
398
|
+
};
|
|
399
|
+
const owner = await resolveOrgIdForHost(context.hostId);
|
|
400
|
+
if (!owner || owner !== context.orgId) return {
|
|
401
|
+
status: 404,
|
|
402
|
+
error: AI_PRODUCTS_UNKNOWN_SITE_COPY
|
|
403
|
+
};
|
|
404
|
+
const org = context.org;
|
|
405
|
+
if (!checkEntitlement(org, 'commerce')) return {
|
|
406
|
+
status: 403,
|
|
407
|
+
error: AI_PRODUCTS_NOT_ENTITLED_COPY
|
|
408
|
+
};
|
|
409
|
+
const host = (_data = (await context.firestore.collection('hosts').doc(context.hostId).get()).data()) != null ? _data : null;
|
|
410
|
+
const released = await filterEnabledPluginsByReleaseFlags([
|
|
411
|
+
COMMERCE_PLUGIN_ID
|
|
412
|
+
], {
|
|
413
|
+
orgId: context.orgId,
|
|
414
|
+
authorization: null
|
|
415
|
+
});
|
|
416
|
+
if (!released.includes(COMMERCE_PLUGIN_ID) || !isHostPluginEnabled(org, host, COMMERCE_PLUGIN_ID)) {
|
|
417
|
+
return {
|
|
418
|
+
status: 403,
|
|
419
|
+
error: AI_PRODUCTS_COMMERCE_OFF_COPY
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
return null;
|
|
423
|
+
};
|
|
424
|
+
/**
|
|
425
|
+
* Registers the `products` step, the least time each of its passes needs, its
|
|
426
|
+
* pass bound and its admission.
|
|
427
|
+
*/ export function registerAiProductsJob() {
|
|
428
|
+
registerAiJobStep('products', runAiJobProductsStep, {
|
|
429
|
+
minimumMs: AI_JOB_PRODUCTS_STEP_BUDGET.minimumMs,
|
|
430
|
+
minimumMsFor: aiProductsRunMinimumMs
|
|
431
|
+
});
|
|
432
|
+
registerAiJobStepPasses('products', AI_PRODUCTS_BULK_MAX);
|
|
433
|
+
registerAiJobAdmission('products', aiProductsJobAdmission);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
//# sourceMappingURL=ai-job-products-step.js.map
|