@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,337 @@
|
|
|
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 { hostThemeSource, resolveSiteTheme } from "@aglyn/aglyn/app-utils/marketplace-theme";
|
|
18
|
+
import { INHERITED_BORDER_RADIUS, INHERITED_FONT_FAMILY, INHERITED_SPACING, INHERITED_TOOLBAR_HEIGHTS, inheritedThemeColor } from "@aglyn/shared-ui-theme/util/theme-editor-defaults";
|
|
19
|
+
import { readDarkScheme, readFontFamily, readThemeColor, readToolbarHeight, SYSTEM_FONT_VALUE, THEME_COLOR_FIELDS, THEME_EDITOR_MEDIA_QUERIES } from "@aglyn/shared-ui-theme/util/theme-editor-fields";
|
|
20
|
+
import { buildAiThemeProposal } from "../model/ai-theme-proposal.js";
|
|
21
|
+
import { AI_ROUTING_TABLE, aiModelForStep } from "../providers/routing.js";
|
|
22
|
+
import { runValidatedGeneration } from "../runtime/ai-doctrine.js";
|
|
23
|
+
import { AI_THEME_TOOL_NAME, aiThemeTool, parseAiThemeToolInput } from "../tools/ai-theme-tool.js";
|
|
24
|
+
import { AI_JOB_BRIEF_MAX_CHARS } from "./ai-job-text-step.js";
|
|
25
|
+
import { AI_JOB_THEME_STEP_BUDGET } from "./ai-job-theme-budget.js";
|
|
26
|
+
import { AI_THEME_BRAND_SOURCE_WORDS, gatherAiThemeBrandInputs } from "./ai-theme-brand-inputs.js";
|
|
27
|
+
/**
|
|
28
|
+
* The `theme` step (AGL-2938): a brief and a site's current theme in, a theme
|
|
29
|
+
* proposal out — every control the theme editor exposes, and nothing else.
|
|
30
|
+
*
|
|
31
|
+
* The step writes nothing to the site. A site's theme is fields on its host
|
|
32
|
+
* document, and writing those is the save the Theme section's editor
|
|
33
|
+
* performs; the step's output is the proposal, which a person puts in the
|
|
34
|
+
* editor, previews against the current theme, and saves or discards.
|
|
35
|
+
*
|
|
36
|
+
* The request is shaped for the cache: the rules and the tool are static and
|
|
37
|
+
* sit in the cached prefix, and everything about this site — its theme, its
|
|
38
|
+
* brand colors, the brief — rides in the user turn. The model answers through
|
|
39
|
+
* one strict tool derived from the editor's own catalog, and the answer is
|
|
40
|
+
* held to that catalog and to the doctrine (a targeted diff, dark values,
|
|
41
|
+
* contrast) before it becomes a proposal.
|
|
42
|
+
*/ /**
|
|
43
|
+
* The routing table's answer for `job.theme`: the model the theme step runs on
|
|
44
|
+
* when the machine hands it no `modelFor`.
|
|
45
|
+
*/ export function aiJobThemeModel() {
|
|
46
|
+
return aiModelForStep('job.theme');
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The output budget, from the routing table. The largest answer the tool
|
|
50
|
+
* accepts — every color in both schemes, the full run of component leaves,
|
|
51
|
+
* the longest summary — is about 2,500 tokens of JSON
|
|
52
|
+
* (`ai-job-theme-step.spec.ts` measures it), and the rest is room for the
|
|
53
|
+
* model to think before it answers.
|
|
54
|
+
*/ export const AI_JOB_THEME_MAX_TOKENS = AI_ROUTING_TABLE['job.theme'].maxTokens;
|
|
55
|
+
/**
|
|
56
|
+
* The theme's answer ceiling on the model a job runs (AGL-3035): the most
|
|
57
|
+
* whose worst case — the answer, its re-ask and the brand reads — fits the
|
|
58
|
+
* least time the step registers (`ai-job-theme-budget.ts`), and never more
|
|
59
|
+
* than the routing table's.
|
|
60
|
+
*/ export function aiJobThemeMaxTokens(model) {
|
|
61
|
+
return AI_JOB_THEME_STEP_BUDGET.maxTokens(model);
|
|
62
|
+
}
|
|
63
|
+
/** How many of a site's own component override leaves the prompt lists. */ export const AI_JOB_THEME_INVENTORY_LEAVES = 40;
|
|
64
|
+
/** The customer-safe sentences a failed theme step leaves on the job. */ export const AI_JOB_THEME_NO_SITE_COPY = 'This theme job names a site this workspace does not have.';
|
|
65
|
+
export const AI_JOB_THEME_NO_ANSWER_COPY = 'The AI could not produce a theme proposal from this brief. Try describing the change differently.';
|
|
66
|
+
/**
|
|
67
|
+
* The theme step's own instructions, byte-identical on every request so they
|
|
68
|
+
* cache. The acceptable-use rules are not in them: they belong to the block
|
|
69
|
+
* every generator shares, which the generation call puts ahead of these.
|
|
70
|
+
*/ export const AI_JOB_THEME_INSTRUCTIONS = [
|
|
71
|
+
{
|
|
72
|
+
text: 'You change the theme of a website built with a site builder. You are given the ' + "site's current theme — every control its theme editor has, with the value the site " + 'set or the default it inherits — any brand colors that belong to the site, and a ' + 'brief from the person who owns it.\n\n' + `Answer by calling ${AI_THEME_TOOL_NAME} exactly once. A reply in prose cannot be used.\n\n` + 'Rules:\n' + '- In modify mode, name only the controls the brief is about. Every control you leave ' + 'out keeps its current value. "Warmer" is about color, not about fonts or corners.\n' + '- In create mode, design a complete theme: the primary, secondary and tertiary ' + 'accents, the page background and paper, the text colors, and their dark values.\n' + "- Colors are hex values on the theme's own tokens. A theme is where the building rules " + 'send every color, so this is the one answer that writes a color as a value. A component ' + 'style never carries a literal color; color belongs to the palette.\n' + '- Give every color you change a dark value beside its light value unless the dark ' + 'scheme is off. A dark value keeps the hue and reads on a dark background.\n' + '- Keep text readable: body text needs 4.5:1 against the background and the paper, and ' + 'the primary color 3:1 against the background.\n' + '- A hex color written in the brief is used exactly as written. When the brief asks to ' + 'match the brand, build on the brand colors you are given.\n' + '- Fonts come from the list the tool offers, and numbers stay inside the ranges it ' + 'states.\n' + '- Write the summary in the language of the brief.',
|
|
73
|
+
cacheBreakpoint: true
|
|
74
|
+
}
|
|
75
|
+
];
|
|
76
|
+
const ZERO_USAGE = {
|
|
77
|
+
inputTokens: 0,
|
|
78
|
+
outputTokens: 0,
|
|
79
|
+
cacheReadTokens: 0,
|
|
80
|
+
cacheWriteTokens: 0
|
|
81
|
+
};
|
|
82
|
+
/** `create` when the job asked for a whole design; `modify` otherwise. */ export function aiJobThemeMode(inputs) {
|
|
83
|
+
return (inputs == null ? void 0 : inputs['mode']) === 'create' ? 'create' : 'modify';
|
|
84
|
+
}
|
|
85
|
+
const SOURCE_WORDS = {
|
|
86
|
+
installed: "an installed marketplace theme; a change is stored as the site's own edits on top of it",
|
|
87
|
+
custom: "the site's own theme",
|
|
88
|
+
default: "the platform's default theme; a change stores only the values it sets"
|
|
89
|
+
};
|
|
90
|
+
/** One value as the inventory shows it: the site's own, or the default it inherits. */ const shown = (own, inherited)=>own === null || own === undefined ? `${inherited != null ? inherited : 'unset'} (default)` : `${own} (set)`;
|
|
91
|
+
/** The site's own component overrides, one bounded line a leaf. */ function overrideLeaves(theme) {
|
|
92
|
+
var _ref;
|
|
93
|
+
const leaves = [];
|
|
94
|
+
const media = Object.fromEntries(Object.entries(THEME_EDITOR_MEDIA_QUERIES).map(([name, query])=>[
|
|
95
|
+
query,
|
|
96
|
+
name
|
|
97
|
+
]));
|
|
98
|
+
const text = (value)=>{
|
|
99
|
+
var _ref;
|
|
100
|
+
var _JSON_stringify;
|
|
101
|
+
return (_ref = (_JSON_stringify = JSON.stringify(value)) == null ? void 0 : _JSON_stringify.slice(0, 60)) != null ? _ref : '';
|
|
102
|
+
};
|
|
103
|
+
for (const [component, override] of Object.entries((_ref = theme == null ? void 0 : theme.components) != null ? _ref : {})){
|
|
104
|
+
var _ref1, _ref2;
|
|
105
|
+
for (const [prop, value] of Object.entries((_ref1 = override == null ? void 0 : override.defaultProps) != null ? _ref1 : {})){
|
|
106
|
+
leaves.push(`${component} default ${prop} = ${text(value)}`);
|
|
107
|
+
}
|
|
108
|
+
for (const [slot, styles] of Object.entries((_ref2 = override == null ? void 0 : override.styleOverrides) != null ? _ref2 : {})){
|
|
109
|
+
if (!styles || typeof styles !== 'object') continue;
|
|
110
|
+
for (const [property, value] of Object.entries(styles)){
|
|
111
|
+
if (value && typeof value === 'object') {
|
|
112
|
+
for (const [nested, nestedValue] of Object.entries(value)){
|
|
113
|
+
var _media_property;
|
|
114
|
+
leaves.push(`${component} ${slot} ${nested} = ${text(nestedValue)} (${(_media_property = media[property]) != null ? _media_property : property})`);
|
|
115
|
+
}
|
|
116
|
+
} else {
|
|
117
|
+
leaves.push(`${component} ${slot} ${property} = ${text(value)}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return leaves;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The site's theme as the model reads it: compact, one control a line, each
|
|
126
|
+
* value marked as the site's own or the default it inherits, so "make the
|
|
127
|
+
* background warmer" starts from the color the visitor actually sees.
|
|
128
|
+
*/ export function aiJobThemeInventory(theme, source) {
|
|
129
|
+
var _theme_shape;
|
|
130
|
+
const lines = [
|
|
131
|
+
`Source: ${SOURCE_WORDS[source]}.`,
|
|
132
|
+
`Dark scheme: ${readDarkScheme(theme)}.`
|
|
133
|
+
];
|
|
134
|
+
lines.push('Colors, light | dark:');
|
|
135
|
+
for (const { token } of THEME_COLOR_FIELDS){
|
|
136
|
+
const value = (scheme)=>shown(readThemeColor(theme, scheme, token), inheritedThemeColor(scheme, token));
|
|
137
|
+
lines.push(`- ${token}: ${value('light')} | ${value('dark')}`);
|
|
138
|
+
}
|
|
139
|
+
const font = readFontFamily(theme);
|
|
140
|
+
lines.push(`Font family: ${shown(font === SYSTEM_FONT_VALUE ? null : font, INHERITED_FONT_FAMILY)}`);
|
|
141
|
+
lines.push(`Border radius: ${shown(theme == null ? void 0 : (_theme_shape = theme.shape) == null ? void 0 : _theme_shape.borderRadius, INHERITED_BORDER_RADIUS)}`);
|
|
142
|
+
lines.push(`Spacing unit: ${shown(theme == null ? void 0 : theme.spacing, INHERITED_SPACING)}`);
|
|
143
|
+
lines.push(`Nav height: mobile ${shown(theme && readToolbarHeight(theme, 'xs'), INHERITED_TOOLBAR_HEIGHTS.xs)}, ` + `desktop ${shown(theme && readToolbarHeight(theme, 'sm'), INHERITED_TOOLBAR_HEIGHTS.sm)}`);
|
|
144
|
+
const leaves = overrideLeaves(theme);
|
|
145
|
+
if (!leaves.length) {
|
|
146
|
+
lines.push('Component overrides: none.');
|
|
147
|
+
} else {
|
|
148
|
+
lines.push('Component overrides:');
|
|
149
|
+
for (const leaf of leaves.slice(0, AI_JOB_THEME_INVENTORY_LEAVES))lines.push(`- ${leaf}`);
|
|
150
|
+
if (leaves.length > AI_JOB_THEME_INVENTORY_LEAVES) {
|
|
151
|
+
lines.push(`- and ${leaves.length - AI_JOB_THEME_INVENTORY_LEAVES} more`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return lines.join('\n');
|
|
155
|
+
}
|
|
156
|
+
/** The user turn: the mode, the site's theme, its brand colors, and the brief. */ export function aiJobThemePrompt(input) {
|
|
157
|
+
const sections = [
|
|
158
|
+
input.mode === 'create' ? 'Mode: create. Design a complete theme over every control.' : 'Mode: modify. Change only what the brief is about.',
|
|
159
|
+
`Current theme:\n${aiJobThemeInventory(input.theme, input.source)}`
|
|
160
|
+
];
|
|
161
|
+
if (input.brand.length) {
|
|
162
|
+
sections.push(`Brand colors:\n${input.brand.map((color)=>`- ${color.hex} (${AI_THEME_BRAND_SOURCE_WORDS[color.source]})`).join('\n')}`);
|
|
163
|
+
}
|
|
164
|
+
sections.push(`Brief: ${input.brief.slice(0, AI_JOB_BRIEF_MAX_CHARS)}`);
|
|
165
|
+
return sections.join('\n\n');
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* The theme tool's answer held to the editor — the check the doctrine's loop
|
|
169
|
+
* runs on each answer (AGL-2935), which also holds rule 13 on it. Usable when
|
|
170
|
+
* anything in it survives; refused, naming what was refused, when nothing
|
|
171
|
+
* does. A call that proposes no change and refuses nothing is a real answer —
|
|
172
|
+
* the theme already does what the brief asks.
|
|
173
|
+
*/ export const aiJobThemeCheck = (answer)=>{
|
|
174
|
+
const parse = parseAiThemeToolInput(answer);
|
|
175
|
+
const nothingUsable = !parse.changes.length && !parse.components.length && !parse.resetComponents;
|
|
176
|
+
if (!nothingUsable || !parse.dropped.length) return {
|
|
177
|
+
value: parse,
|
|
178
|
+
violations: []
|
|
179
|
+
};
|
|
180
|
+
return {
|
|
181
|
+
value: null,
|
|
182
|
+
violations: parse.dropped.map((message)=>({
|
|
183
|
+
rule: null,
|
|
184
|
+
code: 'theme-control',
|
|
185
|
+
message
|
|
186
|
+
}))
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* The theme step's generation as the doctrine's loop runs it: its cached
|
|
191
|
+
* block, which carries the acceptable-use rules, then this step's
|
|
192
|
+
* instructions; the site's theme in the user turn rather than a site
|
|
193
|
+
* inventory; the strict tool, the ceiling and the check. The eval harness
|
|
194
|
+
* records a theme answer through this same call.
|
|
195
|
+
*/ export function aiJobThemeGeneration(request) {
|
|
196
|
+
return _extends({
|
|
197
|
+
step: 'job.theme',
|
|
198
|
+
model: request.model,
|
|
199
|
+
instructions: AI_JOB_THEME_INSTRUCTIONS,
|
|
200
|
+
messages: [
|
|
201
|
+
{
|
|
202
|
+
role: 'user',
|
|
203
|
+
content: aiJobThemePrompt(request)
|
|
204
|
+
}
|
|
205
|
+
],
|
|
206
|
+
tool: aiThemeTool(),
|
|
207
|
+
maxTokens: aiJobThemeMaxTokens(request.model)
|
|
208
|
+
}, AI_ROUTING_TABLE['job.theme'].thinking ? {
|
|
209
|
+
thinking: AI_ROUTING_TABLE['job.theme'].thinking
|
|
210
|
+
} : {}, AI_ROUTING_TABLE['job.theme'].effort ? {
|
|
211
|
+
effort: AI_ROUTING_TABLE['job.theme'].effort
|
|
212
|
+
} : {}, request.signal ? {
|
|
213
|
+
signal: request.signal
|
|
214
|
+
} : {}, {
|
|
215
|
+
check: aiJobThemeCheck
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
/** The site a theme job changes, read and checked against the job's org. */ async function loadThemeSite(firestore, job) {
|
|
219
|
+
if (!job.hostId) return {
|
|
220
|
+
failure: AI_JOB_THEME_NO_SITE_COPY
|
|
221
|
+
};
|
|
222
|
+
const snapshot = await firestore.collection('hosts').doc(job.hostId).get();
|
|
223
|
+
const host = snapshot.exists ? snapshot.data() : null;
|
|
224
|
+
// The route checks the caller's membership of the org the job is metered
|
|
225
|
+
// against, not that the site it named belongs to that org. A site of some
|
|
226
|
+
// other org is refused here, before anything about it reaches a prompt.
|
|
227
|
+
if (!host || host['orgId'] !== job.orgId) return {
|
|
228
|
+
failure: AI_JOB_THEME_NO_SITE_COPY
|
|
229
|
+
};
|
|
230
|
+
return {
|
|
231
|
+
host,
|
|
232
|
+
theme: resolveSiteTheme(host),
|
|
233
|
+
source: hostThemeSource(host)
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
/** How many edits a proposal makes, for its label. */ function proposalSize(proposal) {
|
|
237
|
+
return proposal.changes.length + proposal.components.length + (proposal.resetComponents ? 1 : 0);
|
|
238
|
+
}
|
|
239
|
+
export const runAiJobThemeStep = async ({ job, signal, firestore, org, modelFor })=>{
|
|
240
|
+
var _ref, _job_hostId;
|
|
241
|
+
if (!firestore) {
|
|
242
|
+
// The machine always hands one in; a runner called without it is a
|
|
243
|
+
// wiring fault, not a customer path.
|
|
244
|
+
throw new Error('the theme step reads the site it changes and was given no Firestore');
|
|
245
|
+
}
|
|
246
|
+
// The model switch's answer for this job (AGL-2942): the creator's pick
|
|
247
|
+
// where the plan, the org restriction and the allotment allowlists allow
|
|
248
|
+
// it, and Auto held to those same lists otherwise. Only a runner called
|
|
249
|
+
// without a resolver asks the routing table directly.
|
|
250
|
+
const model = (_ref = modelFor == null ? void 0 : modelFor('job.theme')) != null ? _ref : aiJobThemeModel();
|
|
251
|
+
const site = await loadThemeSite(firestore, job);
|
|
252
|
+
if ('failure' in site) {
|
|
253
|
+
return {
|
|
254
|
+
outputs: [],
|
|
255
|
+
usage: ZERO_USAGE,
|
|
256
|
+
estCostUsd: 0,
|
|
257
|
+
model,
|
|
258
|
+
stopReason: null,
|
|
259
|
+
failure: site.failure
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
const mode = aiJobThemeMode(job.inputs);
|
|
263
|
+
const brand = await gatherAiThemeBrandInputs({
|
|
264
|
+
firestore,
|
|
265
|
+
org: org != null ? org : null,
|
|
266
|
+
hostId: job.hostId,
|
|
267
|
+
host: site.host,
|
|
268
|
+
brief: job.brief,
|
|
269
|
+
signal
|
|
270
|
+
});
|
|
271
|
+
// A second refused answer ends in this step's own sentence, below.
|
|
272
|
+
const generation = await runValidatedGeneration('theme', aiJobThemeGeneration(_extends({
|
|
273
|
+
brief: job.brief,
|
|
274
|
+
mode,
|
|
275
|
+
theme: site.theme,
|
|
276
|
+
source: site.source,
|
|
277
|
+
brand: brand.colors,
|
|
278
|
+
model
|
|
279
|
+
}, signal ? {
|
|
280
|
+
signal
|
|
281
|
+
} : {})));
|
|
282
|
+
const spent = _extends({
|
|
283
|
+
usage: generation.usage,
|
|
284
|
+
estCostUsd: generation.estCostUsd,
|
|
285
|
+
model: generation.model,
|
|
286
|
+
stopReason: generation.stopReason
|
|
287
|
+
}, generation.effort ? {
|
|
288
|
+
effort: generation.effort
|
|
289
|
+
} : {});
|
|
290
|
+
if (generation.status === 'refused') return _extends({
|
|
291
|
+
outputs: []
|
|
292
|
+
}, spent, {
|
|
293
|
+
refused: true
|
|
294
|
+
});
|
|
295
|
+
if (generation.status === 'needs_input') {
|
|
296
|
+
return _extends({
|
|
297
|
+
outputs: []
|
|
298
|
+
}, spent, {
|
|
299
|
+
failure: AI_JOB_THEME_NO_ANSWER_COPY
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
const answer = generation.value;
|
|
303
|
+
const proposal = buildAiThemeProposal({
|
|
304
|
+
base: site.theme,
|
|
305
|
+
source: site.source,
|
|
306
|
+
mode,
|
|
307
|
+
brief: job.brief,
|
|
308
|
+
summary: answer.summary,
|
|
309
|
+
changes: answer.changes,
|
|
310
|
+
components: answer.components,
|
|
311
|
+
resetComponents: answer.resetComponents,
|
|
312
|
+
dropped: answer.dropped,
|
|
313
|
+
notes: [
|
|
314
|
+
...brand.notes,
|
|
315
|
+
...answer.notes
|
|
316
|
+
]
|
|
317
|
+
});
|
|
318
|
+
const size = proposalSize(proposal);
|
|
319
|
+
const output = {
|
|
320
|
+
resource: 'theme',
|
|
321
|
+
// A proposal has no document of its own; the id names what it is within
|
|
322
|
+
// the job, as a text output's `draft` does.
|
|
323
|
+
id: 'proposal',
|
|
324
|
+
hostId: (_job_hostId = job.hostId) != null ? _job_hostId : null,
|
|
325
|
+
hostSubdomain: typeof site.host['subdomain'] === 'string' ? site.host['subdomain'] : null,
|
|
326
|
+
label: `Theme proposal · ${size} ${size === 1 ? 'change' : 'changes'}`,
|
|
327
|
+
// Through JSON so no `undefined` reaches the document write.
|
|
328
|
+
proposal: JSON.parse(JSON.stringify(proposal))
|
|
329
|
+
};
|
|
330
|
+
return _extends({
|
|
331
|
+
outputs: [
|
|
332
|
+
output
|
|
333
|
+
]
|
|
334
|
+
}, spent);
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
//# sourceMappingURL=ai-job-theme-step.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/jobs/ai-job-theme-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 {\n hostThemeSource,\n resolveSiteTheme,\n type HostThemeSource,\n type ThemeHostDocument,\n} from '@aglyn/aglyn/app-utils/marketplace-theme'\nimport type { HostTheme, HostThemeScheme } from '@aglyn/shared-data-types'\nimport {\n INHERITED_BORDER_RADIUS,\n INHERITED_FONT_FAMILY,\n INHERITED_SPACING,\n INHERITED_TOOLBAR_HEIGHTS,\n inheritedThemeColor,\n} from '@aglyn/shared-ui-theme/util/theme-editor-defaults'\nimport {\n readDarkScheme,\n readFontFamily,\n readThemeColor,\n readToolbarHeight,\n SYSTEM_FONT_VALUE,\n THEME_COLOR_FIELDS,\n THEME_EDITOR_MEDIA_QUERIES,\n} from '@aglyn/shared-ui-theme/util/theme-editor-fields'\nimport type { AiJob, AiJobOutput } from '../model/ai-jobs.types'\nimport {\n buildAiThemeProposal,\n type AiThemeProposal,\n type AiThemeProposalMode,\n} from '../model/ai-theme-proposal'\nimport { AI_ROUTING_TABLE, aiModelForStep } from '../providers/routing'\nimport {\n runValidatedGeneration,\n type AiCustomGenerationInput,\n type AiGenerationCheck,\n} from '../runtime/ai-doctrine'\nimport type { AiSystemBlock, AiUsage } from '../runtime/ai-runtime'\nimport {\n AI_THEME_TOOL_NAME,\n aiThemeTool,\n parseAiThemeToolInput,\n type AiThemeToolParse,\n} from '../tools/ai-theme-tool'\nimport {\n AI_JOB_BRIEF_MAX_CHARS,\n type AiJobStepOutcome,\n type AiJobStepRunner,\n} from './ai-job-text-step'\nimport { AI_JOB_THEME_STEP_BUDGET } from './ai-job-theme-budget'\nimport {\n AI_THEME_BRAND_SOURCE_WORDS,\n gatherAiThemeBrandInputs,\n type AiThemeBrandColor,\n} from './ai-theme-brand-inputs'\n\n/**\n * The `theme` step (AGL-2938): a brief and a site's current theme in, a theme\n * proposal out — every control the theme editor exposes, and nothing else.\n *\n * The step writes nothing to the site. A site's theme is fields on its host\n * document, and writing those is the save the Theme section's editor\n * performs; the step's output is the proposal, which a person puts in the\n * editor, previews against the current theme, and saves or discards.\n *\n * The request is shaped for the cache: the rules and the tool are static and\n * sit in the cached prefix, and everything about this site — its theme, its\n * brand colors, the brief — rides in the user turn. The model answers through\n * one strict tool derived from the editor's own catalog, and the answer is\n * held to that catalog and to the doctrine (a targeted diff, dark values,\n * contrast) before it becomes a proposal.\n */\n\n/**\n * The routing table's answer for `job.theme`: the model the theme step runs on\n * when the machine hands it no `modelFor`.\n */\nexport function aiJobThemeModel(): string {\n return aiModelForStep('job.theme')\n}\n\n/**\n * The output budget, from the routing table. The largest answer the tool\n * accepts — every color in both schemes, the full run of component leaves,\n * the longest summary — is about 2,500 tokens of JSON\n * (`ai-job-theme-step.spec.ts` measures it), and the rest is room for the\n * model to think before it answers.\n */\nexport const AI_JOB_THEME_MAX_TOKENS = AI_ROUTING_TABLE['job.theme'].maxTokens\n\n/**\n * The theme's answer ceiling on the model a job runs (AGL-3035): the most\n * whose worst case — the answer, its re-ask and the brand reads — fits the\n * least time the step registers (`ai-job-theme-budget.ts`), and never more\n * than the routing table's.\n */\nexport function aiJobThemeMaxTokens(model: string): number {\n return AI_JOB_THEME_STEP_BUDGET.maxTokens(model)\n}\n\n/** How many of a site's own component override leaves the prompt lists. */\nexport const AI_JOB_THEME_INVENTORY_LEAVES = 40\n\n/** The customer-safe sentences a failed theme step leaves on the job. */\nexport const AI_JOB_THEME_NO_SITE_COPY =\n 'This theme job names a site this workspace does not have.'\nexport const AI_JOB_THEME_NO_ANSWER_COPY =\n 'The AI could not produce a theme proposal from this brief. Try describing the change differently.'\n\n/**\n * The theme step's own instructions, byte-identical on every request so they\n * cache. The acceptable-use rules are not in them: they belong to the block\n * every generator shares, which the generation call puts ahead of these.\n */\nexport const AI_JOB_THEME_INSTRUCTIONS: AiSystemBlock[] = [\n {\n text:\n 'You change the theme of a website built with a site builder. You are given the ' +\n \"site's current theme — every control its theme editor has, with the value the site \" +\n 'set or the default it inherits — any brand colors that belong to the site, and a ' +\n 'brief from the person who owns it.\\n\\n' +\n `Answer by calling ${AI_THEME_TOOL_NAME} exactly once. A reply in prose cannot be used.\\n\\n` +\n 'Rules:\\n' +\n '- In modify mode, name only the controls the brief is about. Every control you leave ' +\n 'out keeps its current value. \"Warmer\" is about color, not about fonts or corners.\\n' +\n '- In create mode, design a complete theme: the primary, secondary and tertiary ' +\n 'accents, the page background and paper, the text colors, and their dark values.\\n' +\n \"- Colors are hex values on the theme's own tokens. A theme is where the building rules \" +\n 'send every color, so this is the one answer that writes a color as a value. A component ' +\n 'style never carries a literal color; color belongs to the palette.\\n' +\n '- Give every color you change a dark value beside its light value unless the dark ' +\n 'scheme is off. A dark value keeps the hue and reads on a dark background.\\n' +\n '- Keep text readable: body text needs 4.5:1 against the background and the paper, and ' +\n 'the primary color 3:1 against the background.\\n' +\n '- A hex color written in the brief is used exactly as written. When the brief asks to ' +\n 'match the brand, build on the brand colors you are given.\\n' +\n '- Fonts come from the list the tool offers, and numbers stay inside the ranges it ' +\n 'states.\\n' +\n '- Write the summary in the language of the brief.',\n cacheBreakpoint: true,\n },\n]\n\nconst ZERO_USAGE: AiUsage = {\n inputTokens: 0,\n outputTokens: 0,\n cacheReadTokens: 0,\n cacheWriteTokens: 0,\n}\n\n/** `create` when the job asked for a whole design; `modify` otherwise. */\nexport function aiJobThemeMode(inputs: AiJob['inputs'] | undefined): AiThemeProposalMode {\n return inputs?.['mode'] === 'create' ? 'create' : 'modify'\n}\n\nconst SOURCE_WORDS: Record<HostThemeSource, string> = {\n installed:\n \"an installed marketplace theme; a change is stored as the site's own edits on top of it\",\n custom: \"the site's own theme\",\n default: \"the platform's default theme; a change stores only the values it sets\",\n}\n\n/** One value as the inventory shows it: the site's own, or the default it inherits. */\nconst shown = (own: string | number | null | undefined, inherited: string | number | undefined) =>\n own === null || own === undefined ? `${inherited ?? 'unset'} (default)` : `${own} (set)`\n\n/** The site's own component overrides, one bounded line a leaf. */\nfunction overrideLeaves(theme: HostTheme | undefined): string[] {\n const leaves: string[] = []\n const media = Object.fromEntries(\n Object.entries(THEME_EDITOR_MEDIA_QUERIES).map(([name, query]) => [query, name]),\n )\n const text = (value: unknown) => JSON.stringify(value)?.slice(0, 60) ?? ''\n for (const [component, override] of Object.entries(theme?.components ?? {})) {\n for (const [prop, value] of Object.entries(override?.defaultProps ?? {})) {\n leaves.push(`${component} default ${prop} = ${text(value)}`)\n }\n for (const [slot, styles] of Object.entries(override?.styleOverrides ?? {})) {\n if (!styles || typeof styles !== 'object') continue\n for (const [property, value] of Object.entries(styles as Record<string, unknown>)) {\n if (value && typeof value === 'object') {\n for (const [nested, nestedValue] of Object.entries(value as Record<string, unknown>)) {\n leaves.push(\n `${component} ${slot} ${nested} = ${text(nestedValue)} (${media[property] ?? property})`,\n )\n }\n } else {\n leaves.push(`${component} ${slot} ${property} = ${text(value)}`)\n }\n }\n }\n }\n return leaves\n}\n\n/**\n * The site's theme as the model reads it: compact, one control a line, each\n * value marked as the site's own or the default it inherits, so \"make the\n * background warmer\" starts from the color the visitor actually sees.\n */\nexport function aiJobThemeInventory(theme: HostTheme | undefined, source: HostThemeSource): string {\n const lines = [`Source: ${SOURCE_WORDS[source]}.`, `Dark scheme: ${readDarkScheme(theme)}.`]\n lines.push('Colors, light | dark:')\n for (const { token } of THEME_COLOR_FIELDS) {\n const value = (scheme: HostThemeScheme) =>\n shown(readThemeColor(theme, scheme, token), inheritedThemeColor(scheme, token))\n lines.push(`- ${token}: ${value('light')} | ${value('dark')}`)\n }\n const font = readFontFamily(theme)\n lines.push(`Font family: ${shown(font === SYSTEM_FONT_VALUE ? null : font, INHERITED_FONT_FAMILY)}`)\n lines.push(`Border radius: ${shown(theme?.shape?.borderRadius, INHERITED_BORDER_RADIUS)}`)\n lines.push(`Spacing unit: ${shown(theme?.spacing, INHERITED_SPACING)}`)\n lines.push(\n `Nav height: mobile ${shown(theme && readToolbarHeight(theme, 'xs'), INHERITED_TOOLBAR_HEIGHTS.xs)}, ` +\n `desktop ${shown(theme && readToolbarHeight(theme, 'sm'), INHERITED_TOOLBAR_HEIGHTS.sm)}`,\n )\n const leaves = overrideLeaves(theme)\n if (!leaves.length) {\n lines.push('Component overrides: none.')\n } else {\n lines.push('Component overrides:')\n for (const leaf of leaves.slice(0, AI_JOB_THEME_INVENTORY_LEAVES)) lines.push(`- ${leaf}`)\n if (leaves.length > AI_JOB_THEME_INVENTORY_LEAVES) {\n lines.push(`- and ${leaves.length - AI_JOB_THEME_INVENTORY_LEAVES} more`)\n }\n }\n return lines.join('\\n')\n}\n\n/** The user turn: the mode, the site's theme, its brand colors, and the brief. */\nexport function aiJobThemePrompt(input: {\n brief: string\n mode: AiThemeProposalMode\n theme: HostTheme | undefined\n source: HostThemeSource\n brand: readonly AiThemeBrandColor[]\n}): string {\n const sections = [\n input.mode === 'create'\n ? 'Mode: create. Design a complete theme over every control.'\n : 'Mode: modify. Change only what the brief is about.',\n `Current theme:\\n${aiJobThemeInventory(input.theme, input.source)}`,\n ]\n if (input.brand.length) {\n sections.push(\n `Brand colors:\\n${input.brand\n .map((color) => `- ${color.hex} (${AI_THEME_BRAND_SOURCE_WORDS[color.source]})`)\n .join('\\n')}`,\n )\n }\n sections.push(`Brief: ${input.brief.slice(0, AI_JOB_BRIEF_MAX_CHARS)}`)\n return sections.join('\\n\\n')\n}\n\n/**\n * The theme tool's answer held to the editor — the check the doctrine's loop\n * runs on each answer (AGL-2935), which also holds rule 13 on it. Usable when\n * anything in it survives; refused, naming what was refused, when nothing\n * does. A call that proposes no change and refuses nothing is a real answer —\n * the theme already does what the brief asks.\n */\nexport const aiJobThemeCheck: AiGenerationCheck<AiThemeToolParse> = (answer) => {\n const parse = parseAiThemeToolInput(answer)\n const nothingUsable =\n !parse.changes.length && !parse.components.length && !parse.resetComponents\n if (!nothingUsable || !parse.dropped.length) return { value: parse, violations: [] }\n return {\n value: null,\n violations: parse.dropped.map((message) => ({ rule: null, code: 'theme-control', message })),\n }\n}\n\n/** What a theme generation is asked from, once the site and its brand have been read. */\nexport interface AiJobThemeRequest {\n brief: string\n mode: AiThemeProposalMode\n theme: HostTheme | undefined\n source: HostThemeSource\n brand: readonly AiThemeBrandColor[]\n model: string\n signal?: AbortSignal\n}\n\n/**\n * The theme step's generation as the doctrine's loop runs it: its cached\n * block, which carries the acceptable-use rules, then this step's\n * instructions; the site's theme in the user turn rather than a site\n * inventory; the strict tool, the ceiling and the check. The eval harness\n * records a theme answer through this same call.\n */\nexport function aiJobThemeGeneration(\n request: AiJobThemeRequest,\n): AiCustomGenerationInput<AiThemeToolParse> {\n return {\n step: 'job.theme',\n model: request.model,\n instructions: AI_JOB_THEME_INSTRUCTIONS,\n messages: [{ role: 'user', content: aiJobThemePrompt(request) }],\n tool: aiThemeTool(),\n maxTokens: aiJobThemeMaxTokens(request.model),\n ...(AI_ROUTING_TABLE['job.theme'].thinking ? { thinking: AI_ROUTING_TABLE['job.theme'].thinking } : {}),\n ...(AI_ROUTING_TABLE['job.theme'].effort ? { effort: AI_ROUTING_TABLE['job.theme'].effort } : {}),\n ...(request.signal ? { signal: request.signal } : {}),\n check: aiJobThemeCheck,\n }\n}\n\n/** The site a theme job changes, read and checked against the job's org. */\nasync function loadThemeSite(\n firestore: FirebaseFirestore.Firestore,\n job: AiJob,\n): Promise<\n | { host: ThemeHostDocument & Record<string, unknown>; theme: HostTheme | undefined; source: HostThemeSource }\n | { failure: string }\n> {\n if (!job.hostId) return { failure: AI_JOB_THEME_NO_SITE_COPY }\n const snapshot = await firestore.collection('hosts').doc(job.hostId).get()\n const host = snapshot.exists\n ? (snapshot.data() as ThemeHostDocument & Record<string, unknown>)\n : null\n // The route checks the caller's membership of the org the job is metered\n // against, not that the site it named belongs to that org. A site of some\n // other org is refused here, before anything about it reaches a prompt.\n if (!host || host['orgId'] !== job.orgId) return { failure: AI_JOB_THEME_NO_SITE_COPY }\n return { host, theme: resolveSiteTheme(host), source: hostThemeSource(host) }\n}\n\n/** How many edits a proposal makes, for its label. */\nfunction proposalSize(proposal: AiThemeProposal): number {\n return proposal.changes.length + proposal.components.length + (proposal.resetComponents ? 1 : 0)\n}\n\nexport const runAiJobThemeStep: AiJobStepRunner = async ({\n job,\n signal,\n firestore,\n org,\n modelFor,\n}) => {\n if (!firestore) {\n // The machine always hands one in; a runner called without it is a\n // wiring fault, not a customer path.\n throw new Error('the theme step reads the site it changes and was given no Firestore')\n }\n // The model switch's answer for this job (AGL-2942): the creator's pick\n // where the plan, the org restriction and the allotment allowlists allow\n // it, and Auto held to those same lists otherwise. Only a runner called\n // without a resolver asks the routing table directly.\n const model = modelFor?.('job.theme') ?? aiJobThemeModel()\n const site = await loadThemeSite(firestore, job)\n if ('failure' in site) {\n return {\n outputs: [],\n usage: ZERO_USAGE,\n estCostUsd: 0,\n model,\n stopReason: null,\n failure: site.failure,\n }\n }\n const mode = aiJobThemeMode(job.inputs)\n const brand = await gatherAiThemeBrandInputs({\n firestore,\n org: org ?? null,\n hostId: job.hostId as string,\n host: site.host,\n brief: job.brief,\n signal,\n })\n // A second refused answer ends in this step's own sentence, below.\n const generation = await runValidatedGeneration(\n 'theme',\n aiJobThemeGeneration({\n brief: job.brief,\n mode,\n theme: site.theme,\n source: site.source,\n brand: brand.colors,\n model,\n ...(signal ? { signal } : {}),\n }),\n )\n const spent: Pick<AiJobStepOutcome, 'usage' | 'estCostUsd' | 'model' | 'stopReason' | 'effort'> = {\n usage: generation.usage,\n estCostUsd: generation.estCostUsd,\n model: generation.model,\n stopReason: generation.stopReason,\n ...(generation.effort ? { effort: generation.effort } : {}),\n }\n if (generation.status === 'refused') return { outputs: [], ...spent, refused: true }\n if (generation.status === 'needs_input') {\n return { outputs: [], ...spent, failure: AI_JOB_THEME_NO_ANSWER_COPY }\n }\n\n const answer = generation.value\n const proposal = buildAiThemeProposal({\n base: site.theme,\n source: site.source,\n mode,\n brief: job.brief,\n summary: answer.summary,\n changes: answer.changes,\n components: answer.components,\n resetComponents: answer.resetComponents,\n dropped: answer.dropped,\n notes: [...brand.notes, ...answer.notes],\n })\n const size = proposalSize(proposal)\n const output: AiJobOutput = {\n resource: 'theme',\n // A proposal has no document of its own; the id names what it is within\n // the job, as a text output's `draft` does.\n id: 'proposal',\n hostId: job.hostId ?? null,\n hostSubdomain: typeof site.host['subdomain'] === 'string' ? site.host['subdomain'] : null,\n label: `Theme proposal · ${size} ${size === 1 ? 'change' : 'changes'}`,\n // Through JSON so no `undefined` reaches the document write.\n proposal: JSON.parse(JSON.stringify(proposal)) as Record<string, unknown>,\n }\n return { outputs: [output], ...spent }\n}\n"],"names":["hostThemeSource","resolveSiteTheme","INHERITED_BORDER_RADIUS","INHERITED_FONT_FAMILY","INHERITED_SPACING","INHERITED_TOOLBAR_HEIGHTS","inheritedThemeColor","readDarkScheme","readFontFamily","readThemeColor","readToolbarHeight","SYSTEM_FONT_VALUE","THEME_COLOR_FIELDS","THEME_EDITOR_MEDIA_QUERIES","buildAiThemeProposal","AI_ROUTING_TABLE","aiModelForStep","runValidatedGeneration","AI_THEME_TOOL_NAME","aiThemeTool","parseAiThemeToolInput","AI_JOB_BRIEF_MAX_CHARS","AI_JOB_THEME_STEP_BUDGET","AI_THEME_BRAND_SOURCE_WORDS","gatherAiThemeBrandInputs","aiJobThemeModel","AI_JOB_THEME_MAX_TOKENS","maxTokens","aiJobThemeMaxTokens","model","AI_JOB_THEME_INVENTORY_LEAVES","AI_JOB_THEME_NO_SITE_COPY","AI_JOB_THEME_NO_ANSWER_COPY","AI_JOB_THEME_INSTRUCTIONS","text","cacheBreakpoint","ZERO_USAGE","inputTokens","outputTokens","cacheReadTokens","cacheWriteTokens","aiJobThemeMode","inputs","SOURCE_WORDS","installed","custom","default","shown","own","inherited","undefined","overrideLeaves","theme","leaves","media","Object","fromEntries","entries","map","name","query","value","JSON","stringify","slice","component","override","components","prop","defaultProps","push","slot","styles","styleOverrides","property","nested","nestedValue","aiJobThemeInventory","source","lines","token","scheme","font","shape","borderRadius","spacing","xs","sm","length","leaf","join","aiJobThemePrompt","input","sections","mode","brand","color","hex","brief","aiJobThemeCheck","answer","parse","nothingUsable","changes","resetComponents","dropped","violations","message","rule","code","aiJobThemeGeneration","request","step","instructions","messages","role","content","tool","thinking","effort","signal","check","loadThemeSite","firestore","job","hostId","failure","snapshot","collection","doc","get","host","exists","data","orgId","proposalSize","proposal","runAiJobThemeStep","org","modelFor","Error","site","outputs","usage","estCostUsd","stopReason","generation","colors","spent","status","refused","base","summary","notes","size","output","resource","id","hostSubdomain","label"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,eAAe,EACfC,gBAAgB,QAGX,2CAA0C;AAEjD,SACEC,uBAAuB,EACvBC,qBAAqB,EACrBC,iBAAiB,EACjBC,yBAAyB,EACzBC,mBAAmB,QACd,oDAAmD;AAC1D,SACEC,cAAc,EACdC,cAAc,EACdC,cAAc,EACdC,iBAAiB,EACjBC,iBAAiB,EACjBC,kBAAkB,EAClBC,0BAA0B,QACrB,kDAAiD;AAExD,SACEC,oBAAoB,QAGf,gCAA4B;AACnC,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,0BAAsB;AACvE,SACEC,sBAAsB,QAGjB,4BAAwB;AAE/B,SACEC,kBAAkB,EAClBC,WAAW,EACXC,qBAAqB,QAEhB,4BAAwB;AAC/B,SACEC,sBAAsB,QAGjB,wBAAoB;AAC3B,SAASC,wBAAwB,QAAQ,2BAAuB;AAChE,SACEC,2BAA2B,EAC3BC,wBAAwB,QAEnB,6BAAyB;AAEhC;;;;;;;;;;;;;;;CAeC,GAED;;;CAGC,GACD,OAAO,SAASC;IACd,OAAOT,eAAe;AACx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AEP,SAAS,EAAE;OAAKM;QAAOE,SAAS;;IAC9E,IAAIJ,WAAWG,MAAM,KAAK,eAAe;QACvC,OAAO;YAAEP,SAAS,EAAE;WAAKM;YAAOtB,SAAS9F;;IAC3C;IAEA,MAAMoE,SAAS8C,WAAWrF,KAAK;IAC/B,MAAM2E,WAAW1H,qBAAqB;QACpCyI,MAAMV,KAAKzF,KAAK;QAChB0B,QAAQ+D,KAAK/D,MAAM;QACnBgB;QACAI,OAAO0B,IAAI1B,KAAK;QAChBsD,SAASpD,OAAOoD,OAAO;QACvBjD,SAASH,OAAOG,OAAO;QACvBpC,YAAYiC,OAAOjC,UAAU;QAC7BqC,iBAAiBJ,OAAOI,eAAe;QACvCC,SAASL,OAAOK,OAAO;QACvBgD,OAAO;eAAI1D,MAAM0D,KAAK;eAAKrD,OAAOqD,KAAK;SAAC;IAC1C;IACA,MAAMC,OAAOnB,aAAaC;IAC1B,MAAMmB,SAAsB;QAC1BC,UAAU;QACV,wEAAwE;QACxE,4CAA4C;QAC5CC,IAAI;QACJhC,MAAM,GAAED,cAAAA,IAAIC,MAAM,YAAVD,cAAc;QACtBkC,eAAe,OAAOjB,KAAKV,IAAI,CAAC,YAAY,KAAK,WAAWU,KAAKV,IAAI,CAAC,YAAY,GAAG;QACrF4B,OAAO,CAAC,iBAAiB,EAAEL,KAAK,CAAC,EAAEA,SAAS,IAAI,WAAW,WAAW;QACtE,6DAA6D;QAC7DlB,UAAU1E,KAAKuC,KAAK,CAACvC,KAAKC,SAAS,CAACyE;IACtC;IACA,OAAO;QAAEM,SAAS;YAACa;SAAO;OAAKP;AACjC,EAAC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { type AiAutomationRecords } from '../model/ai-automation-draft';
|
|
18
|
+
import { type AiAutomationCapabilities } from '../model/ai-workflow-job';
|
|
19
|
+
import { type AiCustomGenerationInput } from '../runtime/ai-doctrine';
|
|
20
|
+
import type { AiSystemBlock } from '../runtime/ai-runtime';
|
|
21
|
+
import { type AiAutomationAnswer, type AiWorkflowExplanation } from '../tools/ai-workflow-tool';
|
|
22
|
+
import { type AiJobAdmission } from './ai-job-admission';
|
|
23
|
+
import { type AiPluginDraftWriterLookup } from './ai-job-plugin-drafts';
|
|
24
|
+
import { type AiJobStepRunner } from './ai-job-text-step';
|
|
25
|
+
import { readAiAutomationRecords, readAiWorkflowFunctions, readAiWorkflowRun, readAiWorkflowTarget } from './ai-workflow-records';
|
|
26
|
+
/**
|
|
27
|
+
* The `workflow` step (AGL-2919): an automation drafted from a description,
|
|
28
|
+
* or a saved automation explained.
|
|
29
|
+
*
|
|
30
|
+
* ## Drafting
|
|
31
|
+
*
|
|
32
|
+
* The model is shown the platform's automation vocabulary — every trigger with
|
|
33
|
+
* the fields it carries, every step with the fields it takes — in a cached
|
|
34
|
+
* block, and in the user turn what this workspace can run, the site's forms
|
|
35
|
+
* and datasets by name, and the description. It answers through
|
|
36
|
+
* `submit_automation`, and the answer is held to the vocabulary and to what
|
|
37
|
+
* the workspace can run before anything is written.
|
|
38
|
+
*
|
|
39
|
+
* A record the description names — a list, a campaign, a workflow, a webhook,
|
|
40
|
+
* a dataset, a form, a deal stage — is answered in the description's WORDS,
|
|
41
|
+
* and looked up among the site's records in code, after the answer
|
|
42
|
+
* (`model/ai-automation-draft.ts`). The model is never shown the site's lists,
|
|
43
|
+
* campaigns, workflows, webhooks or pipelines. Words that name no record, or
|
|
44
|
+
* more than one, are kept as a placeholder the person fills in.
|
|
45
|
+
*
|
|
46
|
+
* The automation is written through the workflows plugin's draft writer —
|
|
47
|
+
* that plugin's stored shape, validator, role, plan and cap — keyed by the
|
|
48
|
+
* job's id, and it is written OFF. A run cut off after the write finds its
|
|
49
|
+
* draft and spends nothing.
|
|
50
|
+
*
|
|
51
|
+
* ## Explaining
|
|
52
|
+
*
|
|
53
|
+
* The model is shown an outline of the saved automation, and for a failed run
|
|
54
|
+
* what the run history recorded about it (`model/ai-automation-outline.ts`):
|
|
55
|
+
* never the stored documents, never an email address, never a run's event
|
|
56
|
+
* payload. It answers through `submit_explanation`, which becomes a `text`
|
|
57
|
+
* output. Nothing is changed.
|
|
58
|
+
*/
|
|
59
|
+
/** The longest an explanation or a draft's generation may take reading the site first. */
|
|
60
|
+
export declare const AI_WORKFLOW_RECORDS_READ_MS = 4000;
|
|
61
|
+
/**
|
|
62
|
+
* The step's time (AGL-3035): its answer and its re-ask at the routing
|
|
63
|
+
* table's `job.workflow` ceiling on the tier the step is served from. It sends
|
|
64
|
+
* no site inventory block, so it makes no lookup; its own reads — the records
|
|
65
|
+
* a draft is matched against, or the automation and run an explanation
|
|
66
|
+
* reads — are the declared `AI_WORKFLOW_RECORDS_READ_MS`.
|
|
67
|
+
*/
|
|
68
|
+
export declare const AI_JOB_WORKFLOW_STEP_BUDGET: import("./ai-job-budget").AiJobStepBudget;
|
|
69
|
+
/** The least time one workflow step needs before it starts. */
|
|
70
|
+
export declare const AI_JOB_WORKFLOW_STEP_MINIMUM_MS: number;
|
|
71
|
+
/** The routing table's answer for `job.workflow`. */
|
|
72
|
+
export declare function aiJobWorkflowModel(): string;
|
|
73
|
+
/** How many forms and datasets the user turn lists, and how many fields a form. */
|
|
74
|
+
export declare const AI_WORKFLOW_FORMS_LISTED = 40;
|
|
75
|
+
export declare const AI_WORKFLOW_FORM_FIELDS_LISTED = 20;
|
|
76
|
+
export declare const AI_WORKFLOW_DATASETS_LISTED = 40;
|
|
77
|
+
/**
|
|
78
|
+
* The drafting instructions, byte-identical on every request so they cache.
|
|
79
|
+
* Built from the platform's own trigger and step catalogs, so the vocabulary
|
|
80
|
+
* the model is shown is the vocabulary the answer is held to.
|
|
81
|
+
*/
|
|
82
|
+
export declare const AI_JOB_WORKFLOW_DRAFT_INSTRUCTIONS: readonly AiSystemBlock[];
|
|
83
|
+
/** The explaining instructions, byte-identical on every request so they cache. */
|
|
84
|
+
export declare const AI_JOB_WORKFLOW_EXPLAIN_INSTRUCTIONS: readonly AiSystemBlock[];
|
|
85
|
+
/** What a draft is asked from: the workspace's reach, the site's forms and datasets, and the brief. */
|
|
86
|
+
export declare function aiJobWorkflowDraftPrompt(input: {
|
|
87
|
+
brief: string;
|
|
88
|
+
capabilities: AiAutomationCapabilities;
|
|
89
|
+
records: Pick<AiAutomationRecords, 'forms' | 'datasets'>;
|
|
90
|
+
}): string;
|
|
91
|
+
/** What an explanation is asked from: the mode, the outlines, and the member's question. */
|
|
92
|
+
export declare function aiJobWorkflowExplainPrompt(input: {
|
|
93
|
+
brief: string;
|
|
94
|
+
mode: 'explain' | 'diagnose';
|
|
95
|
+
outline: string;
|
|
96
|
+
run: string | null;
|
|
97
|
+
}): string;
|
|
98
|
+
/** The draft generation as the doctrine's loop runs it; the eval harness records one through this same call. */
|
|
99
|
+
export declare function aiJobWorkflowDraftGeneration(request: {
|
|
100
|
+
brief: string;
|
|
101
|
+
capabilities: AiAutomationCapabilities;
|
|
102
|
+
records: Pick<AiAutomationRecords, 'forms' | 'datasets'>;
|
|
103
|
+
model: string;
|
|
104
|
+
signal?: AbortSignal;
|
|
105
|
+
}): AiCustomGenerationInput<AiAutomationAnswer>;
|
|
106
|
+
/** The explanation generation as the doctrine's loop runs it. */
|
|
107
|
+
export declare function aiJobWorkflowExplainGeneration(request: {
|
|
108
|
+
brief: string;
|
|
109
|
+
mode: 'explain' | 'diagnose';
|
|
110
|
+
outline: string;
|
|
111
|
+
run: string | null;
|
|
112
|
+
model: string;
|
|
113
|
+
signal?: AbortSignal;
|
|
114
|
+
}): AiCustomGenerationInput<AiWorkflowExplanation>;
|
|
115
|
+
export interface AiJobWorkflowStepDeps {
|
|
116
|
+
/** How the automation draft writer is found; the core's registry otherwise. */
|
|
117
|
+
writerFor?: AiPluginDraftWriterLookup;
|
|
118
|
+
readRecords?: typeof readAiAutomationRecords;
|
|
119
|
+
readTarget?: typeof readAiWorkflowTarget;
|
|
120
|
+
readRun?: typeof readAiWorkflowRun;
|
|
121
|
+
readFunctions?: typeof readAiWorkflowFunctions;
|
|
122
|
+
}
|
|
123
|
+
export declare function createAiJobWorkflowStep(deps?: AiJobWorkflowStepDeps): AiJobStepRunner;
|
|
124
|
+
export declare const runAiJobWorkflowStep: AiJobStepRunner;
|
|
125
|
+
export interface AiWorkflowJobAdmissionDeps {
|
|
126
|
+
readTarget?: typeof readAiWorkflowTarget;
|
|
127
|
+
readRun?: typeof readAiWorkflowRun;
|
|
128
|
+
writerFor?: AiPluginDraftWriterLookup;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* A workflow job is admitted for a site of its org with the Automation plugin
|
|
132
|
+
* on. A draft also needs the draft writer and the member's room and role in
|
|
133
|
+
* its own words; an explanation needs the automation it names to exist, and
|
|
134
|
+
* a run's explanation a failed run of it.
|
|
135
|
+
*/
|
|
136
|
+
export declare function createAiWorkflowJobAdmission(deps?: AiWorkflowJobAdmissionDeps): AiJobAdmission;
|
|
137
|
+
export declare const aiWorkflowJobAdmission: AiJobAdmission;
|
|
138
|
+
/** Registers the workflow step and the check a workflow job passes before it is created or resumed. */
|
|
139
|
+
export declare function registerAiWorkflowJob(): void;
|