@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,262 @@
|
|
|
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 { _ as _extends } from "@swc/helpers/_/_extends";
|
|
17
|
+
import { duplicateResource } from "@aglyn/tenant-data-admin/server/duplicate-resource";
|
|
18
|
+
import { AI_STEP_TIERS } from "../providers/catalog.js";
|
|
19
|
+
import { AI_ROUTING_TABLE, aiModelForStep } from "../providers/routing.js";
|
|
20
|
+
import { runValidatedGeneration } from "../runtime/ai-doctrine.js";
|
|
21
|
+
import { readSiteInventory } from "../runtime/site-inventory.js";
|
|
22
|
+
import { AI_COMPONENT_TOOL_NAME, aiComponentPropKindWords, aiComponentTool } from "../tools/ai-component-tool.js";
|
|
23
|
+
import { registerAiJobAdmission } from "./ai-job-admission.js";
|
|
24
|
+
import { aiJobStepBudget } from "./ai-job-budget.js";
|
|
25
|
+
import { aiComponentCheck } from "./ai-job-component-checks.js";
|
|
26
|
+
import { aiJobDraftId } from "./ai-job-draft-ids.js";
|
|
27
|
+
import { aiDraftAdmissionRefusal, aiDraftAllowanceRefusal, aiSiteSubdomain, readAiDraft, writeAiDraft } from "./ai-job-drafts.js";
|
|
28
|
+
import { aiBracketedFactsNote, aiConfirmedPlan, aiDoctrineReview, aiGenerationSpent, aiJobBriefLine, aiLimitReview, aiPlanCreation, aiPlanReferenceLines, aiUnspentOutcome } from "./ai-job-generation.js";
|
|
29
|
+
import { registerAiJobStep } from "./ai-jobs.js";
|
|
30
|
+
/**
|
|
31
|
+
* The component step (AGL-2908): the generation step of a `component` job,
|
|
32
|
+
* run once a member confirmed the job's plan.
|
|
33
|
+
*
|
|
34
|
+
* It builds ONE reusable component from the brief — its tree, and the typed
|
|
35
|
+
* properties each page that places it fills in — through
|
|
36
|
+
* `runValidatedGeneration('component', …)`, so every building rule holds on
|
|
37
|
+
* the tree before it is kept. The tree binds each property with
|
|
38
|
+
* `{{prop.<name>}}`; the palette validator keeps those tokens as written
|
|
39
|
+
* (`definesComponent`), and the step's own check, through `extend`, holds
|
|
40
|
+
* each binding to what the Properties dialog and the Attributes panel allow
|
|
41
|
+
* (`ai-job-component-checks.ts`).
|
|
42
|
+
*
|
|
43
|
+
* The component lands as a new draft (`ai-job-drafts.ts`) that no page
|
|
44
|
+
* places, and gets its first version when a member opens it, as every
|
|
45
|
+
* component created outside the besigner does. A plan that starts from a copy
|
|
46
|
+
* of a component the site has gets that copy, through the platform's
|
|
47
|
+
* duplicate module, and nothing generated.
|
|
48
|
+
*
|
|
49
|
+
* A generation step runs on the job beat, never at an inline door: it
|
|
50
|
+
* registers the least time its lookup rounds, its answer and its re-ask need
|
|
51
|
+
* (AGL-3035), runs without extended thinking, and asks for no more of the
|
|
52
|
+
* ceiling the layout and template steps keep than fits that time on the model
|
|
53
|
+
* it runs. The step's spec measures the request and the answer against it.
|
|
54
|
+
*/ /** The longest answer a component may run to; the tree is held to the component budget either way. */ export const AI_JOB_COMPONENT_MAX_TOKENS = AI_ROUTING_TABLE['job.component'].maxTokens;
|
|
55
|
+
/**
|
|
56
|
+
* The component step's time (AGL-3035, AGL-3036): its two inventory-lookup
|
|
57
|
+
* rounds, its answer and its re-ask at the routing table's ceiling on the tier
|
|
58
|
+
* `job.component` is served from, fitted to what a beat can give a step.
|
|
59
|
+
*/ export const AI_JOB_COMPONENT_STEP_BUDGET = aiJobStepBudget({
|
|
60
|
+
tier: AI_STEP_TIERS['job.component'],
|
|
61
|
+
maxTokens: AI_JOB_COMPONENT_MAX_TOKENS
|
|
62
|
+
});
|
|
63
|
+
/** The least time one component step needs before it starts. */ export const AI_JOB_COMPONENT_STEP_MINIMUM_MS = AI_JOB_COMPONENT_STEP_BUDGET.minimumMs;
|
|
64
|
+
/** A component's name when the plan names none. */ export const AI_JOB_COMPONENT_DEFAULT_NAME = 'Component';
|
|
65
|
+
/** The component step's own instructions, cached after the doctrine and before the catalog. */ export const AI_JOB_COMPONENT_INSTRUCTIONS = [
|
|
66
|
+
{
|
|
67
|
+
text: [
|
|
68
|
+
`You build one reusable component for a website: a block the site places on many pages, each placement filling in its own values. Answer with ${AI_COMPONENT_TOOL_NAME}: the component’s tree as one flat node map, and the properties it declares.`,
|
|
69
|
+
'The root is the document wrapper holding the component. A component is placed inside a page section, which opens with its own h2: it carries no main landmark, its headings are h3 or below, and its colors, spacing and type come from the theme.',
|
|
70
|
+
'Every value that should differ from one placement to the next is a property, bound in the tree with its token {{prop.<name>}}. Declare every property the tree binds, and bind every property you declare.',
|
|
71
|
+
`Property kinds, as type (the name a page reads): ${aiComponentPropKindWords()}.`,
|
|
72
|
+
'A property binds only to a field that holds its kind of value:',
|
|
73
|
+
'- text, richText and number: copy, such as a Typography’s text, an Image’s alt or a Button’s label, as the whole value or inside a sentence.',
|
|
74
|
+
'- image: an Image’s src, as the whole value.',
|
|
75
|
+
'- href: a screenId or an href, as the whole value.',
|
|
76
|
+
'- icon: an Icon element’s iconId, as the whole value.',
|
|
77
|
+
'- boolean: a switch setting such as a Button’s fullWidth, or hideIf on the part it hides, as the whole value.',
|
|
78
|
+
'- choice: a setting with fixed options such as a Button’s variant, as the whole value, with every answer’s value one that setting lists.',
|
|
79
|
+
'An optional part, such as a photo, a badge or a second button, gets a boolean property labeled "Hide <the part>" whose default is "false", and the part’s own element carries "hideIf": "{{prop.<name>}}". Never hide the whole component.',
|
|
80
|
+
'A default is what the component shows until a page sets it: copy in the site’s voice from the brief, with a fact the brief does not give in square brackets; for href a screen id from the site inventory, or ""; for image "", for an upload; for icon "", for the site owner to pick; for choice one of its answers’ values.'
|
|
81
|
+
].join('\n')
|
|
82
|
+
}
|
|
83
|
+
];
|
|
84
|
+
/** The component job as the generation's user turn: the name, the brief, the confirmed plan. */ export function aiJobComponentPrompt(job, plan, name) {
|
|
85
|
+
return [
|
|
86
|
+
`Component name: ${name}`,
|
|
87
|
+
aiJobBriefLine(job),
|
|
88
|
+
...aiPlanReferenceLines(plan)
|
|
89
|
+
].join('\n');
|
|
90
|
+
}
|
|
91
|
+
/** A component job is admitted for a site of the job's own org whose plan includes reusable components. */ export const aiComponentJobAdmission = (context)=>aiDraftAdmissionRefusal(context.firestore, {
|
|
92
|
+
orgId: context.orgId,
|
|
93
|
+
hostId: context.hostId,
|
|
94
|
+
kind: 'component',
|
|
95
|
+
org: context.org
|
|
96
|
+
});
|
|
97
|
+
export function createAiJobComponentStep(deps = {}) {
|
|
98
|
+
var _deps_readInventory, _deps_duplicate;
|
|
99
|
+
const readInventory = (_deps_readInventory = deps.readInventory) != null ? _deps_readInventory : readSiteInventory;
|
|
100
|
+
const duplicate = (_deps_duplicate = deps.duplicate) != null ? _deps_duplicate : duplicateResource;
|
|
101
|
+
return async ({ job, now, signal, firestore, modelFor })=>{
|
|
102
|
+
var _ref, _orgSnapshot_data;
|
|
103
|
+
const hostId = job.hostId;
|
|
104
|
+
if (!hostId) throw new Error('a component job names no site, and its admission refuses one');
|
|
105
|
+
const output = (draft, load, note)=>_extends({
|
|
106
|
+
resource: 'reusableComponent',
|
|
107
|
+
id: draft.id,
|
|
108
|
+
versionId: draft.versionId,
|
|
109
|
+
hostId,
|
|
110
|
+
hostSubdomain: draft.hostSubdomain,
|
|
111
|
+
label: draft.name
|
|
112
|
+
}, load ? {
|
|
113
|
+
load
|
|
114
|
+
} : {}, note ? {
|
|
115
|
+
note
|
|
116
|
+
} : {});
|
|
117
|
+
// The switch's answer for this job, else the routing table's (AGL-2942).
|
|
118
|
+
const model = (_ref = modelFor == null ? void 0 : modelFor('job.component')) != null ? _ref : aiModelForStep('job.component');
|
|
119
|
+
// A run cut off after its draft was written reports that draft, found by the id the job recorded.
|
|
120
|
+
const draftId = aiJobDraftId(job, 'component');
|
|
121
|
+
const written = await readAiDraft(firestore, {
|
|
122
|
+
kind: 'component',
|
|
123
|
+
hostId,
|
|
124
|
+
id: draftId
|
|
125
|
+
});
|
|
126
|
+
if (written) return aiUnspentOutcome(model, {
|
|
127
|
+
outputs: [
|
|
128
|
+
output(written)
|
|
129
|
+
]
|
|
130
|
+
});
|
|
131
|
+
const [inventory, orgSnapshot] = await Promise.all([
|
|
132
|
+
readInventory(job.orgId, hostId, {
|
|
133
|
+
firestore
|
|
134
|
+
}),
|
|
135
|
+
firestore.collection('orgs').doc(job.orgId).get()
|
|
136
|
+
]);
|
|
137
|
+
const org = (_orgSnapshot_data = orgSnapshot.data()) != null ? _orgSnapshot_data : null;
|
|
138
|
+
const plan = aiConfirmedPlan(job);
|
|
139
|
+
const creation = aiPlanCreation(plan, 'component');
|
|
140
|
+
const name = (creation == null ? void 0 : creation.name) || AI_JOB_COMPONENT_DEFAULT_NAME;
|
|
141
|
+
// The plan starts from a copy of a component the site has (rule 15): the
|
|
142
|
+
// copy is the draft, and nothing is generated. A source gone since the
|
|
143
|
+
// plan was made is built from the brief instead.
|
|
144
|
+
if ((creation == null ? void 0 : creation.duplicateOf) && inventory.components.some((component)=>component.id === creation.duplicateOf)) {
|
|
145
|
+
const copy = await duplicate('component', {
|
|
146
|
+
orgId: job.orgId,
|
|
147
|
+
hostId,
|
|
148
|
+
sourceId: creation.duplicateOf,
|
|
149
|
+
name,
|
|
150
|
+
uid: job.createdBy,
|
|
151
|
+
org: org
|
|
152
|
+
});
|
|
153
|
+
if (copy.ok) {
|
|
154
|
+
var _copy_versionId;
|
|
155
|
+
const hostSubdomain = await aiSiteSubdomain(firestore, hostId);
|
|
156
|
+
return aiUnspentOutcome(model, {
|
|
157
|
+
outputs: [
|
|
158
|
+
output({
|
|
159
|
+
id: copy.id,
|
|
160
|
+
versionId: (_copy_versionId = copy.versionId) != null ? _copy_versionId : null,
|
|
161
|
+
name: copy.name,
|
|
162
|
+
hostSubdomain
|
|
163
|
+
})
|
|
164
|
+
]
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
if (copy.ok === false && copy.status === 403) {
|
|
168
|
+
return aiUnspentOutcome(model, {
|
|
169
|
+
review: aiLimitReview(copy.error)
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
const allowance = await aiDraftAllowanceRefusal(firestore, {
|
|
174
|
+
kind: 'component',
|
|
175
|
+
hostId,
|
|
176
|
+
org
|
|
177
|
+
});
|
|
178
|
+
if (allowance) return aiUnspentOutcome(model, {
|
|
179
|
+
review: aiLimitReview(allowance)
|
|
180
|
+
});
|
|
181
|
+
let props = [];
|
|
182
|
+
const result = await runValidatedGeneration('component', _extends({
|
|
183
|
+
step: 'job.component',
|
|
184
|
+
model,
|
|
185
|
+
instructions: AI_JOB_COMPONENT_INSTRUCTIONS,
|
|
186
|
+
inventory,
|
|
187
|
+
messages: [
|
|
188
|
+
{
|
|
189
|
+
role: 'user',
|
|
190
|
+
content: aiJobComponentPrompt(job, plan, name)
|
|
191
|
+
}
|
|
192
|
+
],
|
|
193
|
+
tool: aiComponentTool(),
|
|
194
|
+
maxTokens: AI_JOB_COMPONENT_STEP_BUDGET.maxTokens(model)
|
|
195
|
+
}, AI_ROUTING_TABLE['job.component'].thinking ? {
|
|
196
|
+
thinking: AI_ROUTING_TABLE['job.component'].thinking
|
|
197
|
+
} : {}, AI_ROUTING_TABLE['job.component'].effort ? {
|
|
198
|
+
effort: AI_ROUTING_TABLE['job.component'].effort
|
|
199
|
+
} : {}, {
|
|
200
|
+
context: {
|
|
201
|
+
definesComponent: true
|
|
202
|
+
},
|
|
203
|
+
extend: aiComponentCheck({
|
|
204
|
+
inventory,
|
|
205
|
+
plan,
|
|
206
|
+
onProps: (declared)=>{
|
|
207
|
+
props = declared;
|
|
208
|
+
}
|
|
209
|
+
})
|
|
210
|
+
}, signal ? {
|
|
211
|
+
signal
|
|
212
|
+
} : {}));
|
|
213
|
+
const spent = aiGenerationSpent(result);
|
|
214
|
+
if (result.status === 'refused') return _extends({}, spent, {
|
|
215
|
+
refused: true
|
|
216
|
+
});
|
|
217
|
+
if (result.status === 'needs_input') return _extends({}, spent, {
|
|
218
|
+
review: aiDoctrineReview(result)
|
|
219
|
+
});
|
|
220
|
+
const draft = await writeAiDraft(firestore, {
|
|
221
|
+
kind: 'component',
|
|
222
|
+
hostId,
|
|
223
|
+
id: draftId,
|
|
224
|
+
uid: job.createdBy,
|
|
225
|
+
org,
|
|
226
|
+
name,
|
|
227
|
+
nodes: result.value.nodes,
|
|
228
|
+
rootId: result.value.rootId,
|
|
229
|
+
props,
|
|
230
|
+
now
|
|
231
|
+
});
|
|
232
|
+
if (draft.ok === false) {
|
|
233
|
+
if (draft.status === 404) throw new Error(`site ${hostId} vanished while its component was generated`);
|
|
234
|
+
return _extends({}, spent, {
|
|
235
|
+
review: aiLimitReview(draft.error)
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
// The facts the brief did not give, in the tree or the defaults a page shows (AGL-3056).
|
|
239
|
+
const note = aiBracketedFactsNote({
|
|
240
|
+
tree: {
|
|
241
|
+
rootId: result.value.rootId,
|
|
242
|
+
nodes: result.value.nodes
|
|
243
|
+
},
|
|
244
|
+
inventory,
|
|
245
|
+
copy: props.map((prop)=>typeof prop.defaultValue === 'string' ? prop.defaultValue : '')
|
|
246
|
+
});
|
|
247
|
+
return _extends({}, spent, {
|
|
248
|
+
outputs: [
|
|
249
|
+
output(draft, result.value.load, note)
|
|
250
|
+
]
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
export const runAiJobComponentStep = createAiJobComponentStep();
|
|
255
|
+
/** Registers the component step and the check a component job passes before it is created or resumed. */ export function registerAiComponentJob() {
|
|
256
|
+
registerAiJobStep('component', runAiJobComponentStep, {
|
|
257
|
+
minimumMs: AI_JOB_COMPONENT_STEP_MINIMUM_MS
|
|
258
|
+
});
|
|
259
|
+
registerAiJobAdmission('component', aiComponentJobAdmission);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
//# sourceMappingURL=ai-job-component-step.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-job-component-step.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { AglynOrgBilling } from '@aglyn/aglyn/foundation/definitions/org-billing.types'\nimport type { ReusableComponentProp } from '@aglyn/aglyn/foundation/definitions/platform.types'\nimport { duplicateResource } from '@aglyn/tenant-data-admin/server/duplicate-resource'\nimport type { AiJob, AiJobOutput, AiJobPlan } from '../model/ai-jobs.types'\nimport { AI_STEP_TIERS } from '../providers/catalog'\nimport { AI_ROUTING_TABLE, aiModelForStep } from '../providers/routing'\nimport { runValidatedGeneration } from '../runtime/ai-doctrine'\nimport type { AiDoctrineTree } from '../runtime/ai-doctrine-validators'\nimport type { AiLoadEstimate } from '../runtime/ai-palette'\nimport type { AiSystemBlock } from '../runtime/ai-runtime'\nimport { readSiteInventory } from '../runtime/site-inventory'\nimport {\n AI_COMPONENT_TOOL_NAME,\n aiComponentPropKindWords,\n aiComponentTool,\n} from '../tools/ai-component-tool'\nimport { registerAiJobAdmission, type AiJobAdmission } from './ai-job-admission'\nimport { aiJobStepBudget } from './ai-job-budget'\nimport { aiComponentCheck } from './ai-job-component-checks'\nimport { aiJobDraftId } from './ai-job-draft-ids'\nimport {\n aiDraftAdmissionRefusal,\n aiDraftAllowanceRefusal,\n aiSiteSubdomain,\n readAiDraft,\n writeAiDraft,\n type AiDraftRecord,\n} from './ai-job-drafts'\nimport {\n aiBracketedFactsNote,\n aiConfirmedPlan,\n aiDoctrineReview,\n aiGenerationSpent,\n aiJobBriefLine,\n aiLimitReview,\n aiPlanCreation,\n aiPlanReferenceLines,\n aiUnspentOutcome,\n} from './ai-job-generation'\nimport type { AiJobStepRunner } from './ai-job-text-step'\nimport { registerAiJobStep } from './ai-jobs'\n\n/**\n * The component step (AGL-2908): the generation step of a `component` job,\n * run once a member confirmed the job's plan.\n *\n * It builds ONE reusable component from the brief — its tree, and the typed\n * properties each page that places it fills in — through\n * `runValidatedGeneration('component', …)`, so every building rule holds on\n * the tree before it is kept. The tree binds each property with\n * `{{prop.<name>}}`; the palette validator keeps those tokens as written\n * (`definesComponent`), and the step's own check, through `extend`, holds\n * each binding to what the Properties dialog and the Attributes panel allow\n * (`ai-job-component-checks.ts`).\n *\n * The component lands as a new draft (`ai-job-drafts.ts`) that no page\n * places, and gets its first version when a member opens it, as every\n * component created outside the besigner does. A plan that starts from a copy\n * of a component the site has gets that copy, through the platform's\n * duplicate module, and nothing generated.\n *\n * A generation step runs on the job beat, never at an inline door: it\n * registers the least time its lookup rounds, its answer and its re-ask need\n * (AGL-3035), runs without extended thinking, and asks for no more of the\n * ceiling the layout and template steps keep than fits that time on the model\n * it runs. The step's spec measures the request and the answer against it.\n */\n\n/** The longest answer a component may run to; the tree is held to the component budget either way. */\nexport const AI_JOB_COMPONENT_MAX_TOKENS = AI_ROUTING_TABLE['job.component'].maxTokens\n\n/**\n * The component step's time (AGL-3035, AGL-3036): its two inventory-lookup\n * rounds, its answer and its re-ask at the routing table's ceiling on the tier\n * `job.component` is served from, fitted to what a beat can give a step.\n */\nexport const AI_JOB_COMPONENT_STEP_BUDGET = aiJobStepBudget({\n tier: AI_STEP_TIERS['job.component'],\n maxTokens: AI_JOB_COMPONENT_MAX_TOKENS,\n})\n\n/** The least time one component step needs before it starts. */\nexport const AI_JOB_COMPONENT_STEP_MINIMUM_MS = AI_JOB_COMPONENT_STEP_BUDGET.minimumMs\n\n/** A component's name when the plan names none. */\nexport const AI_JOB_COMPONENT_DEFAULT_NAME = 'Component'\n\n/** The component step's own instructions, cached after the doctrine and before the catalog. */\nexport const AI_JOB_COMPONENT_INSTRUCTIONS: readonly AiSystemBlock[] = [\n {\n text: [\n `You build one reusable component for a website: a block the site places on many pages, each placement filling in its own values. Answer with ${AI_COMPONENT_TOOL_NAME}: the component’s tree as one flat node map, and the properties it declares.`,\n 'The root is the document wrapper holding the component. A component is placed inside a page section, which opens with its own h2: it carries no main landmark, its headings are h3 or below, and its colors, spacing and type come from the theme.',\n 'Every value that should differ from one placement to the next is a property, bound in the tree with its token {{prop.<name>}}. Declare every property the tree binds, and bind every property you declare.',\n `Property kinds, as type (the name a page reads): ${aiComponentPropKindWords()}.`,\n 'A property binds only to a field that holds its kind of value:',\n '- text, richText and number: copy, such as a Typography’s text, an Image’s alt or a Button’s label, as the whole value or inside a sentence.',\n '- image: an Image’s src, as the whole value.',\n '- href: a screenId or an href, as the whole value.',\n '- icon: an Icon element’s iconId, as the whole value.',\n '- boolean: a switch setting such as a Button’s fullWidth, or hideIf on the part it hides, as the whole value.',\n '- choice: a setting with fixed options such as a Button’s variant, as the whole value, with every answer’s value one that setting lists.',\n 'An optional part, such as a photo, a badge or a second button, gets a boolean property labeled \"Hide <the part>\" whose default is \"false\", and the part’s own element carries \"hideIf\": \"{{prop.<name>}}\". Never hide the whole component.',\n 'A default is what the component shows until a page sets it: copy in the site’s voice from the brief, with a fact the brief does not give in square brackets; for href a screen id from the site inventory, or \"\"; for image \"\", for an upload; for icon \"\", for the site owner to pick; for choice one of its answers’ values.',\n ].join('\\n'),\n },\n]\n\n/** The component job as the generation's user turn: the name, the brief, the confirmed plan. */\nexport function aiJobComponentPrompt(\n job: Pick<AiJob, 'brief'>,\n plan: AiJobPlan | null,\n name: string,\n): string {\n return [`Component name: ${name}`, aiJobBriefLine(job), ...aiPlanReferenceLines(plan)].join('\\n')\n}\n\n/** A component job is admitted for a site of the job's own org whose plan includes reusable components. */\nexport const aiComponentJobAdmission: AiJobAdmission = (context) =>\n aiDraftAdmissionRefusal(context.firestore, {\n orgId: context.orgId,\n hostId: context.hostId,\n kind: 'component',\n org: context.org,\n })\n\nexport interface AiJobComponentStepDeps {\n /** The inventory reader; specs hand in a fake. */\n readInventory?: typeof readSiteInventory\n /** The platform's duplicate module, for a plan that starts from a copy. */\n duplicate?: typeof duplicateResource\n}\n\nexport function createAiJobComponentStep(deps: AiJobComponentStepDeps = {}): AiJobStepRunner {\n const readInventory = deps.readInventory ?? readSiteInventory\n const duplicate = deps.duplicate ?? duplicateResource\n return async ({ job, now, signal, firestore, modelFor }) => {\n const hostId = job.hostId\n if (!hostId) throw new Error('a component job names no site, and its admission refuses one')\n const output = (draft: AiDraftRecord, load?: AiLoadEstimate | null, note?: string | null): AiJobOutput => ({\n resource: 'reusableComponent',\n id: draft.id,\n versionId: draft.versionId,\n hostId,\n hostSubdomain: draft.hostSubdomain,\n label: draft.name,\n ...(load ? { load } : {}),\n ...(note ? { note } : {}),\n })\n // The switch's answer for this job, else the routing table's (AGL-2942).\n const model = modelFor?.('job.component') ?? aiModelForStep('job.component')\n\n // A run cut off after its draft was written reports that draft, found by the id the job recorded.\n const draftId = aiJobDraftId(job, 'component')\n const written = await readAiDraft(firestore, { kind: 'component', hostId, id: draftId })\n if (written) return aiUnspentOutcome(model, { outputs: [output(written)] })\n\n const [inventory, orgSnapshot] = await Promise.all([\n readInventory(job.orgId, hostId, { firestore }),\n firestore.collection('orgs').doc(job.orgId).get(),\n ])\n const org = (orgSnapshot.data() ?? null) as Partial<AglynOrgBilling> | null\n const plan = aiConfirmedPlan(job)\n const creation = aiPlanCreation(plan, 'component')\n const name = creation?.name || AI_JOB_COMPONENT_DEFAULT_NAME\n\n // The plan starts from a copy of a component the site has (rule 15): the\n // copy is the draft, and nothing is generated. A source gone since the\n // plan was made is built from the brief instead.\n if (\n creation?.duplicateOf &&\n inventory.components.some((component) => component.id === creation.duplicateOf)\n ) {\n const copy = await duplicate('component', {\n orgId: job.orgId,\n hostId,\n sourceId: creation.duplicateOf,\n name,\n uid: job.createdBy,\n org: org as Record<string, unknown> | null,\n })\n if (copy.ok) {\n const hostSubdomain = await aiSiteSubdomain(firestore, hostId)\n return aiUnspentOutcome(model, {\n outputs: [\n output({ id: copy.id, versionId: copy.versionId ?? null, name: copy.name, hostSubdomain }),\n ],\n })\n }\n if (copy.ok === false && copy.status === 403) {\n return aiUnspentOutcome(model, { review: aiLimitReview(copy.error) })\n }\n }\n\n const allowance = await aiDraftAllowanceRefusal(firestore, { kind: 'component', hostId, org })\n if (allowance) return aiUnspentOutcome(model, { review: aiLimitReview(allowance) })\n\n let props: ReusableComponentProp[] = []\n const result = await runValidatedGeneration('component', {\n step: 'job.component',\n model,\n instructions: AI_JOB_COMPONENT_INSTRUCTIONS,\n inventory,\n messages: [{ role: 'user', content: aiJobComponentPrompt(job, plan, name) }],\n tool: aiComponentTool(),\n maxTokens: AI_JOB_COMPONENT_STEP_BUDGET.maxTokens(model),\n ...(AI_ROUTING_TABLE['job.component'].thinking\n ? { thinking: AI_ROUTING_TABLE['job.component'].thinking }\n : {}),\n ...(AI_ROUTING_TABLE['job.component'].effort\n ? { effort: AI_ROUTING_TABLE['job.component'].effort }\n : {}),\n context: { definesComponent: true },\n extend: aiComponentCheck({\n inventory,\n plan,\n onProps: (declared) => {\n props = declared\n },\n }),\n ...(signal ? { signal } : {}),\n })\n const spent = aiGenerationSpent(result)\n if (result.status === 'refused') return { ...spent, refused: true }\n if (result.status === 'needs_input') return { ...spent, review: aiDoctrineReview(result) }\n\n const draft = await writeAiDraft(firestore, {\n kind: 'component',\n hostId,\n id: draftId,\n uid: job.createdBy,\n org,\n name,\n nodes: result.value.nodes,\n rootId: result.value.rootId,\n props,\n now,\n })\n if (draft.ok === false) {\n if (draft.status === 404) throw new Error(`site ${hostId} vanished while its component was generated`)\n return { ...spent, review: aiLimitReview(draft.error) }\n }\n // The facts the brief did not give, in the tree or the defaults a page shows (AGL-3056).\n const note = aiBracketedFactsNote({\n tree: { rootId: result.value.rootId, nodes: result.value.nodes as unknown as AiDoctrineTree['nodes'] },\n inventory,\n copy: props.map((prop) => (typeof prop.defaultValue === 'string' ? prop.defaultValue : '')),\n })\n return { ...spent, outputs: [output(draft, result.value.load, note)] }\n }\n}\n\nexport const runAiJobComponentStep = createAiJobComponentStep()\n\n/** Registers the component step and the check a component job passes before it is created or resumed. */\nexport function registerAiComponentJob(): void {\n registerAiJobStep('component', runAiJobComponentStep, { minimumMs: AI_JOB_COMPONENT_STEP_MINIMUM_MS })\n registerAiJobAdmission('component', aiComponentJobAdmission)\n}\n"],"names":["duplicateResource","AI_STEP_TIERS","AI_ROUTING_TABLE","aiModelForStep","runValidatedGeneration","readSiteInventory","AI_COMPONENT_TOOL_NAME","aiComponentPropKindWords","aiComponentTool","registerAiJobAdmission","aiJobStepBudget","aiComponentCheck","aiJobDraftId","aiDraftAdmissionRefusal","aiDraftAllowanceRefusal","aiSiteSubdomain","readAiDraft","writeAiDraft","aiBracketedFactsNote","aiConfirmedPlan","aiDoctrineReview","aiGenerationSpent","aiJobBriefLine","aiLimitReview","aiPlanCreation","aiPlanReferenceLines","aiUnspentOutcome","registerAiJobStep","AI_JOB_COMPONENT_MAX_TOKENS","maxTokens","AI_JOB_COMPONENT_STEP_BUDGET","tier","AI_JOB_COMPONENT_STEP_MINIMUM_MS","minimumMs","AI_JOB_COMPONENT_DEFAULT_NAME","AI_JOB_COMPONENT_INSTRUCTIONS","text","join","aiJobComponentPrompt","job","plan","name","aiComponentJobAdmission","context","firestore","orgId","hostId","kind","org","createAiJobComponentStep","deps","readInventory","duplicate","now","signal","modelFor","orgSnapshot","Error","output","draft","load","note","resource","id","versionId","hostSubdomain","label","model","draftId","written","outputs","inventory","Promise","all","collection","doc","get","data","creation","duplicateOf","components","some","component","copy","sourceId","uid","createdBy","ok","status","review","error","allowance","props","result","step","instructions","messages","role","content","tool","thinking","effort","definesComponent","extend","onProps","declared","spent","refused","nodes","value","rootId","tree","map","prop","defaultValue","runAiJobComponentStep","registerAiComponentJob"],"mappings":"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"}
|
|
@@ -0,0 +1,192 @@
|
|
|
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 AiCrmProposal, type AiCrmRecordKind, type AiCrmRecordProposal } from '../model/ai-crm';
|
|
18
|
+
import type { AiTool } from '../providers/contract';
|
|
19
|
+
import type { AiSystemBlock } from '../runtime/ai-runtime';
|
|
20
|
+
import { type AiCrmImportField } from '../tools/ai-crm-tool';
|
|
21
|
+
import { type AiCrmReaderLookup } from './ai-crm-access';
|
|
22
|
+
import { type AiJobAdmission, type AiJobAdmissionRefusal } from './ai-job-admission';
|
|
23
|
+
import type { AiJobStepRunner } from './ai-job-text-step';
|
|
24
|
+
/**
|
|
25
|
+
* The `crm` step (AGL-2917): CRM by AI, as proposals.
|
|
26
|
+
*
|
|
27
|
+
* `inputs.task` says what the job is asked (`model/ai-crm.ts`):
|
|
28
|
+
*
|
|
29
|
+
* - `record` — one contact, company, deal or lead (`record`, `recordId`): a
|
|
30
|
+
* summary, the next step as a task, a deal's stage, a lead's standing;
|
|
31
|
+
* - `email` — a draft for the CRM composer, from what the member asked for
|
|
32
|
+
* (the brief) and the record's facts;
|
|
33
|
+
* - `mapping` — an import's columns (`collection`, `columns`) matched to the
|
|
34
|
+
* fields the CRM's import fills.
|
|
35
|
+
*
|
|
36
|
+
* ## The CRM decides what is read
|
|
37
|
+
*
|
|
38
|
+
* The step never reads a CRM document. It asks the CRM's readers on the core's
|
|
39
|
+
* record-facts seam for the job's creator, and the CRM applies its own rules —
|
|
40
|
+
* the member's reach and `data.manage`, the plan, the record's visibility on
|
|
41
|
+
* the site — and reports the facts it chooses to. The admission below asks the
|
|
42
|
+
* same reader before the job exists, beside what an in-process call skips of
|
|
43
|
+
* the plugin API dispatcher: the CRM switched on and released where the job
|
|
44
|
+
* runs. A mapping sends the file's headers and each column's shape, never a
|
|
45
|
+
* cell.
|
|
46
|
+
*
|
|
47
|
+
* ## It writes no CRM record
|
|
48
|
+
*
|
|
49
|
+
* The CRM's task form, stage route, composer and import drawer are the
|
|
50
|
+
* writes, and a member makes each one. No email is sent by a job.
|
|
51
|
+
*
|
|
52
|
+
* ## The answer is kept apart from the job
|
|
53
|
+
*
|
|
54
|
+
* Every member of a workspace may read its jobs, and not every member may
|
|
55
|
+
* read every record. So a job's output names only the question — which
|
|
56
|
+
* record, which import — and the answer is kept at
|
|
57
|
+
* `orgs/{orgId}/aiCrmAnswers/{jobId}`, which no client may read, for two
|
|
58
|
+
* weeks (`AI_CRM_ANSWER_RETENTION_DAYS`). The answer door
|
|
59
|
+
* (`server/ai-crm-answer.ts`) serves it to a member the CRM still lets read
|
|
60
|
+
* the record, asking the same reader again.
|
|
61
|
+
*
|
|
62
|
+
* ## A summary is asked once per timeline
|
|
63
|
+
*
|
|
64
|
+
* A record answer is keyed on the whole request — the record, the site, the
|
|
65
|
+
* model, the rules, the tool and the facts as the CRM reported them — and a
|
|
66
|
+
* later job whose key matches a kept answer reuses it and spends nothing.
|
|
67
|
+
* The facts change exactly when something the model was told changes, so an
|
|
68
|
+
* unchanged record is never asked twice while its answer is kept.
|
|
69
|
+
*/
|
|
70
|
+
/**
|
|
71
|
+
* ASSUMED: the step's own round trips — the facts read (the record and its
|
|
72
|
+
* three windowed queries, in parallel), a record's reuse lookup, and the
|
|
73
|
+
* answer's write.
|
|
74
|
+
*/
|
|
75
|
+
export declare const AI_CRM_FACTS_READS_MS = 1500;
|
|
76
|
+
/**
|
|
77
|
+
* The step's time (AGL-3035): one generation and its re-ask on the tier
|
|
78
|
+
* `job.crm` is served from, after the facts read, with no site inventory and
|
|
79
|
+
* so no lookup round. It fits an inline door's budget, so a member who asks on
|
|
80
|
+
* a record page is answered in the request.
|
|
81
|
+
*/
|
|
82
|
+
export declare const AI_JOB_CRM_STEP_BUDGET: import("./ai-job-budget").AiJobStepBudget;
|
|
83
|
+
/** The least time one CRM step needs before it starts. */
|
|
84
|
+
export declare const AI_JOB_CRM_STEP_MINIMUM_MS: number;
|
|
85
|
+
/** Kept answers to one request a reuse lookup reads. */
|
|
86
|
+
export declare const AI_CRM_REUSE_CANDIDATES = 20;
|
|
87
|
+
/** How long a record answer stays reusable, beside its facts being unchanged: as long as it is kept. */
|
|
88
|
+
export declare const AI_CRM_REUSE_WINDOW_MS: number;
|
|
89
|
+
export declare const AI_CRM_FACTS_FAILURE_COPY = "The CRM record could not be read. Try again.";
|
|
90
|
+
export declare const AI_CRM_KEEP_FAILURE_COPY = "The answer could not be kept. Try again.";
|
|
91
|
+
/** The generation kinds the step asks under, which the doctrine states only its field rules to. */
|
|
92
|
+
export declare const AI_CRM_GENERATION_KINDS: {
|
|
93
|
+
readonly record: "crm-record";
|
|
94
|
+
readonly email: "crm-email";
|
|
95
|
+
readonly mapping: "crm-mapping";
|
|
96
|
+
};
|
|
97
|
+
type Facts = Readonly<Record<string, unknown>>;
|
|
98
|
+
/**
|
|
99
|
+
* The rules for a record of one kind. Each kind is sent the rules its tool can
|
|
100
|
+
* be refused for, and no others: on a model that caches no prompt this short,
|
|
101
|
+
* a rule a request cannot break is paid for on every request.
|
|
102
|
+
*/
|
|
103
|
+
export declare function aiCrmRecordInstructions(kind: AiCrmRecordKind): AiSystemBlock[];
|
|
104
|
+
export declare const AI_CRM_EMAIL_INSTRUCTIONS: AiSystemBlock[];
|
|
105
|
+
export declare const AI_CRM_MAPPING_INSTRUCTIONS: AiSystemBlock[];
|
|
106
|
+
/**
|
|
107
|
+
* The facts as lines of text. Only the fields named here are written, whatever
|
|
108
|
+
* else a reader reports, so what reaches a prompt is decided in two places
|
|
109
|
+
* that both have to agree: the CRM's builders and this list.
|
|
110
|
+
*/
|
|
111
|
+
export declare function aiCrmFactsLines(kind: AiCrmRecordKind, facts: Facts): string[];
|
|
112
|
+
/** The user turn for a record. */
|
|
113
|
+
export declare function aiCrmRecordPrompt(kind: AiCrmRecordKind, facts: Facts): string;
|
|
114
|
+
/** The user turn for an email draft. */
|
|
115
|
+
export declare function aiCrmEmailPrompt(input: {
|
|
116
|
+
kind: AiCrmRecordKind;
|
|
117
|
+
facts: Facts;
|
|
118
|
+
request: string;
|
|
119
|
+
}): string;
|
|
120
|
+
/** The user turn for an import's columns. */
|
|
121
|
+
export declare function aiCrmMappingPrompt(input: {
|
|
122
|
+
collection: string;
|
|
123
|
+
fields: readonly AiCrmImportField[];
|
|
124
|
+
columns: ReadonlyArray<{
|
|
125
|
+
header: string;
|
|
126
|
+
shape: string;
|
|
127
|
+
}>;
|
|
128
|
+
}): string;
|
|
129
|
+
/**
|
|
130
|
+
* A digest of the whole request a record answer is produced for. A hash of the
|
|
131
|
+
* request, never of the answer, and nothing of the facts is recoverable from
|
|
132
|
+
* it. The version tag strands every old key when what a key means changes.
|
|
133
|
+
*/
|
|
134
|
+
export declare function aiCrmRecordKey(input: {
|
|
135
|
+
kind: AiCrmRecordKind;
|
|
136
|
+
id: string;
|
|
137
|
+
hostId: string | null;
|
|
138
|
+
model: string;
|
|
139
|
+
prompt: string;
|
|
140
|
+
system: readonly AiSystemBlock[];
|
|
141
|
+
tool: AiTool;
|
|
142
|
+
}): string;
|
|
143
|
+
/** A kept answer about a record, as the reuse lookup reads it. */
|
|
144
|
+
export interface AiCrmAnswerCandidate {
|
|
145
|
+
jobId: string;
|
|
146
|
+
hostId: string | null;
|
|
147
|
+
task: string;
|
|
148
|
+
key: string | null;
|
|
149
|
+
createdAtMs: number | null;
|
|
150
|
+
proposal: AiCrmProposal | null;
|
|
151
|
+
}
|
|
152
|
+
export type AiCrmAnswerFinder = (orgId: string, key: string, firestore?: FirebaseFirestore.Firestore) => Promise<AiCrmAnswerCandidate[]>;
|
|
153
|
+
/**
|
|
154
|
+
* The finder the step uses in production: one equality on the request key
|
|
155
|
+
* inside the org's kept answers. Firestore's automatic single-field index
|
|
156
|
+
* answers it, so no composite index is deployed; the site and the window are
|
|
157
|
+
* applied in memory.
|
|
158
|
+
*/
|
|
159
|
+
export declare const findAiCrmAnswersByKey: AiCrmAnswerFinder;
|
|
160
|
+
/** The newest answer another job kept for the same request, inside the window. */
|
|
161
|
+
export declare function aiReusableCrmRecord(candidates: readonly AiCrmAnswerCandidate[], context: {
|
|
162
|
+
jobId: string;
|
|
163
|
+
hostId: string | null;
|
|
164
|
+
key: string;
|
|
165
|
+
now: Date;
|
|
166
|
+
}): {
|
|
167
|
+
jobId: string;
|
|
168
|
+
proposal: AiCrmRecordProposal;
|
|
169
|
+
} | null;
|
|
170
|
+
export interface AiCrmAdmissionDeps {
|
|
171
|
+
readerFor?: AiCrmReaderLookup;
|
|
172
|
+
now?: () => Date;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Whether a `crm` job may start here for this member; `null` admits it: its
|
|
176
|
+
* inputs name a record or an import, and the CRM would let the member read it
|
|
177
|
+
* ({@link aiCrmAccessRefusal}). Asked at the create door before the job
|
|
178
|
+
* exists, so a refusal spends nothing. A door that names no member asks
|
|
179
|
+
* nothing of the reader.
|
|
180
|
+
*/
|
|
181
|
+
export declare function aiCrmAdmissionRefusal(context: Parameters<AiJobAdmission>[0], deps?: AiCrmAdmissionDeps): Promise<AiJobAdmissionRefusal | null>;
|
|
182
|
+
export declare const aiCrmJobAdmission: AiJobAdmission;
|
|
183
|
+
export interface AiJobCrmStepDeps {
|
|
184
|
+
readerFor?: AiCrmReaderLookup;
|
|
185
|
+
/** The reuse lookup; specs hand in a fake, and `null` turns reuse off. */
|
|
186
|
+
findAnswersByKey?: AiCrmAnswerFinder | null;
|
|
187
|
+
}
|
|
188
|
+
export declare function createAiJobCrmStep(deps?: AiJobCrmStepDeps): AiJobStepRunner;
|
|
189
|
+
export declare const runAiJobCrmStep: AiJobStepRunner;
|
|
190
|
+
/** Registers the CRM step and the check a `crm` job passes before it is created. */
|
|
191
|
+
export declare function registerAiCrmJob(): void;
|
|
192
|
+
export {};
|