@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,416 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ import { assistCreditsFromUsd } from "@aglyn/aglyn/app-utils/assist-credits";
|
|
17
|
+
import { AI_MODEL_CATALOG, AI_STEP_TIERS, aiCatalogEntry, aiBilledRatesForModel, estimateAiBilledUsd } from "./catalog.js";
|
|
18
|
+
import { resolveAiRoute } from "./routing.js";
|
|
19
|
+
/**
|
|
20
|
+
* THE MODEL SWITCH (AGL-2942): what a person may pick, what "Auto" means,
|
|
21
|
+
* and what a pick costs.
|
|
22
|
+
*
|
|
23
|
+
* ## Auto is the routing table
|
|
24
|
+
*
|
|
25
|
+
* A request that names no model — or names one it may not have — runs on
|
|
26
|
+
* `resolveAiRoute(kind)`, the table that maps a step kind to a catalog model
|
|
27
|
+
* (AGL-2937). Picking a model is an override of that one row for one request,
|
|
28
|
+
* never a second table.
|
|
29
|
+
*
|
|
30
|
+
* ## Three bounds, one intersection
|
|
31
|
+
*
|
|
32
|
+
* A manual pick must be served by the active provider, in a tier the org's
|
|
33
|
+
* plan offers (`AI_PLAN_MODEL_TIERS`), on the org's own restriction when it
|
|
34
|
+
* set one, and on the allotment allowlists that apply to the request. The
|
|
35
|
+
* two allowlists bound Auto too: when the routing table's answer is not on
|
|
36
|
+
* them, Auto runs on the allowed model of the same tier, else the cheapest
|
|
37
|
+
* allowed one. The plan bounds only a pick — Auto is the platform's choice,
|
|
38
|
+
* made for the step, and a plan never makes it worse.
|
|
39
|
+
*
|
|
40
|
+
* An allowlist that leaves nothing this deployment serves is not a way to
|
|
41
|
+
* switch AI off by mistake: the choice falls back to the routing table, and
|
|
42
|
+
* the permission keys are how AI is switched off on purpose.
|
|
43
|
+
*
|
|
44
|
+
* ## The price beside each option
|
|
45
|
+
*
|
|
46
|
+
* Credits per typical request at each model's list rates, over the step's
|
|
47
|
+
* measured median exchange when the workspace has enough of them, and over
|
|
48
|
+
* `AI_STEP_NOMINAL_USAGE` until it does — with the multiple of what Auto
|
|
49
|
+
* would cost for the same request. Every figure is credits, never dollars.
|
|
50
|
+
*/ /** The value a request sends for "let the platform route it". */ export const AI_MODEL_AUTO = 'auto';
|
|
51
|
+
/**
|
|
52
|
+
* The catalog tiers a MANUAL pick may name, per plan. Free runs on Auto only:
|
|
53
|
+
* its taste is a wall, and a pick there would spend the account's credits at
|
|
54
|
+
* a rate nobody chose on purpose. The dearest tier opens from Scale up, where
|
|
55
|
+
* the band is large enough that a slower, deeper model is a real choice
|
|
56
|
+
* rather than a fast way to end the month.
|
|
57
|
+
*/ export const AI_PLAN_MODEL_TIERS = {
|
|
58
|
+
free: [],
|
|
59
|
+
starter: [
|
|
60
|
+
'fast',
|
|
61
|
+
'balanced'
|
|
62
|
+
],
|
|
63
|
+
pro: [
|
|
64
|
+
'fast',
|
|
65
|
+
'balanced'
|
|
66
|
+
],
|
|
67
|
+
business: [
|
|
68
|
+
'fast',
|
|
69
|
+
'balanced'
|
|
70
|
+
],
|
|
71
|
+
scale: [
|
|
72
|
+
'fast',
|
|
73
|
+
'balanced',
|
|
74
|
+
'deep'
|
|
75
|
+
],
|
|
76
|
+
advanced: [
|
|
77
|
+
'fast',
|
|
78
|
+
'balanced',
|
|
79
|
+
'deep'
|
|
80
|
+
],
|
|
81
|
+
agency: [
|
|
82
|
+
'fast',
|
|
83
|
+
'balanced',
|
|
84
|
+
'deep'
|
|
85
|
+
],
|
|
86
|
+
enterprise: [
|
|
87
|
+
'fast',
|
|
88
|
+
'balanced',
|
|
89
|
+
'deep'
|
|
90
|
+
]
|
|
91
|
+
};
|
|
92
|
+
/** The plans whose admins may restrict the model set org-wide. */ export const AI_MODEL_RESTRICTION_PLANS = [
|
|
93
|
+
'agency',
|
|
94
|
+
'enterprise'
|
|
95
|
+
];
|
|
96
|
+
/**
|
|
97
|
+
* A typical exchange per step kind, before a workspace has measured one: the
|
|
98
|
+
* doors' own prompt sizes and output ceilings, read conservatively. Replaced
|
|
99
|
+
* by the workspace's measured median as soon as `aiMedianUsage` has enough
|
|
100
|
+
* samples, and only ever used for the price beside an option.
|
|
101
|
+
*/ export const AI_STEP_NOMINAL_USAGE = {
|
|
102
|
+
'assist.chat': {
|
|
103
|
+
inputTokens: 900,
|
|
104
|
+
outputTokens: 450,
|
|
105
|
+
cacheReadTokens: 1050,
|
|
106
|
+
cacheWriteTokens: 0
|
|
107
|
+
},
|
|
108
|
+
'copy.element': {
|
|
109
|
+
inputTokens: 350,
|
|
110
|
+
outputTokens: 120,
|
|
111
|
+
cacheReadTokens: 0,
|
|
112
|
+
cacheWriteTokens: 0
|
|
113
|
+
},
|
|
114
|
+
'copy.section': {
|
|
115
|
+
inputTokens: 700,
|
|
116
|
+
outputTokens: 1400,
|
|
117
|
+
cacheReadTokens: 0,
|
|
118
|
+
cacheWriteTokens: 0
|
|
119
|
+
},
|
|
120
|
+
'copy.blog': {
|
|
121
|
+
inputTokens: 600,
|
|
122
|
+
outputTokens: 1100,
|
|
123
|
+
cacheReadTokens: 0,
|
|
124
|
+
cacheWriteTokens: 0
|
|
125
|
+
},
|
|
126
|
+
'generate.section': {
|
|
127
|
+
inputTokens: 700,
|
|
128
|
+
outputTokens: 1400,
|
|
129
|
+
cacheReadTokens: 0,
|
|
130
|
+
cacheWriteTokens: 0
|
|
131
|
+
},
|
|
132
|
+
// The text step's rules are about 500 characters — far under the balanced
|
|
133
|
+
// tier's cacheable minimum, so they are billed as input every time rather
|
|
134
|
+
// than read from a cache (`runtime/ai-prompt-cache.spec.ts` measures it).
|
|
135
|
+
'job.text': {
|
|
136
|
+
inputTokens: 450,
|
|
137
|
+
outputTokens: 500,
|
|
138
|
+
cacheReadTokens: 0,
|
|
139
|
+
cacheWriteTokens: 0
|
|
140
|
+
},
|
|
141
|
+
// The theme step: the tool's schema and both system blocks (about 7,500
|
|
142
|
+
// characters) are the cached prefix, the site's inventory and the brief ride
|
|
143
|
+
// uncached, and a full-palette answer is about 1,300 characters of JSON with
|
|
144
|
+
// as much again to think in.
|
|
145
|
+
'job.theme': {
|
|
146
|
+
inputTokens: 500,
|
|
147
|
+
outputTokens: 850,
|
|
148
|
+
cacheReadTokens: 2500,
|
|
149
|
+
cacheWriteTokens: 0
|
|
150
|
+
},
|
|
151
|
+
// The plan step: the tool's schema, the doctrine and the plan instructions
|
|
152
|
+
// (about 10,000 characters) are the cached prefix, the site inventory and the
|
|
153
|
+
// brief ride uncached, and a plan answer is about 600 characters of JSON with
|
|
154
|
+
// as much again to think in.
|
|
155
|
+
'job.plan': {
|
|
156
|
+
inputTokens: 500,
|
|
157
|
+
outputTokens: 400,
|
|
158
|
+
cacheReadTokens: 3600,
|
|
159
|
+
cacheWriteTokens: 0
|
|
160
|
+
},
|
|
161
|
+
// The component step: the doctrine, the component instructions, the
|
|
162
|
+
// component surface's catalog and the tool are the cached prefix, the site
|
|
163
|
+
// inventory, the brief and the confirmed plan ride uncached, and a card-sized
|
|
164
|
+
// answer — its tree and declared props as JSON — is about 1,700 characters.
|
|
165
|
+
// The component step's spec measures the prefix and the answer against this.
|
|
166
|
+
'job.component': {
|
|
167
|
+
inputTokens: 700,
|
|
168
|
+
outputTokens: 600,
|
|
169
|
+
cacheReadTokens: 5800,
|
|
170
|
+
cacheWriteTokens: 0
|
|
171
|
+
},
|
|
172
|
+
// The CRM step's exchange (AGL-2917). NOTHING is cached: the step runs on
|
|
173
|
+
// the fast tier, whose cacheable minimum is far above what its prompt
|
|
174
|
+
// reaches — the doctrine's field rules, the CRM rules and the tool come to
|
|
175
|
+
// 650 to 913 tokens, as `runtime/ai-prompt-cache.spec.ts` measures — so
|
|
176
|
+
// every byte is billed as input. A record's facts ride with them, a
|
|
177
|
+
// timeline cut to its newest twelve entries, and the typical answer is a
|
|
178
|
+
// summary and a next step of a few sentences, with no thinking.
|
|
179
|
+
'job.crm': {
|
|
180
|
+
inputTokens: 1800,
|
|
181
|
+
outputTokens: 250,
|
|
182
|
+
cacheReadTokens: 0,
|
|
183
|
+
cacheWriteTokens: 0
|
|
184
|
+
},
|
|
185
|
+
'job.layout': {
|
|
186
|
+
inputTokens: 700,
|
|
187
|
+
outputTokens: 1000,
|
|
188
|
+
cacheReadTokens: 5600,
|
|
189
|
+
cacheWriteTokens: 0
|
|
190
|
+
},
|
|
191
|
+
'job.template': {
|
|
192
|
+
inputTokens: 1200,
|
|
193
|
+
outputTokens: 700,
|
|
194
|
+
cacheReadTokens: 6400,
|
|
195
|
+
cacheWriteTokens: 0
|
|
196
|
+
},
|
|
197
|
+
// One page section's exchange (AGL-2907), from the modules' own text: the
|
|
198
|
+
// doctrine (6,281 characters), the page instructions (1,524), the screen
|
|
199
|
+
// palette catalog (8,353) and the section tool (484) are the cached prefix;
|
|
200
|
+
// the site inventory (711 on the median golden site), the brief, the plan
|
|
201
|
+
// and the section line ride uncached; and a golden section answer is 901
|
|
202
|
+
// characters at the median, asked for with no thinking.
|
|
203
|
+
'job.page': {
|
|
204
|
+
inputTokens: 600,
|
|
205
|
+
outputTokens: 300,
|
|
206
|
+
cacheReadTokens: 4400,
|
|
207
|
+
cacheWriteTokens: 0
|
|
208
|
+
},
|
|
209
|
+
// One product's copy (AGL-2916), the exchange a bulk job makes once a
|
|
210
|
+
// product: the doctrine, the copy rules and the tool (about 9,500 characters)
|
|
211
|
+
// are the cached prefix; the product's facts, the site's categories and a
|
|
212
|
+
// photo at most 768 pixels on its long edge (about 790 tokens) ride
|
|
213
|
+
// uncached; and the answer is a description with its search listing, tags,
|
|
214
|
+
// categories and option names, about 1,300 characters of JSON.
|
|
215
|
+
'job.products': {
|
|
216
|
+
inputTokens: 1500,
|
|
217
|
+
outputTokens: 450,
|
|
218
|
+
cacheReadTokens: 2400,
|
|
219
|
+
cacheWriteTokens: 0
|
|
220
|
+
},
|
|
221
|
+
// The SEO step's listing exchange, which a page's or a product's listing is
|
|
222
|
+
// exactly one of. NOTHING is cached here, whatever the breakpoints say: the
|
|
223
|
+
// step runs on the fast tier, whose cacheable minimum is four times what
|
|
224
|
+
// this prompt reaches, so every static byte is billed as input on every
|
|
225
|
+
// attempt — the doctrine's block in its field scope, the listing rules and
|
|
226
|
+
// the tool's schema, about 760 tokens together. The page text, capped at
|
|
227
|
+
// 2,000 characters, rides with the current listing and a dozen other titles
|
|
228
|
+
// for about another 750. The largest answer the tool accepts is about 600
|
|
229
|
+
// characters of JSON, and the request asks for no thinking. An audit pass
|
|
230
|
+
// is heavier: eight pages' findings and text, about 9,000 characters, with
|
|
231
|
+
// up to about 8,000 back.
|
|
232
|
+
'job.seo': {
|
|
233
|
+
inputTokens: 1500,
|
|
234
|
+
outputTokens: 250,
|
|
235
|
+
cacheReadTokens: 0,
|
|
236
|
+
cacheWriteTokens: 0
|
|
237
|
+
},
|
|
238
|
+
// The experiment step (AGL-2914). NOTHING is cached: the A/B test rules
|
|
239
|
+
// and the acceptable-use block come to about 2,300 characters, under the
|
|
240
|
+
// balanced tier's cacheable minimum, so they are billed as input every
|
|
241
|
+
// time. The copy under test, or a test's arms with its verdict, rides with
|
|
242
|
+
// them, and a four-variant answer is about 800 characters of JSON.
|
|
243
|
+
'job.experiment': {
|
|
244
|
+
inputTokens: 900,
|
|
245
|
+
outputTokens: 300,
|
|
246
|
+
cacheReadTokens: 0,
|
|
247
|
+
cacheWriteTokens: 0
|
|
248
|
+
},
|
|
249
|
+
// The form step: the doctrine, the form instructions, the form surface's
|
|
250
|
+
// catalog (about 150 tokens) and the tool's schema are the cached prefix, the
|
|
251
|
+
// site inventory and the brief ride uncached, and a form's answer is 200 to
|
|
252
|
+
// 400 tokens of JSON with no extended thinking.
|
|
253
|
+
'job.form': {
|
|
254
|
+
inputTokens: 700,
|
|
255
|
+
outputTokens: 450,
|
|
256
|
+
cacheReadTokens: 3900,
|
|
257
|
+
cacheWriteTokens: 0
|
|
258
|
+
},
|
|
259
|
+
// An insight (AGL-2915): two exchanges, and NOTHING cached — the rules and
|
|
260
|
+
// the acceptable-use block are under the balanced tier's minimum, so they
|
|
261
|
+
// are billed as input on both. The read call carries the question and the
|
|
262
|
+
// readers' catalog (about 2,000 characters) and answers a few reads; the
|
|
263
|
+
// answer call carries four tables of about ten rows each (about 4,000
|
|
264
|
+
// characters) and answers three to five insights as JSON.
|
|
265
|
+
'job.insight': {
|
|
266
|
+
inputTokens: 2800,
|
|
267
|
+
outputTokens: 650,
|
|
268
|
+
cacheReadTokens: 0,
|
|
269
|
+
cacheWriteTokens: 0
|
|
270
|
+
},
|
|
271
|
+
// The email step, and the campaign step that shares its generation: the
|
|
272
|
+
// doctrine, the email instructions, the email palette catalog and the
|
|
273
|
+
// tool's schema (about 10,300 characters) are the cached prefix, the site
|
|
274
|
+
// inventory and the brief ride uncached, and the answer is one email's
|
|
275
|
+
// node map with three subject lines and three preheaders.
|
|
276
|
+
'job.email': {
|
|
277
|
+
inputTokens: 600,
|
|
278
|
+
outputTokens: 1500,
|
|
279
|
+
cacheReadTokens: 3600,
|
|
280
|
+
cacheWriteTokens: 0
|
|
281
|
+
},
|
|
282
|
+
'job.campaign': {
|
|
283
|
+
inputTokens: 600,
|
|
284
|
+
outputTokens: 1500,
|
|
285
|
+
cacheReadTokens: 3600,
|
|
286
|
+
cacheWriteTokens: 0
|
|
287
|
+
},
|
|
288
|
+
// The workflow step's draft (AGL-2919): the doctrine, the automation
|
|
289
|
+
// vocabulary and the tool's schema are the cached prefix (4,564 tokens, as
|
|
290
|
+
// `runtime/ai-prompt-cache.spec.ts` measures it); what the workspace can
|
|
291
|
+
// run, the site's forms and datasets and the description ride uncached; and
|
|
292
|
+
// an automation of a few steps is about 1,300 characters of JSON with as
|
|
293
|
+
// much again to think in. An explanation caches half as much.
|
|
294
|
+
'job.workflow': {
|
|
295
|
+
inputTokens: 500,
|
|
296
|
+
outputTokens: 1000,
|
|
297
|
+
cacheReadTokens: 4500,
|
|
298
|
+
cacheWriteTokens: 0
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
/** The fewest measured exchanges a median is taken over. */ export const AI_MEASURED_MEDIAN_MIN_SAMPLES = 3;
|
|
302
|
+
function onLists(entry, bounds) {
|
|
303
|
+
var _bounds_orgModels;
|
|
304
|
+
if (((_bounds_orgModels = bounds.orgModels) == null ? void 0 : _bounds_orgModels.length) && !bounds.orgModels.includes(entry.id)) return false;
|
|
305
|
+
if (bounds.allotmentModels && !bounds.allotmentModels.includes(entry.id)) return false;
|
|
306
|
+
return true;
|
|
307
|
+
}
|
|
308
|
+
/** The catalog models a manual pick may name on a provider under these bounds. */ export function aiModelsSelectable(providerId, bounds) {
|
|
309
|
+
var _AI_PLAN_MODEL_TIERS_bounds_plan;
|
|
310
|
+
const tiers = (_AI_PLAN_MODEL_TIERS_bounds_plan = AI_PLAN_MODEL_TIERS[bounds.plan]) != null ? _AI_PLAN_MODEL_TIERS_bounds_plan : [];
|
|
311
|
+
return AI_MODEL_CATALOG.filter((entry)=>entry.provider === providerId && tiers.includes(entry.tier) && onLists(entry, bounds));
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* A model's blended BILLED rate, for "the cheapest allowed" and nothing
|
|
315
|
+
* else.
|
|
316
|
+
*
|
|
317
|
+
* Billed and not provider (AGL-3015): the substitution below happens when a
|
|
318
|
+
* workspace asked for a model its bounds do not allow, and the party it
|
|
319
|
+
* falls back for is the one whose credits are drawn. "Cheapest" has to mean
|
|
320
|
+
* the same thing here as in the selector this substitution stands in for,
|
|
321
|
+
* which sorts on `creditsPerRequest`.
|
|
322
|
+
*/ const blendedRate = (id)=>{
|
|
323
|
+
const rates = aiBilledRatesForModel(id);
|
|
324
|
+
return rates.inputPerToken + rates.outputPerToken;
|
|
325
|
+
};
|
|
326
|
+
/**
|
|
327
|
+
* The model one request runs on, or `null` when no provider is registered —
|
|
328
|
+
* which every door has refused before it asks.
|
|
329
|
+
*/ export function resolveAiModelChoice(kind, requested, bounds, settings) {
|
|
330
|
+
var _bounds_orgModels;
|
|
331
|
+
const route = resolveAiRoute(kind, settings);
|
|
332
|
+
if (!route) return null;
|
|
333
|
+
const wanted = typeof requested === 'string' && requested.trim() && requested.trim() !== AI_MODEL_AUTO ? requested.trim() : null;
|
|
334
|
+
if (wanted && aiModelsSelectable(route.provider.id, bounds).some((entry)=>entry.id === wanted)) {
|
|
335
|
+
return {
|
|
336
|
+
model: wanted,
|
|
337
|
+
auto: false,
|
|
338
|
+
declined: null
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
const restricted = Boolean((_bounds_orgModels = bounds.orgModels) == null ? void 0 : _bounds_orgModels.length) || Boolean(bounds.allotmentModels);
|
|
342
|
+
let model = route.model;
|
|
343
|
+
if (restricted) {
|
|
344
|
+
const allowed = AI_MODEL_CATALOG.filter((entry)=>entry.provider === route.provider.id && onLists(entry, bounds));
|
|
345
|
+
if (allowed.length && !allowed.some((entry)=>entry.id === model)) {
|
|
346
|
+
var _ref;
|
|
347
|
+
var _aiCatalogEntry;
|
|
348
|
+
const tier = (_ref = (_aiCatalogEntry = aiCatalogEntry(model)) == null ? void 0 : _aiCatalogEntry.tier) != null ? _ref : AI_STEP_TIERS[kind];
|
|
349
|
+
const sameTier = allowed.find((entry)=>entry.tier === tier);
|
|
350
|
+
const cheapest = [
|
|
351
|
+
...allowed
|
|
352
|
+
].sort((a, b)=>blendedRate(a.id) - blendedRate(b.id))[0];
|
|
353
|
+
model = (sameTier != null ? sameTier : cheapest).id;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return {
|
|
357
|
+
model,
|
|
358
|
+
auto: true,
|
|
359
|
+
declined: wanted
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
/** The median exchange over measured samples, or `null` below the minimum. */ export function aiMedianUsage(samples) {
|
|
363
|
+
if (samples.length < AI_MEASURED_MEDIAN_MIN_SAMPLES) return null;
|
|
364
|
+
const median = (field)=>{
|
|
365
|
+
const values = samples.map((sample)=>{
|
|
366
|
+
var _sample_field;
|
|
367
|
+
return Number((_sample_field = sample[field]) != null ? _sample_field : 0);
|
|
368
|
+
}).filter((value)=>Number.isFinite(value) && value >= 0).sort((a, b)=>a - b);
|
|
369
|
+
if (!values.length) return 0;
|
|
370
|
+
const middle = Math.floor(values.length / 2);
|
|
371
|
+
return values.length % 2 ? values[middle] : Math.round((values[middle - 1] + values[middle]) / 2);
|
|
372
|
+
};
|
|
373
|
+
return {
|
|
374
|
+
inputTokens: median('inputTokens'),
|
|
375
|
+
outputTokens: median('outputTokens'),
|
|
376
|
+
cacheReadTokens: median('cacheReadTokens'),
|
|
377
|
+
cacheWriteTokens: median('cacheWriteTokens')
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
/** What the selector lists for one step kind, or `null` without a provider. */ export function aiModelOptions(kind, bounds, measured, settings) {
|
|
381
|
+
var _ref;
|
|
382
|
+
const route = resolveAiRoute(kind, settings);
|
|
383
|
+
const auto = resolveAiModelChoice(kind, null, bounds, settings);
|
|
384
|
+
if (!route || !auto) return null;
|
|
385
|
+
const typical = measured != null ? measured : AI_STEP_NOMINAL_USAGE[kind];
|
|
386
|
+
// Billed rates throughout (AGL-3015): every figure below is what the
|
|
387
|
+
// workspace will be charged for picking this model — credits per request
|
|
388
|
+
// and the multiple of Auto those credits come to. Our own cost for the
|
|
389
|
+
// same request is not this selector's subject and would misstate both.
|
|
390
|
+
const autoCost = estimateAiBilledUsd(typical, auto.model);
|
|
391
|
+
const priced = (entry)=>{
|
|
392
|
+
const cost = estimateAiBilledUsd(typical, entry.id);
|
|
393
|
+
return {
|
|
394
|
+
id: entry.id,
|
|
395
|
+
label: entry.label,
|
|
396
|
+
tier: entry.tier,
|
|
397
|
+
creditsPerRequest: assistCreditsFromUsd(cost),
|
|
398
|
+
multiplier: autoCost > 0 ? Math.round(cost / autoCost * 10) / 10 : 1
|
|
399
|
+
};
|
|
400
|
+
};
|
|
401
|
+
const autoEntry = aiCatalogEntry(auto.model);
|
|
402
|
+
return {
|
|
403
|
+
auto: {
|
|
404
|
+
id: AI_MODEL_AUTO,
|
|
405
|
+
label: autoEntry ? `Auto (${autoEntry.label})` : 'Auto',
|
|
406
|
+
tier: (_ref = autoEntry == null ? void 0 : autoEntry.tier) != null ? _ref : AI_STEP_TIERS[kind],
|
|
407
|
+
creditsPerRequest: assistCreditsFromUsd(autoCost),
|
|
408
|
+
multiplier: 1,
|
|
409
|
+
model: auto.model
|
|
410
|
+
},
|
|
411
|
+
options: aiModelsSelectable(route.provider.id, bounds).map(priced).sort((a, b)=>a.creditsPerRequest - b.creditsPerRequest || a.label.localeCompare(b.label)),
|
|
412
|
+
measured: measured !== null
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
//# sourceMappingURL=model-choice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/providers/model-choice.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 { assistCreditsFromUsd } from '@aglyn/aglyn/app-utils/assist-credits'\nimport type { OrgPlan } from '@aglyn/aglyn/foundation/definitions/org-billing.types'\nimport {\n AI_MODEL_CATALOG,\n AI_STEP_TIERS,\n aiCatalogEntry,\n aiBilledRatesForModel,\n estimateAiBilledUsd,\n type AiCatalogEntry,\n type AiStepKind,\n} from './catalog'\nimport type { AiUsage } from './contract'\nimport { resolveAiRoute, type AiPluginSettings } from './routing'\n\n/**\n * THE MODEL SWITCH (AGL-2942): what a person may pick, what \"Auto\" means,\n * and what a pick costs.\n *\n * ## Auto is the routing table\n *\n * A request that names no model — or names one it may not have — runs on\n * `resolveAiRoute(kind)`, the table that maps a step kind to a catalog model\n * (AGL-2937). Picking a model is an override of that one row for one request,\n * never a second table.\n *\n * ## Three bounds, one intersection\n *\n * A manual pick must be served by the active provider, in a tier the org's\n * plan offers (`AI_PLAN_MODEL_TIERS`), on the org's own restriction when it\n * set one, and on the allotment allowlists that apply to the request. The\n * two allowlists bound Auto too: when the routing table's answer is not on\n * them, Auto runs on the allowed model of the same tier, else the cheapest\n * allowed one. The plan bounds only a pick — Auto is the platform's choice,\n * made for the step, and a plan never makes it worse.\n *\n * An allowlist that leaves nothing this deployment serves is not a way to\n * switch AI off by mistake: the choice falls back to the routing table, and\n * the permission keys are how AI is switched off on purpose.\n *\n * ## The price beside each option\n *\n * Credits per typical request at each model's list rates, over the step's\n * measured median exchange when the workspace has enough of them, and over\n * `AI_STEP_NOMINAL_USAGE` until it does — with the multiple of what Auto\n * would cost for the same request. Every figure is credits, never dollars.\n */\n\n/** The value a request sends for \"let the platform route it\". */\nexport const AI_MODEL_AUTO = 'auto'\n\n/**\n * The catalog tiers a MANUAL pick may name, per plan. Free runs on Auto only:\n * its taste is a wall, and a pick there would spend the account's credits at\n * a rate nobody chose on purpose. The dearest tier opens from Scale up, where\n * the band is large enough that a slower, deeper model is a real choice\n * rather than a fast way to end the month.\n */\nexport const AI_PLAN_MODEL_TIERS: Record<OrgPlan, readonly AiCatalogEntry['tier'][]> = {\n free: [],\n starter: ['fast', 'balanced'],\n pro: ['fast', 'balanced'],\n business: ['fast', 'balanced'],\n scale: ['fast', 'balanced', 'deep'],\n advanced: ['fast', 'balanced', 'deep'],\n agency: ['fast', 'balanced', 'deep'],\n enterprise: ['fast', 'balanced', 'deep'],\n}\n\n/** The plans whose admins may restrict the model set org-wide. */\nexport const AI_MODEL_RESTRICTION_PLANS: readonly OrgPlan[] = ['agency', 'enterprise']\n\n/**\n * A typical exchange per step kind, before a workspace has measured one: the\n * doors' own prompt sizes and output ceilings, read conservatively. Replaced\n * by the workspace's measured median as soon as `aiMedianUsage` has enough\n * samples, and only ever used for the price beside an option.\n */\nexport const AI_STEP_NOMINAL_USAGE: Record<AiStepKind, AiUsage> = {\n 'assist.chat': { inputTokens: 900, outputTokens: 450, cacheReadTokens: 1_050, cacheWriteTokens: 0 },\n 'copy.element': { inputTokens: 350, outputTokens: 120, cacheReadTokens: 0, cacheWriteTokens: 0 },\n 'copy.section': { inputTokens: 700, outputTokens: 1_400, cacheReadTokens: 0, cacheWriteTokens: 0 },\n 'copy.blog': { inputTokens: 600, outputTokens: 1_100, cacheReadTokens: 0, cacheWriteTokens: 0 },\n 'generate.section': { inputTokens: 700, outputTokens: 1_400, cacheReadTokens: 0, cacheWriteTokens: 0 },\n // The text step's rules are about 500 characters — far under the balanced\n // tier's cacheable minimum, so they are billed as input every time rather\n // than read from a cache (`runtime/ai-prompt-cache.spec.ts` measures it).\n 'job.text': { inputTokens: 450, outputTokens: 500, cacheReadTokens: 0, cacheWriteTokens: 0 },\n // The theme step: the tool's schema and both system blocks (about 7,500\n // characters) are the cached prefix, the site's inventory and the brief ride\n // uncached, and a full-palette answer is about 1,300 characters of JSON with\n // as much again to think in.\n 'job.theme': { inputTokens: 500, outputTokens: 850, cacheReadTokens: 2_500, cacheWriteTokens: 0 },\n // The plan step: the tool's schema, the doctrine and the plan instructions\n // (about 10,000 characters) are the cached prefix, the site inventory and the\n // brief ride uncached, and a plan answer is about 600 characters of JSON with\n // as much again to think in.\n 'job.plan': { inputTokens: 500, outputTokens: 400, cacheReadTokens: 3_600, cacheWriteTokens: 0 },\n // The component step: the doctrine, the component instructions, the\n // component surface's catalog and the tool are the cached prefix, the site\n // inventory, the brief and the confirmed plan ride uncached, and a card-sized\n // answer — its tree and declared props as JSON — is about 1,700 characters.\n // The component step's spec measures the prefix and the answer against this.\n 'job.component': { inputTokens: 700, outputTokens: 600, cacheReadTokens: 5_800, cacheWriteTokens: 0 },\n // The CRM step's exchange (AGL-2917). NOTHING is cached: the step runs on\n // the fast tier, whose cacheable minimum is far above what its prompt\n // reaches — the doctrine's field rules, the CRM rules and the tool come to\n // 650 to 913 tokens, as `runtime/ai-prompt-cache.spec.ts` measures — so\n // every byte is billed as input. A record's facts ride with them, a\n // timeline cut to its newest twelve entries, and the typical answer is a\n // summary and a next step of a few sentences, with no thinking.\n 'job.crm': { inputTokens: 1_800, outputTokens: 250, cacheReadTokens: 0, cacheWriteTokens: 0 },\n 'job.layout': { inputTokens: 700, outputTokens: 1_000, cacheReadTokens: 5_600, cacheWriteTokens: 0 },\n 'job.template': { inputTokens: 1_200, outputTokens: 700, cacheReadTokens: 6_400, cacheWriteTokens: 0 },\n // One page section's exchange (AGL-2907), from the modules' own text: the\n // doctrine (6,281 characters), the page instructions (1,524), the screen\n // palette catalog (8,353) and the section tool (484) are the cached prefix;\n // the site inventory (711 on the median golden site), the brief, the plan\n // and the section line ride uncached; and a golden section answer is 901\n // characters at the median, asked for with no thinking.\n 'job.page': { inputTokens: 600, outputTokens: 300, cacheReadTokens: 4_400, cacheWriteTokens: 0 },\n // One product's copy (AGL-2916), the exchange a bulk job makes once a\n // product: the doctrine, the copy rules and the tool (about 9,500 characters)\n // are the cached prefix; the product's facts, the site's categories and a\n // photo at most 768 pixels on its long edge (about 790 tokens) ride\n // uncached; and the answer is a description with its search listing, tags,\n // categories and option names, about 1,300 characters of JSON.\n 'job.products': { inputTokens: 1_500, outputTokens: 450, cacheReadTokens: 2_400, cacheWriteTokens: 0 },\n // The SEO step's listing exchange, which a page's or a product's listing is\n // exactly one of. NOTHING is cached here, whatever the breakpoints say: the\n // step runs on the fast tier, whose cacheable minimum is four times what\n // this prompt reaches, so every static byte is billed as input on every\n // attempt — the doctrine's block in its field scope, the listing rules and\n // the tool's schema, about 760 tokens together. The page text, capped at\n // 2,000 characters, rides with the current listing and a dozen other titles\n // for about another 750. The largest answer the tool accepts is about 600\n // characters of JSON, and the request asks for no thinking. An audit pass\n // is heavier: eight pages' findings and text, about 9,000 characters, with\n // up to about 8,000 back.\n 'job.seo': { inputTokens: 1_500, outputTokens: 250, cacheReadTokens: 0, cacheWriteTokens: 0 },\n // The experiment step (AGL-2914). NOTHING is cached: the A/B test rules\n // and the acceptable-use block come to about 2,300 characters, under the\n // balanced tier's cacheable minimum, so they are billed as input every\n // time. The copy under test, or a test's arms with its verdict, rides with\n // them, and a four-variant answer is about 800 characters of JSON.\n 'job.experiment': { inputTokens: 900, outputTokens: 300, cacheReadTokens: 0, cacheWriteTokens: 0 },\n // The form step: the doctrine, the form instructions, the form surface's\n // catalog (about 150 tokens) and the tool's schema are the cached prefix, the\n // site inventory and the brief ride uncached, and a form's answer is 200 to\n // 400 tokens of JSON with no extended thinking.\n 'job.form': { inputTokens: 700, outputTokens: 450, cacheReadTokens: 3_900, cacheWriteTokens: 0 },\n // An insight (AGL-2915): two exchanges, and NOTHING cached — the rules and\n // the acceptable-use block are under the balanced tier's minimum, so they\n // are billed as input on both. The read call carries the question and the\n // readers' catalog (about 2,000 characters) and answers a few reads; the\n // answer call carries four tables of about ten rows each (about 4,000\n // characters) and answers three to five insights as JSON.\n 'job.insight': { inputTokens: 2_800, outputTokens: 650, cacheReadTokens: 0, cacheWriteTokens: 0 },\n // The email step, and the campaign step that shares its generation: the\n // doctrine, the email instructions, the email palette catalog and the\n // tool's schema (about 10,300 characters) are the cached prefix, the site\n // inventory and the brief ride uncached, and the answer is one email's\n // node map with three subject lines and three preheaders.\n 'job.email': { inputTokens: 600, outputTokens: 1_500, cacheReadTokens: 3_600, cacheWriteTokens: 0 },\n 'job.campaign': { inputTokens: 600, outputTokens: 1_500, cacheReadTokens: 3_600, cacheWriteTokens: 0 },\n // The workflow step's draft (AGL-2919): the doctrine, the automation\n // vocabulary and the tool's schema are the cached prefix (4,564 tokens, as\n // `runtime/ai-prompt-cache.spec.ts` measures it); what the workspace can\n // run, the site's forms and datasets and the description ride uncached; and\n // an automation of a few steps is about 1,300 characters of JSON with as\n // much again to think in. An explanation caches half as much.\n 'job.workflow': { inputTokens: 500, outputTokens: 1_000, cacheReadTokens: 4_500, cacheWriteTokens: 0 },\n}\n\n/** The fewest measured exchanges a median is taken over. */\nexport const AI_MEASURED_MEDIAN_MIN_SAMPLES = 3\n\nexport interface AiModelBounds {\n plan: OrgPlan\n /** The allotment allowlists that apply, intersected; `null` for none. */\n allotmentModels?: readonly string[] | null\n /** The org-wide restriction; `null` for none. */\n orgModels?: readonly string[] | null\n}\n\nfunction onLists(entry: AiCatalogEntry, bounds: AiModelBounds): boolean {\n if (bounds.orgModels?.length && !bounds.orgModels.includes(entry.id)) return false\n if (bounds.allotmentModels && !bounds.allotmentModels.includes(entry.id)) return false\n return true\n}\n\n/** The catalog models a manual pick may name on a provider under these bounds. */\nexport function aiModelsSelectable(\n providerId: string,\n bounds: AiModelBounds,\n): AiCatalogEntry[] {\n const tiers = AI_PLAN_MODEL_TIERS[bounds.plan] ?? []\n return AI_MODEL_CATALOG.filter(\n (entry) =>\n entry.provider === providerId && tiers.includes(entry.tier) && onLists(entry, bounds),\n )\n}\n\n/**\n * A model's blended BILLED rate, for \"the cheapest allowed\" and nothing\n * else.\n *\n * Billed and not provider (AGL-3015): the substitution below happens when a\n * workspace asked for a model its bounds do not allow, and the party it\n * falls back for is the one whose credits are drawn. \"Cheapest\" has to mean\n * the same thing here as in the selector this substitution stands in for,\n * which sorts on `creditsPerRequest`.\n */\nconst blendedRate = (id: string): number => {\n const rates = aiBilledRatesForModel(id)\n return rates.inputPerToken + rates.outputPerToken\n}\n\nexport interface AiModelChoice {\n /** The catalog id the request runs, and is metered, on. */\n model: string\n /** True when the routing table decided: Auto, or a pick that was declined. */\n auto: boolean\n /** A pick that was asked for and is not allowed, for the envelope. */\n declined: string | null\n}\n\n/**\n * The model one request runs on, or `null` when no provider is registered —\n * which every door has refused before it asks.\n */\nexport function resolveAiModelChoice(\n kind: AiStepKind,\n requested: unknown,\n bounds: AiModelBounds,\n settings?: AiPluginSettings,\n): AiModelChoice | null {\n const route = resolveAiRoute(kind, settings)\n if (!route) return null\n const wanted =\n typeof requested === 'string' && requested.trim() && requested.trim() !== AI_MODEL_AUTO\n ? requested.trim()\n : null\n if (wanted && aiModelsSelectable(route.provider.id, bounds).some((entry) => entry.id === wanted)) {\n return { model: wanted, auto: false, declined: null }\n }\n const restricted = Boolean(bounds.orgModels?.length) || Boolean(bounds.allotmentModels)\n let model = route.model\n if (restricted) {\n const allowed = AI_MODEL_CATALOG.filter(\n (entry) => entry.provider === route.provider.id && onLists(entry, bounds),\n )\n if (allowed.length && !allowed.some((entry) => entry.id === model)) {\n const tier = aiCatalogEntry(model)?.tier ?? AI_STEP_TIERS[kind]\n const sameTier = allowed.find((entry) => entry.tier === tier)\n const cheapest = [...allowed].sort((a, b) => blendedRate(a.id) - blendedRate(b.id))[0]\n model = (sameTier ?? cheapest).id\n }\n }\n return { model, auto: true, declined: wanted }\n}\n\n/** The median exchange over measured samples, or `null` below the minimum. */\nexport function aiMedianUsage(samples: readonly AiUsage[]): AiUsage | null {\n if (samples.length < AI_MEASURED_MEDIAN_MIN_SAMPLES) return null\n const median = (field: keyof AiUsage): number => {\n const values = samples\n .map((sample) => Number(sample[field] ?? 0))\n .filter((value) => Number.isFinite(value) && value >= 0)\n .sort((a, b) => a - b)\n if (!values.length) return 0\n const middle = Math.floor(values.length / 2)\n return values.length % 2\n ? values[middle]\n : Math.round((values[middle - 1] + values[middle]) / 2)\n }\n return {\n inputTokens: median('inputTokens'),\n outputTokens: median('outputTokens'),\n cacheReadTokens: median('cacheReadTokens'),\n cacheWriteTokens: median('cacheWriteTokens'),\n }\n}\n\nexport interface AiModelOption {\n /** A catalog id, or `AI_MODEL_AUTO`. */\n id: string\n label: string\n tier: AiCatalogEntry['tier']\n /** Credits a typical request of this kind costs on the option. */\n creditsPerRequest: number\n /** That cost as a multiple of Auto's, to one decimal. */\n multiplier: number\n}\n\nexport interface AiModelOptions {\n /** Auto, labeled with the model it routes this kind to under these bounds. */\n auto: AiModelOption & { model: string }\n /** The manual picks, cheapest first; empty where the plan offers none. */\n options: AiModelOption[]\n /** Whether the price came from the workspace's own measured exchanges. */\n measured: boolean\n}\n\n/** What the selector lists for one step kind, or `null` without a provider. */\nexport function aiModelOptions(\n kind: AiStepKind,\n bounds: AiModelBounds,\n measured: AiUsage | null,\n settings?: AiPluginSettings,\n): AiModelOptions | null {\n const route = resolveAiRoute(kind, settings)\n const auto = resolveAiModelChoice(kind, null, bounds, settings)\n if (!route || !auto) return null\n const typical = measured ?? AI_STEP_NOMINAL_USAGE[kind]\n // Billed rates throughout (AGL-3015): every figure below is what the\n // workspace will be charged for picking this model — credits per request\n // and the multiple of Auto those credits come to. Our own cost for the\n // same request is not this selector's subject and would misstate both.\n const autoCost = estimateAiBilledUsd(typical, auto.model)\n const priced = (entry: AiCatalogEntry): AiModelOption => {\n const cost = estimateAiBilledUsd(typical, entry.id)\n return {\n id: entry.id,\n label: entry.label,\n tier: entry.tier,\n creditsPerRequest: assistCreditsFromUsd(cost),\n multiplier: autoCost > 0 ? Math.round((cost / autoCost) * 10) / 10 : 1,\n }\n }\n const autoEntry = aiCatalogEntry(auto.model)\n return {\n auto: {\n id: AI_MODEL_AUTO,\n label: autoEntry ? `Auto (${autoEntry.label})` : 'Auto',\n tier: autoEntry?.tier ?? AI_STEP_TIERS[kind],\n creditsPerRequest: assistCreditsFromUsd(autoCost),\n multiplier: 1,\n model: auto.model,\n },\n options: aiModelsSelectable(route.provider.id, bounds)\n .map(priced)\n .sort((a, b) => a.creditsPerRequest - b.creditsPerRequest || a.label.localeCompare(b.label)),\n measured: measured !== null,\n }\n}\n"],"names":["assistCreditsFromUsd","AI_MODEL_CATALOG","AI_STEP_TIERS","aiCatalogEntry","aiBilledRatesForModel","estimateAiBilledUsd","resolveAiRoute","AI_MODEL_AUTO","AI_PLAN_MODEL_TIERS","free","starter","pro","business","scale","advanced","agency","enterprise","AI_MODEL_RESTRICTION_PLANS","AI_STEP_NOMINAL_USAGE","inputTokens","outputTokens","cacheReadTokens","cacheWriteTokens","AI_MEASURED_MEDIAN_MIN_SAMPLES","onLists","entry","bounds","orgModels","length","includes","id","allotmentModels","aiModelsSelectable","providerId","tiers","plan","filter","provider","tier","blendedRate","rates","inputPerToken","outputPerToken","resolveAiModelChoice","kind","requested","settings","route","wanted","trim","some","model","auto","declined","restricted","Boolean","allowed","sameTier","find","cheapest","sort","a","b","aiMedianUsage","samples","median","field","values","map","sample","Number","value","isFinite","middle","Math","floor","round","aiModelOptions","measured","typical","autoCost","priced","cost","label","creditsPerRequest","multiplier","autoEntry","options","localeCompare"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,oBAAoB,QAAQ,wCAAuC;AAE5E,SACEC,gBAAgB,EAChBC,aAAa,EACbC,cAAc,EACdC,qBAAqB,EACrBC,mBAAmB,QAGd,eAAW;AAElB,SAASC,cAAc,QAA+B,eAAW;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BC,GAED,+DAA+D,GAC/D,OAAO,MAAMC,gBAAgB,OAAM;AAEnC;;;;;;CAMC,GACD,OAAO,MAAMC,sBAA0E;IACrFC,MAAM,EAAE;IACRC,SAAS;QAAC;QAAQ;KAAW;IAC7BC,KAAK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A,WAAY5D,qBAAqB,CAAC0B,KAAK;IACvD,qEAAqE;IACrE,yEAAyE;IACzE,uEAAuE;IACvE,uEAAuE;IACvE,MAAMoC,WAAW3E,oBAAoB0E,SAAS3B,KAAKD,KAAK;IACxD,MAAM8B,SAAS,CAACxD;QACd,MAAMyD,OAAO7E,oBAAoB0E,SAAStD,MAAMK,EAAE;QAClD,OAAO;YACLA,IAAIL,MAAMK,EAAE;YACZqD,OAAO1D,MAAM0D,KAAK;YAClB7C,MAAMb,MAAMa,IAAI;YAChB8C,mBAAmBpF,qBAAqBkF;YACxCG,YAAYL,WAAW,IAAIN,KAAKE,KAAK,CAAC,AAACM,OAAOF,WAAY,MAAM,KAAK;QACvE;IACF;IACA,MAAMM,YAAYnF,eAAeiD,KAAKD,KAAK;IAC3C,OAAO;QACLC,MAAM;YACJtB,IAAIvB;YACJ4E,OAAOG,YAAY,CAAC,MAAM,EAAEA,UAAUH,KAAK,CAAC,CAAC,CAAC,GAAG;YACjD7C,IAAI,UAAEgD,6BAAAA,UAAWhD,IAAI,mBAAIpC,aAAa,CAAC0C,KAAK;YAC5CwC,mBAAmBpF,qBAAqBgF;YACxCK,YAAY;YACZlC,OAAOC,KAAKD,KAAK;QACnB;QACAoC,SAASvD,mBAAmBe,MAAMV,QAAQ,CAACP,EAAE,EAAEJ,QAC5C0C,GAAG,CAACa,QACJrB,IAAI,CAAC,CAACC,GAAGC,IAAMD,EAAEuB,iBAAiB,GAAGtB,EAAEsB,iBAAiB,IAAIvB,EAAEsB,KAAK,CAACK,aAAa,CAAC1B,EAAEqB,KAAK;QAC5FL,UAAUA,aAAa;IACzB;AACF"}
|
|
@@ -0,0 +1,58 @@
|
|
|
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 AiProvider, type AiProviderRequest, type AiToolSchemaLimits, type AiUsage } from './contract';
|
|
18
|
+
/**
|
|
19
|
+
* The OpenAI-compatible adapter (AGL-2939): `POST {base}/chat/completions`
|
|
20
|
+
* against whatever endpoint `AI_OPENAI_COMPAT_BASE_URL` names — a vendor,
|
|
21
|
+
* a gateway, a self-hosted model server — with the key in
|
|
22
|
+
* `AI_OPENAI_COMPAT_API_KEY`. The second adapter behind the contract, and
|
|
23
|
+
* the proof that the runtime, the gate, the jobs and the meter never
|
|
24
|
+
* depended on the first vendor's wire shape.
|
|
25
|
+
*
|
|
26
|
+
* What the mapping gives up, stated rather than hidden: the endpoint has
|
|
27
|
+
* no explicit cache breakpoints, so the ordered system blocks become one
|
|
28
|
+
* system message in order (the runtime's prefix rule still holds, so the
|
|
29
|
+
* order is cache-friendly for an endpoint that caches prefixes on its own),
|
|
30
|
+
* and `cacheReadTokens` is whatever `prompt_tokens_details.cached_tokens`
|
|
31
|
+
* reports. A `content_filter` finish is the endpoint's decline and becomes
|
|
32
|
+
* an `AiRefusal`, the way a refusal stop does on the other adapter.
|
|
33
|
+
*/
|
|
34
|
+
export declare const OPENAI_COMPATIBLE_PROVIDER_ID = "openai-compatible";
|
|
35
|
+
export declare const OPENAI_COMPAT_BASE_URL_ENV = "AI_OPENAI_COMPAT_BASE_URL";
|
|
36
|
+
export declare const OPENAI_COMPAT_API_KEY_ENV = "AI_OPENAI_COMPAT_API_KEY";
|
|
37
|
+
/** The configured base, with any trailing slash and `/chat/completions` stripped. */
|
|
38
|
+
export declare function openAiCompatibleBaseUrl(): string | null;
|
|
39
|
+
/** The host the endpoint is reached at, for the subprocessor inventory. */
|
|
40
|
+
export declare function openAiCompatibleHost(): string;
|
|
41
|
+
/**
|
|
42
|
+
* What the strict function shape this adapter sends compiles: every property
|
|
43
|
+
* of every object listed in `required`, so no optional parameter at all — an
|
|
44
|
+
* optional field is a union with `null` instead. No other bound is stated:
|
|
45
|
+
* the endpoint is whatever `AI_OPENAI_COMPAT_BASE_URL` names, and no one
|
|
46
|
+
* count of tools or unions — nor any grammar size — holds for every endpoint
|
|
47
|
+
* that speaks the shape. A bound nothing here has watched an endpoint hold to
|
|
48
|
+
* would be a guess, and a guess in a guard is worse than a gap in one.
|
|
49
|
+
*/
|
|
50
|
+
export declare const OPENAI_COMPATIBLE_TOOL_SCHEMA_LIMITS: AiToolSchemaLimits;
|
|
51
|
+
export declare function openAiCompatibleFailureIsRetryable(status: number | null): boolean;
|
|
52
|
+
/** The endpoint's `usage` object, in the meter's shape. Missing fields read 0. */
|
|
53
|
+
export declare function openAiCompatibleUsageFrom(usage: unknown): AiUsage;
|
|
54
|
+
/** The chat-completions body. Exported so a spec can assert the wire shape. */
|
|
55
|
+
export declare function buildOpenAiCompatibleRequestBody(input: Omit<AiProviderRequest, 'apiKey' | 'signal'> & {
|
|
56
|
+
stream: boolean;
|
|
57
|
+
}): Record<string, unknown>;
|
|
58
|
+
export declare const openAiCompatibleProvider: AiProvider;
|