@aglyn/plugins-ai 1.0.0-beta.250 → 1.0.0-beta.252

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/package.json +17 -17
  2. package/src/lib/components/ai-brief-dialog.component.js +15 -1
  3. package/src/lib/components/ai-brief-dialog.component.js.map +1 -1
  4. package/src/lib/components/ai-job-links.js +1 -1
  5. package/src/lib/components/ai-job-links.js.map +1 -1
  6. package/src/lib/components/ai-job-plan.component.js +20 -2
  7. package/src/lib/components/ai-job-plan.component.js.map +1 -1
  8. package/src/lib/components/ai-jobs-store.d.ts +11 -0
  9. package/src/lib/components/ai-jobs-store.js +22 -0
  10. package/src/lib/components/ai-jobs-store.js.map +1 -1
  11. package/src/lib/jobs/ai-job-crm-step.js +7 -4
  12. package/src/lib/jobs/ai-job-crm-step.js.map +1 -1
  13. package/src/lib/jobs/ai-job-drafts.d.ts +24 -0
  14. package/src/lib/jobs/ai-job-drafts.js +46 -0
  15. package/src/lib/jobs/ai-job-drafts.js.map +1 -1
  16. package/src/lib/jobs/ai-job-experiment-step.js +6 -1
  17. package/src/lib/jobs/ai-job-experiment-step.js.map +1 -1
  18. package/src/lib/jobs/ai-job-form-reuse.d.ts +78 -0
  19. package/src/lib/jobs/ai-job-form-reuse.js +136 -0
  20. package/src/lib/jobs/ai-job-form-reuse.js.map +1 -0
  21. package/src/lib/jobs/ai-job-form-step.d.ts +17 -0
  22. package/src/lib/jobs/ai-job-form-step.js +63 -11
  23. package/src/lib/jobs/ai-job-form-step.js.map +1 -1
  24. package/src/lib/jobs/ai-job-insight-step.js +6 -1
  25. package/src/lib/jobs/ai-job-insight-step.js.map +1 -1
  26. package/src/lib/jobs/ai-job-plan-step.d.ts +19 -0
  27. package/src/lib/jobs/ai-job-plan-step.js +39 -1
  28. package/src/lib/jobs/ai-job-plan-step.js.map +1 -1
  29. package/src/lib/jobs/ai-job-seo-step.js +5 -3
  30. package/src/lib/jobs/ai-job-seo-step.js.map +1 -1
  31. package/src/lib/jobs/ai-job-site-content.d.ts +7 -5
  32. package/src/lib/jobs/ai-job-site-content.js +7 -5
  33. package/src/lib/jobs/ai-job-site-content.js.map +1 -1
  34. package/src/lib/jobs/ai-job-text-step.js +6 -3
  35. package/src/lib/jobs/ai-job-text-step.js.map +1 -1
  36. package/src/lib/jobs/ai-layout-stock-photos.d.ts +11 -7
  37. package/src/lib/jobs/ai-layout-stock-photos.js +25 -10
  38. package/src/lib/jobs/ai-layout-stock-photos.js.map +1 -1
  39. package/src/lib/jobs/ai-stock-business-nouns.d.ts +62 -0
  40. package/src/lib/jobs/ai-stock-business-nouns.js +264 -0
  41. package/src/lib/jobs/ai-stock-business-nouns.js.map +1 -0
  42. package/src/lib/model/ai-build-plan.d.ts +7 -3
  43. package/src/lib/model/ai-build-plan.js +11 -1
  44. package/src/lib/model/ai-build-plan.js.map +1 -1
  45. package/src/lib/model/ai-credit-estimate.d.ts +32 -18
  46. package/src/lib/model/ai-credit-estimate.js +36 -18
  47. package/src/lib/model/ai-credit-estimate.js.map +1 -1
  48. package/src/lib/model/ai-job-activity.d.ts +30 -0
  49. package/src/lib/model/ai-job-activity.js +35 -0
  50. package/src/lib/model/ai-job-activity.js.map +1 -1
  51. package/src/lib/model/ai-media-credits.d.ts +5 -3
  52. package/src/lib/model/ai-media-credits.js +7 -5
  53. package/src/lib/model/ai-media-credits.js.map +1 -1
  54. package/src/lib/model/ai-site-job.js +6 -3
  55. package/src/lib/model/ai-site-job.js.map +1 -1
  56. package/src/lib/model/ai-site-store-pages.d.ts +5 -0
  57. package/src/lib/model/ai-site-store-pages.js +2 -0
  58. package/src/lib/model/ai-site-store-pages.js.map +1 -1
  59. package/src/lib/plugin-config.js +2 -2
  60. package/src/lib/plugin-config.js.map +1 -1
  61. package/src/lib/providers/anthropic-crm-wording-superseded.d.ts +29 -0
  62. package/src/lib/providers/anthropic-crm-wording-superseded.js +31 -0
  63. package/src/lib/providers/anthropic-crm-wording-superseded.js.map +1 -0
  64. package/src/lib/providers/catalog.d.ts +24 -17
  65. package/src/lib/providers/catalog.js +63 -30
  66. package/src/lib/providers/catalog.js.map +1 -1
  67. package/src/lib/providers/model-choice.d.ts +1 -1
  68. package/src/lib/providers/model-choice.js +39 -30
  69. package/src/lib/providers/model-choice.js.map +1 -1
  70. package/src/lib/providers/routing.d.ts +20 -1
  71. package/src/lib/providers/routing.js +47 -8
  72. package/src/lib/providers/routing.js.map +1 -1
  73. package/src/lib/runtime/ai-dev-env.d.ts +37 -1
  74. package/src/lib/runtime/ai-dev-env.js +59 -6
  75. package/src/lib/runtime/ai-dev-env.js.map +1 -1
  76. package/src/lib/runtime/ai-doctrine-validators.js +3 -1
  77. package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
  78. package/src/lib/runtime/ai-doctrine.js +8 -4
  79. package/src/lib/runtime/ai-doctrine.js.map +1 -1
  80. package/src/lib/runtime/ai-eval-live.d.ts +8 -0
  81. package/src/lib/runtime/ai-eval-live.js +34 -8
  82. package/src/lib/runtime/ai-eval-live.js.map +1 -1
  83. package/src/lib/runtime/ai-palette.generated.js +4 -0
  84. package/src/lib/runtime/ai-palette.generated.js.map +1 -1
  85. package/src/lib/runtime/ai-runtime.js +17 -2
  86. package/src/lib/runtime/ai-runtime.js.map +1 -1
  87. package/src/lib/runtime/seo-fields.js +4 -3
  88. package/src/lib/runtime/seo-fields.js.map +1 -1
  89. package/src/lib/server/ai-assist.js +3 -2
  90. package/src/lib/server/ai-assist.js.map +1 -1
  91. package/src/lib/server/ai-media-svg.js +4 -0
  92. package/src/lib/server/ai-media-svg.js.map +1 -1
  93. package/src/lib/usage/ai-allotment-alerts.js +2 -5
  94. package/src/lib/usage/ai-allotment-alerts.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/plugins/ai/src/lib/plugin-config.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PluginConfigSchema } from '@aglyn/aglyn'\nimport { AI_PLUGIN_SETTINGS_ID } from './constants'\nimport { AI_CATALOG_PROVIDERS, AI_MODEL_CATALOG, type AiStepKind } from './providers/catalog'\n\n/**\n * The org's AI settings (AGL-2939), stored in `pluginSettings/ai` and\n * inherited per site the way every plugin setting is (AGL-428): which\n * provider serves the workspace, and which catalog model each kind of step\n * runs on. `platform` means \"whatever the deployment's environment says\",\n * which is what every workspace runs with until it chooses.\n *\n * PURE DATA (type-only aglyn import): the client barrel registers it via\n * '@aglyn/aglyn' and the /server entry via '@aglyn/aglyn/server'.\n */\n\n/** The value that defers to the deployment's environment. */\nexport const AI_SETTING_PLATFORM = 'platform'\n\n/** The setting key each step kind's model override is stored under. */\nexport const AI_STEP_MODEL_SETTING: Record<AiStepKind, string> = {\n 'assist.chat': 'chatModel',\n 'copy.element': 'copyElementModel',\n 'copy.section': 'copySectionModel',\n 'copy.blog': 'copyBlogModel',\n 'generate.section': 'generateModel',\n 'job.component': 'jobComponentModel',\n 'job.crm': 'jobCrmModel',\n 'job.experiment': 'jobExperimentModel',\n 'job.form': 'jobFormModel',\n 'job.insight': 'jobInsightModel',\n 'job.layout': 'jobLayoutModel',\n 'job.logic': 'jobLogicModel',\n 'job.edit': 'jobEditModel',\n 'job.template': 'jobTemplateModel',\n 'job.page': 'jobPageModel',\n 'job.products': 'jobProductsModel',\n 'job.seo': 'jobSeoModel',\n 'job.text': 'jobTextModel',\n 'job.theme': 'jobThemeModel',\n 'job.plan': 'jobPlanModel',\n 'job.email': 'jobEmailModel',\n 'job.campaign': 'jobCampaignModel',\n 'job.workflow': 'jobWorkflowModel',\n}\n\nconst MODEL_OPTIONS = [\n { value: AI_SETTING_PLATFORM, label: 'Platform default' },\n ...AI_MODEL_CATALOG.map((entry) => ({\n value: entry.id,\n label: `${entry.label} (${entry.provider})`,\n })),\n]\n\nconst modelField = (kind: AiStepKind, label: string, description: string) => ({\n key: AI_STEP_MODEL_SETTING[kind],\n label,\n type: 'select' as const,\n options: MODEL_OPTIONS,\n description,\n})\n\nexport const AI_CONFIG_SCHEMA: PluginConfigSchema = {\n pluginId: AI_PLUGIN_SETTINGS_ID,\n fields: [\n {\n key: 'provider',\n label: 'AI provider',\n type: 'select',\n options: [\n { value: AI_SETTING_PLATFORM, label: 'Platform default' },\n ...AI_CATALOG_PROVIDERS.map((provider) => ({ value: provider.id, label: provider.label })),\n ],\n description:\n 'Which provider answers this workspace. A model chosen below must ' +\n 'be one the provider serves; otherwise the provider’s default for ' +\n 'that kind of step is used.',\n },\n modelField('assist.chat', 'Assistant model', 'The in-console assistant’s answers.'),\n modelField('copy.element', 'Copy assistant (element) model', 'Rewriting one element’s text.'),\n modelField('copy.section', 'Copy assistant (section) model', 'Writing a section’s copy.'),\n modelField('copy.blog', 'Copy assistant (blog) model', 'Drafting a blog post.'),\n modelField('generate.section', 'Section generation model', 'Generating a section’s structure.'),\n modelField('job.component', 'Generation job (component) model', 'Generating a reusable component and its properties.'),\n modelField('job.crm', 'Generation job (CRM) model', 'CRM record summaries and next steps, email drafts and import column matches.'),\n modelField(\n 'job.experiment',\n 'Generation job (A/B test) model',\n 'Writing variants for an A/B test, and explaining what a test’s result means.',\n ),\n modelField('job.form', 'Generation job (form) model', 'Generating a form from a confirmed plan.'),\n modelField('job.insight', 'Insights model', 'Answering a question about the site’s figures, and the weekly insights.'),\n modelField('job.layout', 'Generation job (layout) model', 'Generating a shared layout from a confirmed plan.'),\n modelField('job.logic', 'Generation job (logic) model', 'Proposing a site function or variable, and explaining a function.'),\n modelField('job.edit', 'Generation job (edit) model', 'Changing a page or layout the site already has, into a version visitors do not see.'),\n modelField('job.template', 'Generation job (template) model', 'Generating a page template from a confirmed plan.'),\n modelField('job.page', 'Generation job (page) model', 'Generating a page, one section at a time, from a confirmed plan.'),\n modelField('job.products', 'Generation job (products) model', 'Writing product copy, and proposing products, categories and discounts for a store.'),\n modelField('job.seo', 'Generation job (SEO) model', 'Search listings, image descriptions and a site audit’s fixes.'),\n modelField('job.text', 'Generation job (text) model', 'The text step of a generation job.'),\n modelField('job.theme', 'Generation job (theme) model', 'Proposing a change to a site’s theme.'),\n modelField('job.plan', 'Generation job (plan) model', 'The plan step of a generation job.'),\n modelField('job.email', 'Generation job (email) model', 'Generating an email design from a confirmed plan.'),\n modelField('job.campaign', 'Generation job (campaign) model', 'Drafting a campaign and its email from a brief.'),\n modelField('job.workflow', 'Generation job (automation) model', 'Drafting an automation from a description, and explaining one.'),\n ],\n defaults: {\n provider: AI_SETTING_PLATFORM,\n ...Object.fromEntries(\n Object.values(AI_STEP_MODEL_SETTING).map((key) => [key, AI_SETTING_PLATFORM]),\n ),\n },\n}\n"],"names":["AI_PLUGIN_SETTINGS_ID","AI_CATALOG_PROVIDERS","AI_MODEL_CATALOG","AI_SETTING_PLATFORM","AI_STEP_MODEL_SETTING","MODEL_OPTIONS","value","label","map","entry","id","provider","modelField","kind","description","key","type","options","AI_CONFIG_SCHEMA","pluginId","fields","defaults","Object","fromEntries","values"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SAASA,qBAAqB,QAAQ,iBAAa;AACnD,SAASC,oBAAoB,EAAEC,gBAAgB,QAAyB,yBAAqB;AAE7F;;;;;;;;;CASC,GAED,2DAA2D,GAC3D,OAAO,MAAMC,sBAAsB,WAAU;AAE7C,qEAAqE,GACrE,OAAO,MAAMC,wBAAoD;IAC/D,eAAe;IACf,gBAAgB;IAChB,gBAAgB;IAChB,aAAa;IACb,oBAAoB;IACpB,iBAAiB;IACjB,WAAW;IACX,kBAAkB;IAClB,YAAY;IACZ,eAAe;IACf,cAAc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gBAAgB,mCAAmC;QAC9DA,WAAW,YAAY,+BAA+B;QACtDA,WAAW,gBAAgB,mCAAmC;QAC9DA,WAAW,WAAW,8BAA8B;QACpDA,WAAW,YAAY,+BAA+B;QACtDA,WAAW,aAAa,gCAAgC;QACxDA,WAAW,YAAY,+BAA+B;QACtDA,WAAW,aAAa,gCAAgC;QACxDA,WAAW,gBAAgB,mCAAmC;QAC9DA,WAAW,gBAAgB,qCAAqC;KACjE;IACDS,UAAU;QACRV,UAAUR;OACPmB,OAAOC,WAAW,CACnBD,OAAOE,MAAM,CAACpB,uBAAuBI,GAAG,CAAC,CAACO,MAAQ;YAACA;YAAKZ;SAAoB;AAGlF,EAAC"}
1
+ {"version":3,"sources":["../../../../../../libs/plugins/ai/src/lib/plugin-config.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PluginConfigSchema } from '@aglyn/aglyn'\nimport { AI_PLUGIN_SETTINGS_ID } from './constants'\nimport { AI_CATALOG_PROVIDERS, AI_MODEL_CATALOG, type AiStepKind } from './providers/catalog'\n\n/**\n * The org's AI settings (AGL-2939), stored in `pluginSettings/ai` and\n * inherited per site the way every plugin setting is (AGL-428): which\n * provider serves the workspace, and which catalog model each kind of step\n * runs on. `platform` means \"whatever the deployment's environment says\",\n * which is what every workspace runs with until it chooses.\n *\n * PURE DATA (type-only aglyn import): the client barrel registers it via\n * '@aglyn/aglyn' and the /server entry via '@aglyn/aglyn/server'.\n */\n\n/** The value that defers to the deployment's environment. */\nexport const AI_SETTING_PLATFORM = 'platform'\n\n/** The setting key each step kind's model override is stored under. */\nexport const AI_STEP_MODEL_SETTING: Record<AiStepKind, string> = {\n 'assist.chat': 'chatModel',\n 'copy.element': 'copyElementModel',\n 'copy.section': 'copySectionModel',\n 'copy.blog': 'copyBlogModel',\n 'generate.section': 'generateModel',\n 'job.component': 'jobComponentModel',\n 'job.crm': 'jobCrmModel',\n 'job.experiment': 'jobExperimentModel',\n 'job.form': 'jobFormModel',\n 'job.insight': 'jobInsightModel',\n 'job.layout': 'jobLayoutModel',\n 'job.logic': 'jobLogicModel',\n 'job.edit': 'jobEditModel',\n 'job.template': 'jobTemplateModel',\n 'job.page': 'jobPageModel',\n 'job.products': 'jobProductsModel',\n 'job.seo': 'jobSeoModel',\n 'job.text': 'jobTextModel',\n 'job.theme': 'jobThemeModel',\n 'job.plan': 'jobPlanModel',\n 'job.email': 'jobEmailModel',\n 'job.campaign': 'jobCampaignModel',\n 'job.workflow': 'jobWorkflowModel',\n}\n\n/** Every current catalog model: a retired one is served by its successor, so it is not offered. */\nconst MODEL_OPTIONS = [\n { value: AI_SETTING_PLATFORM, label: 'Platform default' },\n ...AI_MODEL_CATALOG.filter((entry) => !entry.successor).map((entry) => ({\n value: entry.id,\n label: `${entry.label} (${entry.provider})`,\n })),\n]\n\nconst modelField = (kind: AiStepKind, label: string, description: string) => ({\n key: AI_STEP_MODEL_SETTING[kind],\n label,\n type: 'select' as const,\n options: MODEL_OPTIONS,\n description,\n})\n\nexport const AI_CONFIG_SCHEMA: PluginConfigSchema = {\n pluginId: AI_PLUGIN_SETTINGS_ID,\n fields: [\n {\n key: 'provider',\n label: 'AI provider',\n type: 'select',\n options: [\n { value: AI_SETTING_PLATFORM, label: 'Platform default' },\n ...AI_CATALOG_PROVIDERS.map((provider) => ({ value: provider.id, label: provider.label })),\n ],\n description:\n 'Which provider answers this workspace. A model chosen below must ' +\n 'be one the provider serves; otherwise the provider’s default for ' +\n 'that kind of step is used.',\n },\n modelField('assist.chat', 'Assistant model', 'The in-console assistant’s answers.'),\n modelField('copy.element', 'Copy assistant (element) model', 'Rewriting one element’s text.'),\n modelField('copy.section', 'Copy assistant (section) model', 'Writing a section’s copy.'),\n modelField('copy.blog', 'Copy assistant (blog) model', 'Drafting a blog post.'),\n modelField('generate.section', 'Section generation model', 'Generating a section’s structure.'),\n modelField('job.component', 'Generation job (component) model', 'Generating a reusable component and its properties.'),\n modelField('job.crm', 'Generation job (CRM) model', 'CRM record summaries and next steps, email drafts and import column matches.'),\n modelField(\n 'job.experiment',\n 'Generation job (A/B test) model',\n 'Writing variants for an A/B test, and explaining what a test’s result means.',\n ),\n modelField('job.form', 'Generation job (form) model', 'Generating a form from a confirmed plan.'),\n modelField('job.insight', 'Insights model', 'Answering a question about the site’s figures, and the weekly insights.'),\n modelField('job.layout', 'Generation job (layout) model', 'Generating a shared layout from a confirmed plan.'),\n modelField('job.logic', 'Generation job (logic) model', 'Proposing a site function or variable, and explaining a function.'),\n modelField('job.edit', 'Generation job (edit) model', 'Changing a page or layout the site already has, into a version visitors do not see.'),\n modelField('job.template', 'Generation job (template) model', 'Generating a page template from a confirmed plan.'),\n modelField('job.page', 'Generation job (page) model', 'Generating a page, one section at a time, from a confirmed plan.'),\n modelField('job.products', 'Generation job (products) model', 'Writing product copy, and proposing products, categories and discounts for a store.'),\n modelField('job.seo', 'Generation job (SEO) model', 'Search listings, image descriptions and a site audit’s fixes.'),\n modelField('job.text', 'Generation job (text) model', 'The text step of a generation job.'),\n modelField('job.theme', 'Generation job (theme) model', 'Proposing a change to a site’s theme.'),\n modelField('job.plan', 'Generation job (plan) model', 'The plan step of a generation job.'),\n modelField('job.email', 'Generation job (email) model', 'Generating an email design from a confirmed plan.'),\n modelField('job.campaign', 'Generation job (campaign) model', 'Drafting a campaign and its email from a brief.'),\n modelField('job.workflow', 'Generation job (automation) model', 'Drafting an automation from a description, and explaining one.'),\n ],\n defaults: {\n provider: AI_SETTING_PLATFORM,\n ...Object.fromEntries(\n Object.values(AI_STEP_MODEL_SETTING).map((key) => [key, AI_SETTING_PLATFORM]),\n ),\n },\n}\n"],"names":["AI_PLUGIN_SETTINGS_ID","AI_CATALOG_PROVIDERS","AI_MODEL_CATALOG","AI_SETTING_PLATFORM","AI_STEP_MODEL_SETTING","MODEL_OPTIONS","value","label","filter","entry","successor","map","id","provider","modelField","kind","description","key","type","options","AI_CONFIG_SCHEMA","pluginId","fields","defaults","Object","fromEntries","values"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SAASA,qBAAqB,QAAQ,iBAAa;AACnD,SAASC,oBAAoB,EAAEC,gBAAgB,QAAyB,yBAAqB;AAE7F;;;;;;;;;CASC,GAED,2DAA2D,GAC3D,OAAO,MAAMC,sBAAsB,WAAU;AAE7C,qEAAqE,GACrE,OAAO,MAAMC,wBAAoD;IAC/D,eAAe;IACf,gBAAgB;IAChB,gBAAgB;IAChB,aAAa;IACb,oBAAoB;IACpB,iBAAiB;IACjB,WAAW;IACX,kBAAkB;IAClB,YAAY;IACZ,eAAe;IACf,cAAc;IACd,aAAa;IACb,YAAY;IACZ,gBAAgB;IAChB,YAAY;IACZ,gBAAgB;IAChB,WAAW;IACX,YAAY;IACZ,aAAa;IACb,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,gBAAgB;AAClB,EAAC;AAED,iGAAiG,GACjG,MAAMC,gBAAgB;IACpB;QAAEC,OAAOH;QAAqBI,OAAO;IAAmB;OACrDL,iBAAiBM,MAAM,CAAC,CAACC,QAAU,CAACA,MAAMC,SAAS,EAAEC,GAAG,CAAC,CAACF,QAAW,CAAA;YACtEH,OAAOG,MAAMG,EAAE;YACfL,OAAO,GAAGE,MAAMF,KAAK,CAAC,EAAE,EAAEE,MAAMI,QAAQ,CAAC,CAAC,CAAC;QAC7C,CAAA;CACD;AAED,MAAMC,aAAa,CAACC,MAAkBR,OAAeS,cAAyB,CAAA;QAC5EC,KAAKb,qBAAqB,CAACW,KAAK;QAChCR;QACAW,MAAM;QACNC,SAASd;QACTW;IACF,CAAA;AAEA,OAAO,MAAMI,mBAAuC;IAClDC,UAAUrB;IACVsB,QAAQ;QACN;YACEL,KAAK;YACLV,OAAO;YACPW,MAAM;YACNC,SAAS;gBACP;oBAAEb,OAAOH;oBAAqBI,OAAO;gBAAmB;mBACrDN,qBAAqBU,GAAG,CAAC,CAACE,WAAc,CAAA;wBAAEP,OAAOO,SAASD,EAAE;wBAAEL,OAAOM,SAASN,KAAK;oBAAC,CAAA;aACxF;YACDS,aACE,sEACA,sEACA;QACJ;QACAF,WAAW,eAAe,mBAAmB;QAC7CA,WAAW,gBAAgB,kCAAkC;QAC7DA,WAAW,gBAAgB,kCAAkC;QAC7DA,WAAW,aAAa,+BAA+B;QACvDA,WAAW,oBAAoB,4BAA4B;QAC3DA,WAAW,iBAAiB,oCAAoC;QAChEA,WAAW,WAAW,8BAA8B;QACpDA,WACE,kBACA,mCACA;QAEFA,WAAW,YAAY,+BAA+B;QACtDA,WAAW,eAAe,kBAAkB;QAC5CA,WAAW,cAAc,iCAAiC;QAC1DA,WAAW,aAAa,gCAAgC;QACxDA,WAAW,YAAY,+BAA+B;QACtDA,WAAW,gBAAgB,mCAAmC;QAC9DA,WAAW,YAAY,+BAA+B;QACtDA,WAAW,gBAAgB,mCAAmC;QAC9DA,WAAW,WAAW,8BAA8B;QACpDA,WAAW,YAAY,+BAA+B;QACtDA,WAAW,aAAa,gCAAgC;QACxDA,WAAW,YAAY,+BAA+B;QACtDA,WAAW,aAAa,gCAAgC;QACxDA,WAAW,gBAAgB,mCAAmC;QAC9DA,WAAW,gBAAgB,qCAAqC;KACjE;IACDS,UAAU;QACRV,UAAUV;OACPqB,OAAOC,WAAW,CACnBD,OAAOE,MAAM,CAACtB,uBAAuBO,GAAG,CAAC,CAACM,MAAQ;YAACA;YAAKd;SAAoB;AAGlF,EAAC"}
@@ -0,0 +1,29 @@
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 { AnthropicCrmAssistanceWording } from './catalog';
18
+ /**
19
+ * CRM assistance as `/legal/subprocessors` published it until October 5,
20
+ * 2026: the disclosed fields of a record, with addresses and numbers in its
21
+ * text replaced. It is still what production sends while
22
+ * `release_crm_assist_whole_record` is off, which the published wording
23
+ * covers: the row describes what the CRM can send, not who has it on.
24
+ *
25
+ * Kept beside the catalog rather than in it: nothing the console runs reads
26
+ * it, and the client barrel exports the whole catalog, so a record of what was
27
+ * published would load on every console page (AGL-3781).
28
+ */
29
+ export declare const ANTHROPIC_CRM_ASSISTANCE_DISCLOSED: AnthropicCrmAssistanceWording;
@@ -0,0 +1,31 @@
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
+ * CRM assistance as `/legal/subprocessors` published it until October 5,
18
+ * 2026: the disclosed fields of a record, with addresses and numbers in its
19
+ * text replaced. It is still what production sends while
20
+ * `release_crm_assist_whole_record` is off, which the published wording
21
+ * covers: the row describes what the CRM can send, not who has it on.
22
+ *
23
+ * Kept beside the catalog rather than in it: nothing the console runs reads
24
+ * it, and the client barrel exports the whole catalog, so a record of what was
25
+ * published would load on every console page (AGL-3781).
26
+ */ export const ANTHROPIC_CRM_ASSISTANCE_DISCLOSED = {
27
+ record: "For CRM assistance, the opened contact, company, deal or lead as the CRM shows it: its name and, by kind, job title, company, lifecycle stage, tags, capture history and counts, domain, industry, headcount, pipeline stages, status, amount, dates, lost reason, parties and lead status, with its notes, newest timeline entries and open tasks and deals. Email addresses and phone numbers in that text are replaced, and no email, phone or postal field, marketing consent, custom field value, team member or record id is sent.",
28
+ never: 'No account identifiers, email addresses or authentication tokens.'
29
+ };
30
+
31
+ //# sourceMappingURL=anthropic-crm-wording-superseded.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/providers/anthropic-crm-wording-superseded.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { AnthropicCrmAssistanceWording } from './catalog'\n\n/**\n * CRM assistance as `/legal/subprocessors` published it until October 5,\n * 2026: the disclosed fields of a record, with addresses and numbers in its\n * text replaced. It is still what production sends while\n * `release_crm_assist_whole_record` is off, which the published wording\n * covers: the row describes what the CRM can send, not who has it on.\n *\n * Kept beside the catalog rather than in it: nothing the console runs reads\n * it, and the client barrel exports the whole catalog, so a record of what was\n * published would load on every console page (AGL-3781).\n */\nexport const ANTHROPIC_CRM_ASSISTANCE_DISCLOSED: AnthropicCrmAssistanceWording = {\n record:\n \"For CRM assistance, the opened contact, company, deal or lead as the CRM shows it: its name and, by kind, job title, company, lifecycle stage, tags, capture history and counts, domain, industry, headcount, pipeline stages, status, amount, dates, lost reason, parties and lead status, with its notes, newest timeline entries and open tasks and deals. Email addresses and phone numbers in that text are replaced, and no email, phone or postal field, marketing consent, custom field value, team member or record id is sent.\",\n never: 'No account identifiers, email addresses or authentication tokens.',\n}\n"],"names":["ANTHROPIC_CRM_ASSISTANCE_DISCLOSED","record","never"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAID;;;;;;;;;;CAUC,GACD,OAAO,MAAMA,qCAAoE;IAC/EC,QACE;IACFC,OAAO;AACT,EAAC"}
@@ -77,6 +77,18 @@ export interface AiCatalogRates {
77
77
  * once so the pair cannot drift.
78
78
  */
79
79
  export declare function aiRatesAtList(inputPerMTok: number, outputPerMTok: number): AiCatalogRates;
80
+ /**
81
+ * THE PLATFORM'S MARKUP over provider cost (AGL-3781): what a customer's
82
+ * credits are charged for a model over what the model costs us, on every
83
+ * figure. The balanced tier's list (Sonnet, $3 / $15 billed over $2 / $10),
84
+ * a picture and the fast tier are billed at it, so a credit carries the same
85
+ * margin whichever of them it is spent on.
86
+ */
87
+ export declare const AI_BILLED_MARKUP = 1.5;
88
+ /** `rates` at the platform's markup: every figure times {@link AI_BILLED_MARKUP}. */
89
+ export declare function aiRatesMarkedUp(rates: AiTokenRates): AiTokenRates;
90
+ /** A row billed at the platform's markup over the provider's list price per MTok. */
91
+ export declare function aiRatesAtMarkup(inputPerMTok: number, outputPerMTok: number): AiCatalogRates;
80
92
  /** {@link aiRatesAtList} for a model whose cache read is not a tenth of its input price. */
81
93
  export declare function aiRatesAtListWithCacheRead(inputPerMTok: number, outputPerMTok: number, cacheReadPerMTok: number): AiCatalogRates;
82
94
  export interface AiCatalogEntry extends AiModelDescriptor, AiCatalogRates {
@@ -101,6 +113,14 @@ export interface AiCatalogEntry extends AiModelDescriptor, AiCatalogRates {
101
113
  * around a cache it never had.
102
114
  */
103
115
  cacheMinTokens: number;
116
+ /**
117
+ * A RETIRED row names the model that serves in its place (AGL-3781). The
118
+ * row stays so usage recorded under its id keeps its price, but nothing
119
+ * offers it or routes to it: a setting, an environment override or a pick
120
+ * that names it is served by the successor, so one model per tier holds
121
+ * the tier's traffic and its one cache namespace.
122
+ */
123
+ successor?: string;
104
124
  }
105
125
  /**
106
126
  * The sentinels a docs-only answer is metered under (AGL-2486): not
@@ -139,14 +159,6 @@ export interface AnthropicCrmAssistanceWording {
139
159
  record: string;
140
160
  never: string;
141
161
  }
142
- /**
143
- * CRM assistance as `/legal/subprocessors` published it until October 5,
144
- * 2026: the disclosed fields of a record, with addresses and numbers in its
145
- * text replaced. It is still what production sends while
146
- * `release_crm_assist_whole_record` is off, which the published wording
147
- * covers: the row describes what the CRM can send, not who has it on.
148
- */
149
- export declare const ANTHROPIC_CRM_ASSISTANCE_DISCLOSED: AnthropicCrmAssistanceWording;
150
162
  /**
151
163
  * CRM assistance once the whole record is sent (AGL-3520): the open-ended
152
164
  * wording the Subprocessors row and Privacy Policy section 2 were
@@ -184,7 +196,7 @@ export declare const AI_MODEL_CATALOG: readonly AiCatalogEntry[];
184
196
  * pricing page on 2026-10-06; a regional endpoint lists 10% higher, so a
185
197
  * deployment that moves off `global` reads its cost low by that much.
186
198
  *
187
- * Every billed figure is the provider figure at `AI_IMAGE_BILLED_MARKUP`:
199
+ * Every billed figure is the provider figure at `AI_BILLED_MARKUP`:
188
200
  * the same ratio the balanced text tier is billed at over its provider rate
189
201
  * (Claude Sonnet 5, $3/$15 billed over $2/$10), so a credit buys the same
190
202
  * share of margin whether it is spent on words or on pictures. A picture is
@@ -210,16 +222,11 @@ export interface AiImageCatalogEntry extends AiCatalogRates {
210
222
  /** What one picture draws from a customer's credits. */
211
223
  billedUsdPerImage: number;
212
224
  }
213
- /**
214
- * The billed rate over the provider rate: the balanced text tier's own markup
215
- * (`claude-sonnet-5`, 3 / 2), restated as a number so an image row cannot be
216
- * written at list by accident.
217
- */
218
- export declare const AI_IMAGE_BILLED_MARKUP = 1.5;
219
225
  /**
220
226
  * An image row's four figures from Google's list prices — USD per output
221
227
  * picture, and USD per million input and text-output tokens — each billed at
222
- * `AI_IMAGE_BILLED_MARKUP`.
228
+ * the platform's markup, `AI_BILLED_MARKUP`, so an image row cannot be written
229
+ * at list by accident.
223
230
  */
224
231
  export declare function aiImageRatesAtMarkup(providerUsdPerImage: number, inputPerMTok: number, outputPerMTok: number): Pick<AiImageCatalogEntry, 'providerUsdPerImage' | 'billedUsdPerImage' | 'providerRates' | 'billedRates'>;
225
232
  /**
@@ -323,5 +330,5 @@ export declare function aiModelIdsForProvider(providerId: string): string[];
323
330
  export type AiStepKind = 'assist.chat' | 'copy.element' | 'copy.section' | 'copy.blog' | 'generate.section' | 'job.component' | 'job.crm' | 'job.edit' | 'job.experiment' | 'job.form' | 'job.insight' | 'job.layout' | 'job.logic' | 'job.template' | 'job.page' | 'job.products' | 'job.seo' | 'job.text' | 'job.theme' | 'job.plan' | 'job.email' | 'job.campaign' | 'job.workflow';
324
331
  /** The tier each step kind is served from when no setting overrides it. */
325
332
  export declare const AI_STEP_TIERS: Record<AiStepKind, AiCatalogEntry['tier']>;
326
- /** The first catalog model of a tier on a provider, or the provider's first model. */
333
+ /** The first current catalog model of a tier on a provider, or the provider's first current model. */
327
334
  export declare function aiDefaultModelFor(providerId: string, tier: AiCatalogEntry['tier']): string | undefined;
@@ -31,6 +31,28 @@
31
31
  billedRates: aiRatesPerMTok(inputPerMTok, outputPerMTok)
32
32
  };
33
33
  }
34
+ /**
35
+ * THE PLATFORM'S MARKUP over provider cost (AGL-3781): what a customer's
36
+ * credits are charged for a model over what the model costs us, on every
37
+ * figure. The balanced tier's list (Sonnet, $3 / $15 billed over $2 / $10),
38
+ * a picture and the fast tier are billed at it, so a credit carries the same
39
+ * margin whichever of them it is spent on.
40
+ */ export const AI_BILLED_MARKUP = 1.5;
41
+ /** `rates` at the platform's markup: every figure times {@link AI_BILLED_MARKUP}. */ export function aiRatesMarkedUp(rates) {
42
+ return {
43
+ inputPerToken: rates.inputPerToken * AI_BILLED_MARKUP,
44
+ outputPerToken: rates.outputPerToken * AI_BILLED_MARKUP,
45
+ cacheReadPerToken: rates.cacheReadPerToken * AI_BILLED_MARKUP,
46
+ cacheWritePerToken: rates.cacheWritePerToken * AI_BILLED_MARKUP
47
+ };
48
+ }
49
+ /** A row billed at the platform's markup over the provider's list price per MTok. */ export function aiRatesAtMarkup(inputPerMTok, outputPerMTok) {
50
+ const providerRates = aiRatesPerMTok(inputPerMTok, outputPerMTok);
51
+ return {
52
+ providerRates,
53
+ billedRates: aiRatesMarkedUp(providerRates)
54
+ };
55
+ }
34
56
  /** {@link aiRatesAtList} for a model whose cache read is not a tenth of its input price. */ export function aiRatesAtListWithCacheRead(inputPerMTok, outputPerMTok, cacheReadPerMTok) {
35
57
  const rates = _extends({}, aiRatesPerMTok(inputPerMTok, outputPerMTok), {
36
58
  cacheReadPerToken: cacheReadPerMTok / 1000000
@@ -57,16 +79,6 @@ const OPENAI_COMPATIBLE = 'openai-compatible';
57
79
  * assistance, worded once for both of the CRM sentences below.
58
80
  */ const ANTHROPIC_DATA_RECEIVED_LEAD = "What the user submits — a question, instruction or brief, with the earlier messages of the same Assist conversation — and the content of the element, post, section or page being worked on, with the generated response. On Pro and above, the organization's name and the console route and host travel with an Assist question. For an edit the assistant proposes in the besigner, an outline of the open page, component or layout: element and component ids, layer names, shortened setting values and the selected element's styles. For a generation job, the site inventory: the names and addresses of its pages and collections, the names of its components, layouts, templates, forms and datasets with their prop and field names, and the theme's summary, colors and fonts. For a theme change, the site's current theme settings and brand colors as hex values, from the organization's brand settings, the site logo in the media library or a public page the brief links to. For features that review or write search information, the text and structure of the pages concerned. For product copy, the store's name, the product's name, type, description, tags, options and search listing, the store's category names, and the product's first media-library photo as a copy at most 768 px on its longer edge with its metadata stripped; never another media file, a price, stock, an order or a customer. For products, categories and discounts proposed from a brief, the store's name and its existing category names. For an automation drafted from a brief, which of CRM, webhooks and bookings the plan includes; for an explanation, the automation's outline (trigger, conditions, each step's text with the names of the lists, campaigns, workflows, webhooks and datasets it uses and whether each exists, and a workflow's function names and expressions) and, for a failed run, its time, steps and recorded errors, with email addresses removed and never the triggering event's data. For an insight, the figure reports available and aggregate tables: traffic with top page paths, referrers and campaign tags; form views and submissions; revenue, orders and best-selling product names; bookings by service; campaign subjects with delivery, open and click rates; A/B test and variant conversions; and, for a dataset the member can see, field names and types, record and fill counts, number ranges and totals grouped by a value at least three records share. Email addresses and phone numbers are removed, and no individual record is sent. ";
59
81
  /** What every CRM door adds after its record sentence: drafts and imports. */ const ANTHROPIC_DATA_RECEIVED_CRM_DRAFTS_AND_IMPORTS = "An email draft adds the request and the record's merge field names; an import sends the field names and types and each column's header and value kind, never a row.";
60
- /**
61
- * CRM assistance as `/legal/subprocessors` published it until October 5,
62
- * 2026: the disclosed fields of a record, with addresses and numbers in its
63
- * text replaced. It is still what production sends while
64
- * `release_crm_assist_whole_record` is off, which the published wording
65
- * covers: the row describes what the CRM can send, not who has it on.
66
- */ export const ANTHROPIC_CRM_ASSISTANCE_DISCLOSED = {
67
- record: "For CRM assistance, the opened contact, company, deal or lead as the CRM shows it: its name and, by kind, job title, company, lifecycle stage, tags, capture history and counts, domain, industry, headcount, pipeline stages, status, amount, dates, lost reason, parties and lead status, with its notes, newest timeline entries and open tasks and deals. Email addresses and phone numbers in that text are replaced, and no email, phone or postal field, marketing consent, custom field value, team member or record id is sent.",
68
- never: 'No account identifiers, email addresses or authentication tokens.'
69
- };
70
82
  /**
71
83
  * CRM assistance once the whole record is sent (AGL-3520): the open-ended
72
84
  * wording the Subprocessors row and Privacy Policy section 2 were
@@ -150,8 +162,10 @@ export const AI_MODEL_CATALOG = [
150
162
  cacheMinTokens: 512
151
163
  },
152
164
  {
153
- // The balanced default until AGL-3660, kept so a workspace that chose it
154
- // and every recording that names it still resolve, at the same rates.
165
+ // The balanced default until AGL-3660, retired to Sonnet 5.5 (AGL-3781):
166
+ // the same price, a cache read half as dear, and a cache namespace of
167
+ // its own that every request on it split the tier's prefixes into. Kept
168
+ // so the usage and recordings that name it still price at its rates.
155
169
  id: 'claude-sonnet-5',
156
170
  provider: ANTHROPIC,
157
171
  label: 'Claude Sonnet 5',
@@ -159,7 +173,8 @@ export const AI_MODEL_CATALOG = [
159
173
  providerRates: aiRatesPerMTok(2, 10),
160
174
  billedRates: aiRatesPerMTok(3, 15),
161
175
  tier: 'balanced',
162
- cacheMinTokens: 1024
176
+ cacheMinTokens: 1024,
177
+ successor: 'claude-sonnet-5-5'
163
178
  },
164
179
  _extends({
165
180
  id: 'claude-sonnet-4-6',
@@ -171,7 +186,31 @@ export const AI_MODEL_CATALOG = [
171
186
  cacheMinTokens: 1024
172
187
  }),
173
188
  _extends({
174
- // Rejects an explicit `thinking` setting; the runtime omits it.
189
+ // THE FAST TIER'S DEFAULT (AGL-3781): the first fast row, so every step
190
+ // routed to fast, a Free site's plan and look, and a page's listing run
191
+ // here. Thinking is adaptive and ON when a request names none, so each
192
+ // fast route says what it wants (`providers/routing.ts`); it accepts
193
+ // `disabled` at effort high or below, refuses budgets, sampling
194
+ // parameters and an assistant prefill, which no door sends, and has no
195
+ // server-side fallback, which none asks for.
196
+ //
197
+ // The provider list is $0.10 / $0.50 for a prompt of 100,000 tokens or
198
+ // fewer and five times that above it; no door sends a prompt near it.
199
+ // Billed at the platform's markup on every figure, $0.15 / $0.75, as the
200
+ // balanced tier and pictures are: Haiku 4.5 was billed at its cost, with
201
+ // no margin at all. Its tokenizer counts the same text as about 30% more
202
+ // tokens than Haiku 4.5's, which the credit figures derived from it say.
203
+ id: 'claude-haiku-5-5',
204
+ provider: ANTHROPIC,
205
+ label: 'Claude Haiku 5.5',
206
+ capabilities: anthropicCapabilities
207
+ }, aiRatesAtMarkup(0.1, 0.5), {
208
+ tier: 'fast',
209
+ cacheMinTokens: 512
210
+ }),
211
+ _extends({
212
+ // The fast default until AGL-3781, retired to Haiku 5.5. Rejects an
213
+ // explicit `thinking` setting; the runtime omits it.
175
214
  id: 'claude-haiku-4-5',
176
215
  provider: ANTHROPIC,
177
216
  label: 'Claude Haiku 4.5',
@@ -181,9 +220,9 @@ export const AI_MODEL_CATALOG = [
181
220
  }, aiRatesAtList(1, 5), {
182
221
  tier: 'fast',
183
222
  // Four times the balanced tier's minimum: the cheapest model per token
184
- // is the hardest one to cache for, which is why a short prompt moved
185
- // here can cost more per request than it saved per token.
186
- cacheMinTokens: 4096
223
+ // was the hardest one to cache for, so no fast-tier prompt ever cached.
224
+ cacheMinTokens: 4096,
225
+ successor: 'claude-haiku-5-5'
187
226
  }),
188
227
  _extends({
189
228
  id: 'claude-opus-5',
@@ -255,22 +294,16 @@ export const AI_MODEL_CATALOG = [
255
294
  cacheMinTokens: 1024
256
295
  })
257
296
  ];
258
- /**
259
- * The billed rate over the provider rate: the balanced text tier's own markup
260
- * (`claude-sonnet-5`, 3 / 2), restated as a number so an image row cannot be
261
- * written at list by accident.
262
- */ export const AI_IMAGE_BILLED_MARKUP = 1.5;
263
297
  /**
264
298
  * An image row's four figures from Google's list prices — USD per output
265
299
  * picture, and USD per million input and text-output tokens — each billed at
266
- * `AI_IMAGE_BILLED_MARKUP`.
300
+ * the platform's markup, `AI_BILLED_MARKUP`, so an image row cannot be written
301
+ * at list by accident.
267
302
  */ export function aiImageRatesAtMarkup(providerUsdPerImage, inputPerMTok, outputPerMTok) {
268
- return {
303
+ return _extends({
269
304
  providerUsdPerImage,
270
- billedUsdPerImage: roundUsd(providerUsdPerImage * AI_IMAGE_BILLED_MARKUP),
271
- providerRates: aiRatesPerMTok(inputPerMTok, outputPerMTok),
272
- billedRates: aiRatesPerMTok(inputPerMTok * AI_IMAGE_BILLED_MARKUP, outputPerMTok * AI_IMAGE_BILLED_MARKUP)
273
- };
305
+ billedUsdPerImage: roundUsd(providerUsdPerImage * AI_BILLED_MARKUP)
306
+ }, aiRatesAtMarkup(inputPerMTok, outputPerMTok));
274
307
  }
275
308
  /**
276
309
  * The image-output tokens Google writes a picture as, by size (AGL-3602),
@@ -493,10 +526,10 @@ function priceUsage(usage, rate) {
493
526
  // closely; the fast tier re-asks more than it saves on both (AGL-2919).
494
527
  'job.workflow': 'balanced'
495
528
  };
496
- /** The first catalog model of a tier on a provider, or the provider's first model. */ export function aiDefaultModelFor(providerId, tier) {
529
+ /** The first current catalog model of a tier on a provider, or the provider's first current model. */ export function aiDefaultModelFor(providerId, tier) {
497
530
  var _onProvider_find;
498
531
  var _this;
499
- const onProvider = AI_MODEL_CATALOG.filter((entry)=>entry.provider === providerId);
532
+ const onProvider = AI_MODEL_CATALOG.filter((entry)=>entry.provider === providerId && !entry.successor);
500
533
  return (_this = (_onProvider_find = onProvider.find((entry)=>entry.tier === tier)) != null ? _onProvider_find : onProvider[0]) == null ? void 0 : _this.id;
501
534
  }
502
535
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/providers/catalog.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PluginSubprocessorDeclaration } from '@aglyn/aglyn/plugin-manager/plugin-subprocessors'\nimport type { AiModelDescriptor, AiUsage } from './contract'\nimport type { AiImageSize } from './image-contract'\n\n/**\n * The model catalog (AGL-2939): every model id the plugin will route to,\n * with its provider, its display name, its capabilities and its list rates.\n * The ONE place a model id is written outside a provider adapter — the\n * routing table maps a step kind to an id through here, the meter prices\n * usage by id through here, and a settings form offers ids from here.\n *\n * ## Two rates, because one figure was answering two questions\n *\n * Every row carries a PROVIDER rate and a BILLED rate (AGL-3015):\n *\n * - `providerRates` is what the vendor charges us. It is money leaving the\n * company, so cost accounting, the margin surfaces and every staff spend\n * meter price usage through this one and no other.\n * - `billedRates` is what a customer's credits are charged at. The credit\n * meter, the band, the overage ladder and the model selector price usage\n * through this one, because it is the figure a customer's balance moves by.\n *\n * They are equal on nearly every row, and a helper writes the pair from one\n * figure so an unmarked row cannot drift apart by a typo. A row may be\n * billed ABOVE its provider rate deliberately — the markup is carried in the\n * rate rather than in the credit conversion, which keeps a credit a fixed\n * quantity of billed spend on every model and leaves the band, the ladder\n * and the invoice on the one arithmetic they were sized with. A row billed\n * BELOW its provider rate would sell tokens at a loss, and\n * `billed-rate-is-not-provider-cost.spec.ts` refuses one.\n *\n * Both are keyed by model rather than fixed at one model's rates because the\n * default is an env override: a one-line incident swap to a dearer model\n * would otherwise keep reporting the cheaper money, and per-org cost would\n * read as roughly right — the failure mode this whole meter exists to\n * prevent. An unknown id falls back to the most EXPENSIVE known tier on\n * purpose, on both rates: an estimate that errs low is worse than one that\n * errs high, whether the figure is our bill or the customer's.\n */\n\nexport interface AiTokenRates {\n inputPerToken: number\n outputPerToken: number\n cacheReadPerToken: number\n cacheWritePerToken: number\n}\n\n/** List price per MTok → per-token rates, cache read at 0.1x, write 1.25x. */\nexport function aiRatesPerMTok(inputPerMTok: number, outputPerMTok: number): AiTokenRates {\n return {\n inputPerToken: inputPerMTok / 1_000_000,\n outputPerToken: outputPerMTok / 1_000_000,\n cacheReadPerToken: (inputPerMTok * 0.1) / 1_000_000,\n cacheWritePerToken: (inputPerMTok * 1.25) / 1_000_000,\n }\n}\n\n/**\n * The two rate tables a catalog row carries. Separate fields rather than one\n * table and a multiplier: a reader that wants our cost has to name it, and\n * a reader that wants the customer's has to name that, so neither can be\n * reached by accident.\n */\nexport interface AiCatalogRates {\n /** What the provider bills us for this model. */\n providerRates: AiTokenRates\n /** What a customer's credits are charged at for this model. */\n billedRates: AiTokenRates\n}\n\n/**\n * A row billed at exactly the provider's list rate — the usual case, written\n * once so the pair cannot drift.\n */\nexport function aiRatesAtList(\n inputPerMTok: number,\n outputPerMTok: number,\n): AiCatalogRates {\n return {\n providerRates: aiRatesPerMTok(inputPerMTok, outputPerMTok),\n billedRates: aiRatesPerMTok(inputPerMTok, outputPerMTok),\n }\n}\n\n/** {@link aiRatesAtList} for a model whose cache read is not a tenth of its input price. */\nexport function aiRatesAtListWithCacheRead(\n inputPerMTok: number,\n outputPerMTok: number,\n cacheReadPerMTok: number,\n): AiCatalogRates {\n const rates = { ...aiRatesPerMTok(inputPerMTok, outputPerMTok), cacheReadPerToken: cacheReadPerMTok / 1_000_000 }\n return { providerRates: rates, billedRates: { ...rates } }\n}\n\nexport interface AiCatalogEntry extends AiModelDescriptor, AiCatalogRates {\n /**\n * The tier a routing decision reads: `fast` for short, constrained\n * answers; `balanced` for the assistant and briefs; `deep` for the\n * dearest, slowest class.\n */\n tier: 'fast' | 'balanced' | 'deep'\n /**\n * The shortest prefix this model's provider will cache (AGL-2937). A\n * request whose cached span falls under it is served with the markers\n * honored and NOTHING cached: no error, no warning, and a usage report\n * that reads as a permanent cache miss.\n *\n * It is a property of the model rather than of the tier or the vendor,\n * and it does not fall as a generation advances — so the number has to be\n * written beside the model, and a door that means to cache has to be held\n * to it (`aiCachedPrefixCaches` in the runtime, and the door table in\n * `runtime/ai-prompt-cache.spec.ts`). Without it, \"this block carries a\n * breakpoint\" is a claim nothing checks, and a prompt can be designed\n * around a cache it never had.\n */\n cacheMinTokens: number\n}\n\n/**\n * The sentinels a docs-only answer is metered under (AGL-2486): not\n * models, but ids the meter sees, priced at zero so a deflected turn lands\n * in the same rollup as a served one and a keyless deployment does not\n * read as the most efficient one on the platform.\n */\nexport const AI_METER_SENTINELS = {\n docsRetrieval: 'docs-retrieval',\n docsLinks: 'docs-links',\n answerCache: 'assist-cache',\n} as const\n\nconst ANTHROPIC = 'anthropic'\nconst OPENAI_COMPATIBLE = 'openai-compatible'\n\n/**\n * A provider's row on the published subprocessor list: every field but the\n * host, which the registered adapter reports as its `endpointHost`.\n * `{apiKeyEnv}` anywhere in the wording stands for the adapter's\n * `apiKeyEnv`, so a credential's name is written in its adapter alone and\n * never in this module, which the browser bundle carries.\n */\nexport type AiProviderSubprocessorWording = Omit<PluginSubprocessorDeclaration, 'host'>\n\n/** A provider the catalog carries models for. */\nexport interface AiCatalogProvider {\n id: string\n /** The name a settings form shows. */\n label: string\n /**\n * The vendor's row on the published subprocessor list, written here and\n * nowhere else: `aiSubprocessors` derives the plugin's declarations from\n * it. Absent for a provider whose endpoint an operator names, which has\n * no fixed recipient to publish.\n */\n subprocessor?: AiProviderSubprocessorWording\n}\n\n/**\n * The Anthropic row's data cell up to its CRM sentence: every door but CRM\n * assistance, worded once for both of the CRM sentences below.\n */\nconst ANTHROPIC_DATA_RECEIVED_LEAD =\n \"What the user submits — a question, instruction or brief, with the earlier messages of the same Assist conversation — and the content of the element, post, section or page being worked on, with the generated response. On Pro and above, the organization's name and the console route and host travel with an Assist question. For an edit the assistant proposes in the besigner, an outline of the open page, component or layout: element and component ids, layer names, shortened setting values and the selected element's styles. For a generation job, the site inventory: the names and addresses of its pages and collections, the names of its components, layouts, templates, forms and datasets with their prop and field names, and the theme's summary, colors and fonts. For a theme change, the site's current theme settings and brand colors as hex values, from the organization's brand settings, the site logo in the media library or a public page the brief links to. For features that review or write search information, the text and structure of the pages concerned. For product copy, the store's name, the product's name, type, description, tags, options and search listing, the store's category names, and the product's first media-library photo as a copy at most 768 px on its longer edge with its metadata stripped; never another media file, a price, stock, an order or a customer. For products, categories and discounts proposed from a brief, the store's name and its existing category names. For an automation drafted from a brief, which of CRM, webhooks and bookings the plan includes; for an explanation, the automation's outline (trigger, conditions, each step's text with the names of the lists, campaigns, workflows, webhooks and datasets it uses and whether each exists, and a workflow's function names and expressions) and, for a failed run, its time, steps and recorded errors, with email addresses removed and never the triggering event's data. For an insight, the figure reports available and aggregate tables: traffic with top page paths, referrers and campaign tags; form views and submissions; revenue, orders and best-selling product names; bookings by service; campaign subjects with delivery, open and click rates; A/B test and variant conversions; and, for a dataset the member can see, field names and types, record and fill counts, number ranges and totals grouped by a value at least three records share. Email addresses and phone numbers are removed, and no individual record is sent. \"\n\n/** What every CRM door adds after its record sentence: drafts and imports. */\nconst ANTHROPIC_DATA_RECEIVED_CRM_DRAFTS_AND_IMPORTS =\n \"An email draft adds the request and the record's merge field names; an import sends the field names and types and each column's header and value kind, never a row.\"\n\n/** How the data cell words CRM assistance: what a record sends, and what never leaves. */\nexport interface AnthropicCrmAssistanceWording {\n record: string\n never: string\n}\n\n/**\n * CRM assistance as `/legal/subprocessors` published it until October 5,\n * 2026: the disclosed fields of a record, with addresses and numbers in its\n * text replaced. It is still what production sends while\n * `release_crm_assist_whole_record` is off, which the published wording\n * covers: the row describes what the CRM can send, not who has it on.\n */\nexport const ANTHROPIC_CRM_ASSISTANCE_DISCLOSED: AnthropicCrmAssistanceWording = {\n record:\n \"For CRM assistance, the opened contact, company, deal or lead as the CRM shows it: its name and, by kind, job title, company, lifecycle stage, tags, capture history and counts, domain, industry, headcount, pipeline stages, status, amount, dates, lost reason, parties and lead status, with its notes, newest timeline entries and open tasks and deals. Email addresses and phone numbers in that text are replaced, and no email, phone or postal field, marketing consent, custom field value, team member or record id is sent.\",\n never: 'No account identifiers, email addresses or authentication tokens.',\n}\n\n/**\n * CRM assistance once the whole record is sent (AGL-3520): the open-ended\n * wording the Subprocessors row and Privacy Policy section 2 were\n * republished with on October 5, 2026 (legal v10), before\n * `release_crm_assist_whole_record` may be turned on. The catalog row below\n * carries it in `dataReceived`.\n */\nexport const ANTHROPIC_CRM_ASSISTANCE_WHOLE_RECORD: AnthropicCrmAssistanceWording = {\n record:\n 'For CRM assistance, the opened record as the CRM shows it, with all of its standard and custom fields, including contact details, notes, timeline and related records.',\n never: 'No account identifiers or authentication tokens, and no email address outside an opened CRM record.',\n}\n\n/** The Anthropic row's data cell, with CRM assistance worded as `crm` words it. */\nexport function anthropicDataReceived(crm: AnthropicCrmAssistanceWording): string {\n return `${ANTHROPIC_DATA_RECEIVED_LEAD}${crm.record} ${ANTHROPIC_DATA_RECEIVED_CRM_DRAFTS_AND_IMPORTS} ${crm.never}`\n}\n\n/**\n * The providers the catalog carries models for, with the name a settings\n * form shows. A form offers providers from here for the reason it offers\n * models from here: nothing outside this folder names a vendor. For the\n * same reason a vendor's subprocessor row is written here too.\n */\nexport const AI_CATALOG_PROVIDERS: readonly AiCatalogProvider[] = [\n {\n id: ANTHROPIC,\n label: 'Anthropic',\n subprocessor: {\n entity: 'Anthropic, PBC',\n region: 'United States',\n purpose:\n \"AI features of the Services, including the Aglyn Assist helper: creating, editing and reviewing content, drafts and settings for a customer’s site, store and CRM, and explaining and summarizing the customer’s own setup and data\",\n publishedOn: '2026-10-07',\n reason:\n \"Reached through the AI plugin's Anthropic adapter (`libs/plugins/ai/src/lib/providers/anthropic.ts`) by the doors that call the AI runtime. `libs/plugins/ai/src/lib/server/assist-chat.ts` is gated by `release_assist` AND the key, and a generation job's text step by `release_ai_generative`; `libs/plugins/ai/src/lib/server/ai-assist.ts` carries NO release flag, so setting `{apiKeyEnv}` in production is by itself what starts this flow. `assist-anthropic-subprocessor-gate.spec.ts` holds the per-door detail and is the deeper guard for this one vendor.\",\n dataReceived: anthropicDataReceived(ANTHROPIC_CRM_ASSISTANCE_WHOLE_RECORD),\n },\n },\n { id: OPENAI_COMPATIBLE, label: 'OpenAI-compatible endpoint' },\n]\n\n/**\n * `vision` is written on every row rather than assumed (AGL-2916): each model\n * below reads a picture in a user turn, in the four formats\n * `AI_IMAGE_MEDIA_TYPES` names, as its vendor documents. A row added without\n * it reads as a model that does not, and is never sent one.\n */\nconst anthropicCapabilities = {\n streaming: true,\n tools: true,\n thinking: true,\n promptCache: true,\n vision: true,\n}\n\nexport const AI_MODEL_CATALOG: readonly AiCatalogEntry[] = [\n {\n // THE BALANCED TIER'S DEFAULT (AGL-3660): the first balanced row is what\n // `aiDefaultModelFor` answers, so Free, \"Auto\" and every step routed to\n // balanced run here. Rejects `thinking: {type: \"disabled\"}` and forced\n // tool choice: the adapter sends thinking off as `between_tools` and\n // every tool call with `tool_choice: auto`.\n id: 'claude-sonnet-5-5',\n provider: ANTHROPIC,\n label: 'Claude Sonnet 5.5',\n capabilities: anthropicCapabilities,\n /*\n * THE ROWS BILLED ABOVE THEIR PROVIDER RATE (AGL-3015).\n *\n * The balanced tier prices most requests, so this markup is most of the\n * platform's AI margin. It is carried in the rate and not in the credit\n * conversion for the reason the module head gives: a credit stays a\n * fixed quantity of billed spend on every model, so the band, the\n * overage ladder and the invoice keep the arithmetic they were sized\n * with, and nothing below has to know which model served a request.\n *\n * Everything that reasons about what we PAY — the margin surfaces, the\n * staff spend meters, the discount guardrail's cost of goods — reads\n * `providerRates`, which is the vendor's published list. Sonnet 5.5's\n * list is Sonnet 5's, except a cache read: $0.10/MTok, a twentieth of\n * input. A customer is billed exactly what Sonnet 5 billed, so the\n * balanced tier's prices do not move when its default does.\n */\n providerRates: { ...aiRatesPerMTok(2, 10), cacheReadPerToken: 0.1 / 1_000_000 },\n billedRates: aiRatesPerMTok(3, 15),\n tier: 'balanced',\n cacheMinTokens: 512,\n },\n {\n // The balanced default until AGL-3660, kept so a workspace that chose it\n // and every recording that names it still resolve, at the same rates.\n id: 'claude-sonnet-5',\n provider: ANTHROPIC,\n label: 'Claude Sonnet 5',\n capabilities: anthropicCapabilities,\n providerRates: aiRatesPerMTok(2, 10),\n billedRates: aiRatesPerMTok(3, 15),\n tier: 'balanced',\n cacheMinTokens: 1_024,\n },\n {\n id: 'claude-sonnet-4-6',\n provider: ANTHROPIC,\n label: 'Claude Sonnet 4.6',\n capabilities: anthropicCapabilities,\n ...aiRatesAtList(3, 15),\n tier: 'balanced',\n cacheMinTokens: 1_024,\n },\n {\n // Rejects an explicit `thinking` setting; the runtime omits it.\n id: 'claude-haiku-4-5',\n provider: ANTHROPIC,\n label: 'Claude Haiku 4.5',\n capabilities: { ...anthropicCapabilities, thinking: false },\n ...aiRatesAtList(1, 5),\n tier: 'fast',\n // Four times the balanced tier's minimum: the cheapest model per token\n // is the hardest one to cache for, which is why a short prompt moved\n // here can cost more per request than it saved per token.\n cacheMinTokens: 4_096,\n },\n {\n id: 'claude-opus-5',\n provider: ANTHROPIC,\n label: 'Claude Opus 5',\n capabilities: anthropicCapabilities,\n ...aiRatesAtList(5, 25),\n tier: 'deep',\n cacheMinTokens: 512,\n },\n {\n // Listed for a side-by-side comparison (AGL-3660); the deep tier's\n // default stays claude-opus-5 above. Thinking cannot be disabled and its\n // effort defaults to medium, so the adapter omits thinking where a step\n // asks for it off and names effort high where a step names none — Opus\n // 5's own default. Forced tool choice is refused; the adapter sends auto.\n id: 'claude-opus-5-5',\n provider: ANTHROPIC,\n label: 'Claude Opus 5.5',\n capabilities: anthropicCapabilities,\n // At list, like its deep-tier siblings. A cache read is $0.20/MTok, a\n // twentieth of input rather than the usual tenth.\n ...aiRatesAtListWithCacheRead(4, 20, 0.2),\n tier: 'deep',\n cacheMinTokens: 512,\n },\n {\n id: 'claude-opus-4-8',\n provider: ANTHROPIC,\n label: 'Claude Opus 4.8',\n capabilities: anthropicCapabilities,\n ...aiRatesAtList(5, 25),\n tier: 'deep',\n cacheMinTokens: 1_024,\n },\n /**\n * The OpenAI-compatible adapter serves whatever the endpoint behind\n * `AI_OPENAI_COMPAT_BASE_URL` serves; these are the ids the routing table\n * may name on it. The figures are the vendor's public list, billed at\n * list: a deployment that reaches its own gateway at a negotiated price\n * is paying less than this says, so its margin reads low rather than\n * high — the direction a cost figure may be wrong in.\n */\n {\n id: 'gpt-5',\n provider: OPENAI_COMPATIBLE,\n label: 'GPT-5',\n capabilities: { streaming: true, tools: true, thinking: false, promptCache: true, vision: true },\n ...aiRatesAtList(1.25, 10),\n tier: 'balanced',\n cacheMinTokens: 1_024,\n },\n {\n id: 'gpt-5-mini',\n provider: OPENAI_COMPATIBLE,\n label: 'GPT-5 mini',\n capabilities: { streaming: true, tools: true, thinking: false, promptCache: true, vision: true },\n ...aiRatesAtList(0.25, 2),\n tier: 'fast',\n cacheMinTokens: 1_024,\n },\n]\n\n/**\n * The IMAGE models (AGL-3602): every model id the Media library's \"Create\n * with AI\" photo mode may route to — Google's Gemini image models on Vertex\n * AI — with a per-picture provider rate and a per-picture billed rate, and the\n * token rates the same request's prompt and thinking are billed at. Kept\n * apart from `AI_MODEL_CATALOG` because nothing that lists text models — the\n * model selector, the routing table, the allotments' allowlists — may ever\n * offer one of these for a conversation.\n *\n * ## The rates\n *\n * Google prices an output picture as image-output tokens: Gemini 3.1 Flash\n * Image writes a 1K picture as 1,120 tokens at $60 per million on the global\n * endpoint, so $0.0672 a picture. Its prompt is input tokens ($0.50 per\n * million) and its thinking is text output ($3.00 per million). Every figure\n * here is the global endpoint's list price, read from Google's Vertex AI\n * pricing page on 2026-10-06; a regional endpoint lists 10% higher, so a\n * deployment that moves off `global` reads its cost low by that much.\n *\n * Every billed figure is the provider figure at `AI_IMAGE_BILLED_MARKUP`:\n * the same ratio the balanced text tier is billed at over its provider rate\n * (Claude Sonnet 5, $3/$15 billed over $2/$10), so a credit buys the same\n * share of margin whether it is spent on words or on pictures. A picture is\n * NEVER billed at provider cost; `billed-rate-is-not-provider-cost.spec.ts`\n * refuses a row that is.\n *\n * A credit is $0.001 of billed spend (`ASSIST_CREDIT_COST_USD`), so the\n * default model's picture is 101 credits before its prompt and thinking.\n *\n * Every per-picture figure on a row is the 1K picture's. A 512 px picture —\n * what the Free plan makes — is written as fewer image tokens at the same\n * per-token rate (`AI_IMAGE_SIZE_OUTPUT_TOKENS`), so it is priced at the 1K\n * figure scaled by its share of tokens: $0.04482 from the provider and\n * $0.06723 billed on the default model, before its prompt and thinking.\n */\nexport interface AiImageCatalogEntry extends AiCatalogRates {\n id: string\n /** The image provider the model is served by. */\n provider: string\n label: string\n /** What the provider bills us for one generated picture. */\n providerUsdPerImage: number\n /** What one picture draws from a customer's credits. */\n billedUsdPerImage: number\n}\n\n/**\n * The billed rate over the provider rate: the balanced text tier's own markup\n * (`claude-sonnet-5`, 3 / 2), restated as a number so an image row cannot be\n * written at list by accident.\n */\nexport const AI_IMAGE_BILLED_MARKUP = 1.5\n\n/**\n * An image row's four figures from Google's list prices — USD per output\n * picture, and USD per million input and text-output tokens — each billed at\n * `AI_IMAGE_BILLED_MARKUP`.\n */\nexport function aiImageRatesAtMarkup(\n providerUsdPerImage: number,\n inputPerMTok: number,\n outputPerMTok: number,\n): Pick<\n AiImageCatalogEntry,\n 'providerUsdPerImage' | 'billedUsdPerImage' | 'providerRates' | 'billedRates'\n> {\n return {\n providerUsdPerImage,\n billedUsdPerImage: roundUsd(providerUsdPerImage * AI_IMAGE_BILLED_MARKUP),\n providerRates: aiRatesPerMTok(inputPerMTok, outputPerMTok),\n billedRates: aiRatesPerMTok(\n inputPerMTok * AI_IMAGE_BILLED_MARKUP,\n outputPerMTok * AI_IMAGE_BILLED_MARKUP,\n ),\n }\n}\n\n/**\n * The image-output tokens Google writes a picture as, by size (AGL-3602),\n * read from the usage of real Gemini 3.1 Flash Image answers on 2026-10-07:\n * 747 at 512 px and 1,120 at 1K. A row's per-picture figures are the 1K\n * picture's; a 512 px picture is priced at its share of them.\n */\nexport const AI_IMAGE_SIZE_OUTPUT_TOKENS: Readonly<Record<AiImageSize, number>> = {\n '512': 747,\n '1K': 1_120,\n}\n\n/** A 1K per-picture figure at `size`, by the size's share of image tokens. */\nfunction atImageSize(usdAt1K: number, size: AiImageSize | undefined): number {\n const tokens = AI_IMAGE_SIZE_OUTPUT_TOKENS[size ?? '1K'] ?? AI_IMAGE_SIZE_OUTPUT_TOKENS['1K']\n return roundUsd((usdAt1K * tokens) / AI_IMAGE_SIZE_OUTPUT_TOKENS['1K'])\n}\n\n/** The image model a photo is made with when the operator names none. */\nexport const AI_IMAGE_DEFAULT_MODEL = 'gemini-3.1-flash-image'\n\n/** The image provider's id: Google's models on Vertex AI. */\nexport const AI_IMAGE_VERTEX_PROVIDER_ID = 'google-vertex'\n\n/**\n * The image providers' rows on the published subprocessor list, kept apart\n * from `AI_CATALOG_PROVIDERS` for the reason the image catalog is kept apart\n * from the text one: a settings form offers text providers from that list,\n * and an image provider answers no conversation. The host is the adapter's\n * published endpoint (`VERTEX_IMAGE_PUBLISHED_HOST`).\n *\n * Google's row is dated to its change-log entry on `/legal/subprocessors`,\n * published with the Privacy Policy §2 sentence naming Google for image\n * generation (legal v12).\n */\nexport const AI_IMAGE_CATALOG_PROVIDERS: readonly AiCatalogProvider[] = [\n {\n id: AI_IMAGE_VERTEX_PROVIDER_ID,\n label: 'Google Vertex AI',\n subprocessor: {\n entity: 'Google LLC (Google Cloud Vertex AI)',\n // The global endpoint, which Google documents as routing and\n // processing a request anywhere in the world, with no data residency\n // guarantee: Google, not Aglyn, chooses the location.\n region: 'Global — Google selects where requests are processed',\n purpose:\n \"AI image generation: creating images for a customer's media library from a description a user writes\",\n publishedOn: '2026-10-08',\n reason:\n \"Reached through the AI plugin's Vertex AI image adapter (`libs/plugins/ai/src/lib/providers/vertex-image.ts`) by the Media library's Create with AI door (`libs/plugins/ai/src/lib/server/ai-media-image.ts`) for every kind that is not drawn as SVG, as the platform's own service account. Off unless `AI_IMAGE_VERTEX_PROJECT` names a Google Cloud project; the console offers those kinds only where `NEXT_PUBLIC_AI_IMAGE_PHOTOS` is `on`. The request carries the description and the kind's fixed style wording, the shape and fixed settings, and nothing else.\",\n dataReceived:\n \"The description the user writes and the shape requested, and the generated image returned. No account identifiers, email addresses, or other content of the customer's site.\",\n },\n },\n]\n\nexport const AI_IMAGE_MODEL_CATALOG: readonly AiImageCatalogEntry[] = [\n {\n // The default: Google's own replacement for Imagen 4, which Vertex AI\n // discontinued in 2026.\n id: 'gemini-3.1-flash-image',\n provider: AI_IMAGE_VERTEX_PROVIDER_ID,\n label: 'Gemini 3.1 Flash Image',\n ...aiImageRatesAtMarkup(0.0672, 0.5, 3),\n },\n {\n id: 'gemini-3.1-flash-lite-image',\n provider: AI_IMAGE_VERTEX_PROVIDER_ID,\n label: 'Gemini 3.1 Flash-Lite Image',\n ...aiImageRatesAtMarkup(0.0336, 0.25, 1.5),\n },\n {\n id: 'gemini-3-pro-image',\n provider: AI_IMAGE_VERTEX_PROVIDER_ID,\n label: 'Gemini 3 Pro Image',\n ...aiImageRatesAtMarkup(0.1344, 2, 12),\n },\n]\n\n/**\n * The per-picture rates an unknown image model id is priced at: the dearest\n * row, on both rates, for the reason `AI_FALLBACK_RATES` gives — an estimate\n * that errs low is worse than one that errs high.\n */\nexport const AI_IMAGE_FALLBACK_RATES: Pick<\n AiImageCatalogEntry,\n 'providerUsdPerImage' | 'billedUsdPerImage'\n> = {\n providerUsdPerImage: Math.max(...AI_IMAGE_MODEL_CATALOG.map((row) => row.providerUsdPerImage)),\n billedUsdPerImage: Math.max(...AI_IMAGE_MODEL_CATALOG.map((row) => row.billedUsdPerImage)),\n}\n\n/** The image catalog row for a model id, or `undefined` for an unknown id. */\nexport function aiImageCatalogEntry(modelId: string): AiImageCatalogEntry | undefined {\n return AI_IMAGE_MODEL_CATALOG.find((entry) => entry.id === modelId)\n}\n\n/** What the provider charges us for one picture from `modelId`, at `size` (1K when absent). */\nexport function aiImageProviderUsdPerImage(modelId: string, size?: AiImageSize): number {\n return atImageSize((aiImageCatalogEntry(modelId) ?? AI_IMAGE_FALLBACK_RATES).providerUsdPerImage, size)\n}\n\n/** What one picture from `modelId` at `size` (1K when absent) draws from a customer's credits. */\nexport function aiImageBilledUsdPerImage(modelId: string, size?: AiImageSize): number {\n return atImageSize((aiImageCatalogEntry(modelId) ?? AI_IMAGE_FALLBACK_RATES).billedUsdPerImage, size)\n}\n\n/**\n * Usage as the meter prices it: a text exchange's tokens, and, for a door\n * that makes pictures, how many it delivered and at what size (1K when\n * absent). `images` is absent on every text exchange, which prices exactly\n * as it always did.\n */\nexport type AiMeteredUsage = AiUsage & { images?: number; imageSize?: AiImageSize }\n\n/** Pictures on a usage record: whole, finite, non-negative, else 0. */\nfunction aiImageCount(usage: AiMeteredUsage): number {\n const value = Number(usage.images ?? 0)\n return Number.isFinite(value) && value > 0 ? Math.floor(value) : 0\n}\n\nfunction roundUsd(value: number): number {\n return Math.round(value * 1_000_000) / 1_000_000\n}\n\n/** The dearest known tier, used when a model id is not in the catalog. */\nexport const AI_FALLBACK_RATES: AiTokenRates = aiRatesPerMTok(10, 50)\n\n/**\n * The minimum an unknown model id is assumed to have: the largest one the\n * catalog knows. It errs the way the rate fallback errs — toward the answer\n * that costs more — so an unrecognized id reads as \"this prompt does not\n * cache\" rather than promising a saving nobody measured.\n */\nexport const AI_FALLBACK_CACHE_MIN_TOKENS = 4_096\n\n/** The shortest prefix a model's provider will cache; the dearest assumption for an unknown id. */\nexport function aiModelCacheMinTokens(modelId: string): number {\n return aiCatalogEntry(modelId)?.cacheMinTokens ?? AI_FALLBACK_CACHE_MIN_TOKENS\n}\n\nconst ZERO_RATES = aiRatesPerMTok(0, 0)\n\n/** The catalog row for a model id, or `undefined` for an unknown id. */\nexport function aiCatalogEntry(modelId: string): AiCatalogEntry | undefined {\n return AI_MODEL_CATALOG.find((entry) => entry.id === modelId)\n}\n\nconst isSentinel = (modelId: string): boolean =>\n (Object.values(AI_METER_SENTINELS) as string[]).includes(modelId)\n\n/**\n * What the PROVIDER charges for a model id — our bill. A meter sentinel is\n * free; an image model's prompt and thinking are priced at its image row's\n * token rates (AGL-3602); an unknown id is priced at the dearest tier.\n *\n * The figure every cost and margin surface prices usage at. Answering the\n * customer's question from here would report a margin the platform does not\n * earn, and answering ours from `aiBilledRatesForModel` reports one it does\n * not pay; the two are separate functions so neither is reachable by\n * forgetting which one was meant.\n */\nexport function aiProviderRatesForModel(modelId: string): AiTokenRates {\n if (isSentinel(modelId)) return ZERO_RATES\n return (\n aiCatalogEntry(modelId)?.providerRates ??\n aiImageCatalogEntry(modelId)?.providerRates ??\n AI_FALLBACK_RATES\n )\n}\n\n/**\n * What a CUSTOMER'S CREDITS are charged at for a model id. A meter sentinel\n * is free; an unknown id is priced at the dearest tier.\n *\n * The figure the credit meter, the band and the model selector price usage\n * at. It is at or above `aiProviderRatesForModel` on every row.\n */\nexport function aiBilledRatesForModel(modelId: string): AiTokenRates {\n if (isSentinel(modelId)) return ZERO_RATES\n return (\n aiCatalogEntry(modelId)?.billedRates ??\n aiImageCatalogEntry(modelId)?.billedRates ??\n AI_FALLBACK_RATES\n )\n}\n\nfunction priceUsage(usage: AiUsage, rate: AiTokenRates): number {\n const raw =\n usage.inputTokens * rate.inputPerToken +\n usage.outputTokens * rate.outputPerToken +\n usage.cacheReadTokens * rate.cacheReadPerToken +\n usage.cacheWriteTokens * rate.cacheWritePerToken\n return Math.round(raw * 1_000_000) / 1_000_000\n}\n\n/**\n * What one exchange COST US, at the serving model's provider rates, rounded\n * to 6dp. Real money, and the only figure a margin may be taken against.\n */\nexport function estimateAiProviderCostUsd(usage: AiMeteredUsage, modelId: string): number {\n return roundUsd(\n priceUsage(usage, aiProviderRatesForModel(modelId)) +\n aiImageCount(usage) * aiImageProviderUsdPerImage(modelId, usage.imageSize),\n )\n}\n\n/**\n * What one exchange DRAWS FROM A CUSTOMER, at the serving model's billed\n * rates, rounded to 6dp — the figure `assistCreditsFromUsd` turns into\n * credits. At or above `estimateAiProviderCostUsd` for the same exchange.\n */\nexport function estimateAiBilledUsd(usage: AiMeteredUsage, modelId: string): number {\n return roundUsd(\n priceUsage(usage, aiBilledRatesForModel(modelId)) +\n aiImageCount(usage) * aiImageBilledUsdPerImage(modelId, usage.imageSize),\n )\n}\n\n/** Every catalog id a provider serves. */\nexport function aiModelIdsForProvider(providerId: string): string[] {\n return AI_MODEL_CATALOG.filter((entry) => entry.provider === providerId).map(\n (entry) => entry.id,\n )\n}\n\n/**\n * What a step asks for, and what the routing table answers with. Every\n * door names its kind here rather than a model, so a model swap — an\n * incident override, an org's own setting, a cheaper model for a cheap\n * step — is one row rather than a search through the doors (AGL-2937).\n */\nexport type AiStepKind =\n | 'assist.chat'\n | 'copy.element'\n | 'copy.section'\n | 'copy.blog'\n | 'generate.section'\n | 'job.component'\n | 'job.crm'\n | 'job.edit'\n | 'job.experiment'\n | 'job.form'\n | 'job.insight'\n | 'job.layout'\n | 'job.logic'\n | 'job.template'\n | 'job.page'\n | 'job.products'\n | 'job.seo'\n | 'job.text'\n | 'job.theme'\n | 'job.plan'\n | 'job.email'\n | 'job.campaign'\n | 'job.workflow'\n\n/** The tier each step kind is served from when no setting overrides it. */\nexport const AI_STEP_TIERS: Record<AiStepKind, AiCatalogEntry['tier']> = {\n 'assist.chat': 'balanced',\n 'copy.element': 'fast',\n 'copy.section': 'balanced',\n 'copy.blog': 'balanced',\n 'generate.section': 'balanced',\n // A reusable component is one structured tree with the typed props it\n // declares, and choosing what becomes a prop is the judgment the step sells.\n 'job.component': 'balanced',\n // CRM by AI (AGL-2917): a record's summary and next step, a deal's stage, a\n // lead's standing, a one-to-one email draft and an import's column matches.\n // Short answers through a strict tool, held to the facts the CRM reports\n // about the record the member opened.\n 'job.crm': 'fast',\n // A change to a page or a layout the site has (AGL-3616): the Assist edit\n // rung's protocol run as a job, held to the closed world of the document's\n // own element ids and to the palette validators. Finding the element a\n // request means, and changing only it, is the judgment; the chat door that\n // proposes the same edits runs on this tier.\n 'job.edit': 'balanced',\n // A/B tests by AI (AGL-2914): variants of one piece of copy, and a\n // result put into words for a verdict code already reached. Short answers\n // through a strict tool, but the judgment a variant sells — which ONE idea\n // to vary so the result says something — is the balanced tier's.\n 'job.experiment': 'balanced',\n // A form is one small tree held to the building rules and to the contract\n // its submissions are read by; a re-ask costs more than the tier saves.\n 'job.form': 'balanced',\n // An insight (AGL-2915) chooses which figures answer a question and says\n // what they show; the trace holds every number, and the judgment of what is\n // worth saying is what the fast tier does worse.\n 'job.insight': 'balanced',\n // A layout or a page template is one structured tree held to every\n // building rule; the fast tier re-asks more than it saves.\n 'job.layout': 'balanced',\n // A site function or variable (AGL-3603): a small structured answer held\n // to the evaluator's grammar, the names it may read and a first run, whose\n // judgment is turning a description into conditions and arithmetic; the\n // fast tier re-asks more than it saves.\n 'job.logic': 'balanced',\n 'job.template': 'balanced',\n // A page section (AGL-2907) is held to the whole page's building rules on\n // every pass, for the same reason.\n 'job.page': 'balanced',\n // A product's copy, a store's first products, or its categories and\n // discounts (AGL-2916): judgment about what a photo shows and what a shopper\n // needs, held to storefront claim rules a re-ask costs more to meet than the\n // tier saves.\n 'job.products': 'balanced',\n // SEO fields, alt text and an audit's fixes (AGL-2910): short answers\n // through a strict tool, held to a length and to the page's own text.\n 'job.seo': 'fast',\n 'job.text': 'balanced',\n // A theme is one structured answer over a small, fixed control set; the\n // judgment is in the color choices, which the fast tier makes worse.\n 'job.theme': 'balanced',\n 'job.plan': 'balanced',\n // An email is one tree held to every building rule, with subject lines\n // whose judgment is the point of asking; the fast tier re-asks more than it\n // saves. A campaign is the same email, drafted into a campaign.\n 'job.email': 'balanced',\n 'job.campaign': 'balanced',\n // An automation is a small structured answer whose judgment is choosing the\n // trigger and steps a description means, and an explanation reads one\n // closely; the fast tier re-asks more than it saves on both (AGL-2919).\n 'job.workflow': 'balanced',\n}\n\n/** The first catalog model of a tier on a provider, or the provider's first model. */\nexport function aiDefaultModelFor(providerId: string, tier: AiCatalogEntry['tier']): string | undefined {\n const onProvider = AI_MODEL_CATALOG.filter((entry) => entry.provider === providerId)\n return (onProvider.find((entry) => entry.tier === tier) ?? onProvider[0])?.id\n}\n"],"names":["aiRatesPerMTok","inputPerMTok","outputPerMTok","inputPerToken","outputPerToken","cacheReadPerToken","cacheWritePerToken","aiRatesAtList","providerRates","billedRates","aiRatesAtListWithCacheRead","cacheReadPerMTok","rates","AI_METER_SENTINELS","docsRetrieval","docsLinks","answerCache","ANTHROPIC","OPENAI_COMPATIBLE","ANTHROPIC_DATA_RECEIVED_LEAD","ANTHROPIC_DATA_RECEIVED_CRM_DRAFTS_AND_IMPORTS","ANTHROPIC_CRM_ASSISTANCE_DISCLOSED","record","never","ANTHROPIC_CRM_ASSISTANCE_WHOLE_RECORD","anthropicDataReceived","crm","AI_CATALOG_PROVIDERS","id","label","subprocessor","entity","region","purpose","publishedOn","reason","dataReceived","anthropicCapabilities","streaming","tools","thinking","promptCache","vision","AI_MODEL_CATALOG","provider","capabilities","tier","cacheMinTokens","AI_IMAGE_BILLED_MARKUP","aiImageRatesAtMarkup","providerUsdPerImage","billedUsdPerImage","roundUsd","AI_IMAGE_SIZE_OUTPUT_TOKENS","atImageSize","usdAt1K","size","tokens","AI_IMAGE_DEFAULT_MODEL","AI_IMAGE_VERTEX_PROVIDER_ID","AI_IMAGE_CATALOG_PROVIDERS","AI_IMAGE_MODEL_CATALOG","AI_IMAGE_FALLBACK_RATES","Math","max","map","row","aiImageCatalogEntry","modelId","find","entry","aiImageProviderUsdPerImage","aiImageBilledUsdPerImage","aiImageCount","usage","value","Number","images","isFinite","floor","round","AI_FALLBACK_RATES","AI_FALLBACK_CACHE_MIN_TOKENS","aiModelCacheMinTokens","aiCatalogEntry","ZERO_RATES","isSentinel","Object","values","includes","aiProviderRatesForModel","aiBilledRatesForModel","priceUsage","rate","raw","inputTokens","outputTokens","cacheReadTokens","cacheWriteTokens","estimateAiProviderCostUsd","imageSize","estimateAiBilledUsd","aiModelIdsForProvider","providerId","filter","AI_STEP_TIERS","aiDefaultModelFor","onProvider"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAiDD,4EAA4E,GAC5E,OAAO,SAASA,eAAeC,YAAoB,EAAEC,aAAqB;IACxE,OAAO;QACLC,eAAeF,eAAe;QAC9BG,gBAAgBF,gBAAgB;QAChCG,mBAAmB,AAACJ,eAAe,MAAO;QAC1CK,oBAAoB,AAACL,eAAe,OAAQ;IAC9C;AACF;AAeA;;;CAGC,GACD,OAAO,SAASM,cACdN,YAAoB,EACpBC,aAAqB;IAErB,OAAO;QACLM,eAAeR,eAAeC,cAAcC;QAC5CO,aAAaT,eAAeC,cAAcC;IAC5C;AACF;AAEA,0FAA0F,GAC1F,OAAO,SAASQ,2BACdT,YAAoB,EACpBC,aAAqB,EACrBS,gBAAwB;IAExB,MAAMC,QAAQ,aAAKZ,eAAeC,cAAcC;QAAgBG,mBAAmBM,mBAAmB;;IACtG,OAAO;QAAEH,eAAeI;QAAOH,aAAa,aAAKG;IAAQ;AAC3D;AA0BA;;;;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,sEAAsE;IACtE,wEAAwE;IACxE,gBAAgB;AAClB,EAAC;AAED,oFAAoF,GACpF,OAAO,SAASC,kBAAkBH,UAAkB,EAAEzD,IAA4B;QAExE6D;QAAAA;IADR,MAAMA,aAAahE,iBAAiB6D,MAAM,CAAC,CAAClC,QAAUA,MAAM1B,QAAQ,KAAK2D;IACzE,QAAQI,SAAAA,mBAAAA,WAAWtC,IAAI,CAAC,CAACC,QAAUA,MAAMxB,IAAI,KAAKA,iBAA1C6D,mBAAmDA,UAAU,CAAC,EAAE,qBAAjE,AAACA,MAAmE/E,EAAE;AAC/E"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/providers/catalog.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PluginSubprocessorDeclaration } from '@aglyn/aglyn/plugin-manager/plugin-subprocessors'\nimport type { AiModelDescriptor, AiUsage } from './contract'\nimport type { AiImageSize } from './image-contract'\n\n/**\n * The model catalog (AGL-2939): every model id the plugin will route to,\n * with its provider, its display name, its capabilities and its list rates.\n * The ONE place a model id is written outside a provider adapter — the\n * routing table maps a step kind to an id through here, the meter prices\n * usage by id through here, and a settings form offers ids from here.\n *\n * ## Two rates, because one figure was answering two questions\n *\n * Every row carries a PROVIDER rate and a BILLED rate (AGL-3015):\n *\n * - `providerRates` is what the vendor charges us. It is money leaving the\n * company, so cost accounting, the margin surfaces and every staff spend\n * meter price usage through this one and no other.\n * - `billedRates` is what a customer's credits are charged at. The credit\n * meter, the band, the overage ladder and the model selector price usage\n * through this one, because it is the figure a customer's balance moves by.\n *\n * They are equal on nearly every row, and a helper writes the pair from one\n * figure so an unmarked row cannot drift apart by a typo. A row may be\n * billed ABOVE its provider rate deliberately — the markup is carried in the\n * rate rather than in the credit conversion, which keeps a credit a fixed\n * quantity of billed spend on every model and leaves the band, the ladder\n * and the invoice on the one arithmetic they were sized with. A row billed\n * BELOW its provider rate would sell tokens at a loss, and\n * `billed-rate-is-not-provider-cost.spec.ts` refuses one.\n *\n * Both are keyed by model rather than fixed at one model's rates because the\n * default is an env override: a one-line incident swap to a dearer model\n * would otherwise keep reporting the cheaper money, and per-org cost would\n * read as roughly right — the failure mode this whole meter exists to\n * prevent. An unknown id falls back to the most EXPENSIVE known tier on\n * purpose, on both rates: an estimate that errs low is worse than one that\n * errs high, whether the figure is our bill or the customer's.\n */\n\nexport interface AiTokenRates {\n inputPerToken: number\n outputPerToken: number\n cacheReadPerToken: number\n cacheWritePerToken: number\n}\n\n/** List price per MTok → per-token rates, cache read at 0.1x, write 1.25x. */\nexport function aiRatesPerMTok(inputPerMTok: number, outputPerMTok: number): AiTokenRates {\n return {\n inputPerToken: inputPerMTok / 1_000_000,\n outputPerToken: outputPerMTok / 1_000_000,\n cacheReadPerToken: (inputPerMTok * 0.1) / 1_000_000,\n cacheWritePerToken: (inputPerMTok * 1.25) / 1_000_000,\n }\n}\n\n/**\n * The two rate tables a catalog row carries. Separate fields rather than one\n * table and a multiplier: a reader that wants our cost has to name it, and\n * a reader that wants the customer's has to name that, so neither can be\n * reached by accident.\n */\nexport interface AiCatalogRates {\n /** What the provider bills us for this model. */\n providerRates: AiTokenRates\n /** What a customer's credits are charged at for this model. */\n billedRates: AiTokenRates\n}\n\n/**\n * A row billed at exactly the provider's list rate — the usual case, written\n * once so the pair cannot drift.\n */\nexport function aiRatesAtList(\n inputPerMTok: number,\n outputPerMTok: number,\n): AiCatalogRates {\n return {\n providerRates: aiRatesPerMTok(inputPerMTok, outputPerMTok),\n billedRates: aiRatesPerMTok(inputPerMTok, outputPerMTok),\n }\n}\n\n/**\n * THE PLATFORM'S MARKUP over provider cost (AGL-3781): what a customer's\n * credits are charged for a model over what the model costs us, on every\n * figure. The balanced tier's list (Sonnet, $3 / $15 billed over $2 / $10),\n * a picture and the fast tier are billed at it, so a credit carries the same\n * margin whichever of them it is spent on.\n */\nexport const AI_BILLED_MARKUP = 1.5\n\n/** `rates` at the platform's markup: every figure times {@link AI_BILLED_MARKUP}. */\nexport function aiRatesMarkedUp(rates: AiTokenRates): AiTokenRates {\n return {\n inputPerToken: rates.inputPerToken * AI_BILLED_MARKUP,\n outputPerToken: rates.outputPerToken * AI_BILLED_MARKUP,\n cacheReadPerToken: rates.cacheReadPerToken * AI_BILLED_MARKUP,\n cacheWritePerToken: rates.cacheWritePerToken * AI_BILLED_MARKUP,\n }\n}\n\n/** A row billed at the platform's markup over the provider's list price per MTok. */\nexport function aiRatesAtMarkup(inputPerMTok: number, outputPerMTok: number): AiCatalogRates {\n const providerRates = aiRatesPerMTok(inputPerMTok, outputPerMTok)\n return { providerRates, billedRates: aiRatesMarkedUp(providerRates) }\n}\n\n/** {@link aiRatesAtList} for a model whose cache read is not a tenth of its input price. */\nexport function aiRatesAtListWithCacheRead(\n inputPerMTok: number,\n outputPerMTok: number,\n cacheReadPerMTok: number,\n): AiCatalogRates {\n const rates = { ...aiRatesPerMTok(inputPerMTok, outputPerMTok), cacheReadPerToken: cacheReadPerMTok / 1_000_000 }\n return { providerRates: rates, billedRates: { ...rates } }\n}\n\nexport interface AiCatalogEntry extends AiModelDescriptor, AiCatalogRates {\n /**\n * The tier a routing decision reads: `fast` for short, constrained\n * answers; `balanced` for the assistant and briefs; `deep` for the\n * dearest, slowest class.\n */\n tier: 'fast' | 'balanced' | 'deep'\n /**\n * The shortest prefix this model's provider will cache (AGL-2937). A\n * request whose cached span falls under it is served with the markers\n * honored and NOTHING cached: no error, no warning, and a usage report\n * that reads as a permanent cache miss.\n *\n * It is a property of the model rather than of the tier or the vendor,\n * and it does not fall as a generation advances — so the number has to be\n * written beside the model, and a door that means to cache has to be held\n * to it (`aiCachedPrefixCaches` in the runtime, and the door table in\n * `runtime/ai-prompt-cache.spec.ts`). Without it, \"this block carries a\n * breakpoint\" is a claim nothing checks, and a prompt can be designed\n * around a cache it never had.\n */\n cacheMinTokens: number\n /**\n * A RETIRED row names the model that serves in its place (AGL-3781). The\n * row stays so usage recorded under its id keeps its price, but nothing\n * offers it or routes to it: a setting, an environment override or a pick\n * that names it is served by the successor, so one model per tier holds\n * the tier's traffic and its one cache namespace.\n */\n successor?: string\n}\n\n/**\n * The sentinels a docs-only answer is metered under (AGL-2486): not\n * models, but ids the meter sees, priced at zero so a deflected turn lands\n * in the same rollup as a served one and a keyless deployment does not\n * read as the most efficient one on the platform.\n */\nexport const AI_METER_SENTINELS = {\n docsRetrieval: 'docs-retrieval',\n docsLinks: 'docs-links',\n answerCache: 'assist-cache',\n} as const\n\nconst ANTHROPIC = 'anthropic'\nconst OPENAI_COMPATIBLE = 'openai-compatible'\n\n/**\n * A provider's row on the published subprocessor list: every field but the\n * host, which the registered adapter reports as its `endpointHost`.\n * `{apiKeyEnv}` anywhere in the wording stands for the adapter's\n * `apiKeyEnv`, so a credential's name is written in its adapter alone and\n * never in this module, which the browser bundle carries.\n */\nexport type AiProviderSubprocessorWording = Omit<PluginSubprocessorDeclaration, 'host'>\n\n/** A provider the catalog carries models for. */\nexport interface AiCatalogProvider {\n id: string\n /** The name a settings form shows. */\n label: string\n /**\n * The vendor's row on the published subprocessor list, written here and\n * nowhere else: `aiSubprocessors` derives the plugin's declarations from\n * it. Absent for a provider whose endpoint an operator names, which has\n * no fixed recipient to publish.\n */\n subprocessor?: AiProviderSubprocessorWording\n}\n\n/**\n * The Anthropic row's data cell up to its CRM sentence: every door but CRM\n * assistance, worded once for both of the CRM sentences below.\n */\nconst ANTHROPIC_DATA_RECEIVED_LEAD =\n \"What the user submits — a question, instruction or brief, with the earlier messages of the same Assist conversation — and the content of the element, post, section or page being worked on, with the generated response. On Pro and above, the organization's name and the console route and host travel with an Assist question. For an edit the assistant proposes in the besigner, an outline of the open page, component or layout: element and component ids, layer names, shortened setting values and the selected element's styles. For a generation job, the site inventory: the names and addresses of its pages and collections, the names of its components, layouts, templates, forms and datasets with their prop and field names, and the theme's summary, colors and fonts. For a theme change, the site's current theme settings and brand colors as hex values, from the organization's brand settings, the site logo in the media library or a public page the brief links to. For features that review or write search information, the text and structure of the pages concerned. For product copy, the store's name, the product's name, type, description, tags, options and search listing, the store's category names, and the product's first media-library photo as a copy at most 768 px on its longer edge with its metadata stripped; never another media file, a price, stock, an order or a customer. For products, categories and discounts proposed from a brief, the store's name and its existing category names. For an automation drafted from a brief, which of CRM, webhooks and bookings the plan includes; for an explanation, the automation's outline (trigger, conditions, each step's text with the names of the lists, campaigns, workflows, webhooks and datasets it uses and whether each exists, and a workflow's function names and expressions) and, for a failed run, its time, steps and recorded errors, with email addresses removed and never the triggering event's data. For an insight, the figure reports available and aggregate tables: traffic with top page paths, referrers and campaign tags; form views and submissions; revenue, orders and best-selling product names; bookings by service; campaign subjects with delivery, open and click rates; A/B test and variant conversions; and, for a dataset the member can see, field names and types, record and fill counts, number ranges and totals grouped by a value at least three records share. Email addresses and phone numbers are removed, and no individual record is sent. \"\n\n/** What every CRM door adds after its record sentence: drafts and imports. */\nconst ANTHROPIC_DATA_RECEIVED_CRM_DRAFTS_AND_IMPORTS =\n \"An email draft adds the request and the record's merge field names; an import sends the field names and types and each column's header and value kind, never a row.\"\n\n/** How the data cell words CRM assistance: what a record sends, and what never leaves. */\nexport interface AnthropicCrmAssistanceWording {\n record: string\n never: string\n}\n\n/**\n * CRM assistance once the whole record is sent (AGL-3520): the open-ended\n * wording the Subprocessors row and Privacy Policy section 2 were\n * republished with on October 5, 2026 (legal v10), before\n * `release_crm_assist_whole_record` may be turned on. The catalog row below\n * carries it in `dataReceived`.\n */\nexport const ANTHROPIC_CRM_ASSISTANCE_WHOLE_RECORD: AnthropicCrmAssistanceWording = {\n record:\n 'For CRM assistance, the opened record as the CRM shows it, with all of its standard and custom fields, including contact details, notes, timeline and related records.',\n never: 'No account identifiers or authentication tokens, and no email address outside an opened CRM record.',\n}\n\n/** The Anthropic row's data cell, with CRM assistance worded as `crm` words it. */\nexport function anthropicDataReceived(crm: AnthropicCrmAssistanceWording): string {\n return `${ANTHROPIC_DATA_RECEIVED_LEAD}${crm.record} ${ANTHROPIC_DATA_RECEIVED_CRM_DRAFTS_AND_IMPORTS} ${crm.never}`\n}\n\n/**\n * The providers the catalog carries models for, with the name a settings\n * form shows. A form offers providers from here for the reason it offers\n * models from here: nothing outside this folder names a vendor. For the\n * same reason a vendor's subprocessor row is written here too.\n */\nexport const AI_CATALOG_PROVIDERS: readonly AiCatalogProvider[] = [\n {\n id: ANTHROPIC,\n label: 'Anthropic',\n subprocessor: {\n entity: 'Anthropic, PBC',\n region: 'United States',\n purpose:\n \"AI features of the Services, including the Aglyn Assist helper: creating, editing and reviewing content, drafts and settings for a customer’s site, store and CRM, and explaining and summarizing the customer’s own setup and data\",\n publishedOn: '2026-10-07',\n reason:\n \"Reached through the AI plugin's Anthropic adapter (`libs/plugins/ai/src/lib/providers/anthropic.ts`) by the doors that call the AI runtime. `libs/plugins/ai/src/lib/server/assist-chat.ts` is gated by `release_assist` AND the key, and a generation job's text step by `release_ai_generative`; `libs/plugins/ai/src/lib/server/ai-assist.ts` carries NO release flag, so setting `{apiKeyEnv}` in production is by itself what starts this flow. `assist-anthropic-subprocessor-gate.spec.ts` holds the per-door detail and is the deeper guard for this one vendor.\",\n dataReceived: anthropicDataReceived(ANTHROPIC_CRM_ASSISTANCE_WHOLE_RECORD),\n },\n },\n { id: OPENAI_COMPATIBLE, label: 'OpenAI-compatible endpoint' },\n]\n\n/**\n * `vision` is written on every row rather than assumed (AGL-2916): each model\n * below reads a picture in a user turn, in the four formats\n * `AI_IMAGE_MEDIA_TYPES` names, as its vendor documents. A row added without\n * it reads as a model that does not, and is never sent one.\n */\nconst anthropicCapabilities = {\n streaming: true,\n tools: true,\n thinking: true,\n promptCache: true,\n vision: true,\n}\n\nexport const AI_MODEL_CATALOG: readonly AiCatalogEntry[] = [\n {\n // THE BALANCED TIER'S DEFAULT (AGL-3660): the first balanced row is what\n // `aiDefaultModelFor` answers, so Free, \"Auto\" and every step routed to\n // balanced run here. Rejects `thinking: {type: \"disabled\"}` and forced\n // tool choice: the adapter sends thinking off as `between_tools` and\n // every tool call with `tool_choice: auto`.\n id: 'claude-sonnet-5-5',\n provider: ANTHROPIC,\n label: 'Claude Sonnet 5.5',\n capabilities: anthropicCapabilities,\n /*\n * THE ROWS BILLED ABOVE THEIR PROVIDER RATE (AGL-3015).\n *\n * The balanced tier prices most requests, so this markup is most of the\n * platform's AI margin. It is carried in the rate and not in the credit\n * conversion for the reason the module head gives: a credit stays a\n * fixed quantity of billed spend on every model, so the band, the\n * overage ladder and the invoice keep the arithmetic they were sized\n * with, and nothing below has to know which model served a request.\n *\n * Everything that reasons about what we PAY — the margin surfaces, the\n * staff spend meters, the discount guardrail's cost of goods — reads\n * `providerRates`, which is the vendor's published list. Sonnet 5.5's\n * list is Sonnet 5's, except a cache read: $0.10/MTok, a twentieth of\n * input. A customer is billed exactly what Sonnet 5 billed, so the\n * balanced tier's prices do not move when its default does.\n */\n providerRates: { ...aiRatesPerMTok(2, 10), cacheReadPerToken: 0.1 / 1_000_000 },\n billedRates: aiRatesPerMTok(3, 15),\n tier: 'balanced',\n cacheMinTokens: 512,\n },\n {\n // The balanced default until AGL-3660, retired to Sonnet 5.5 (AGL-3781):\n // the same price, a cache read half as dear, and a cache namespace of\n // its own that every request on it split the tier's prefixes into. Kept\n // so the usage and recordings that name it still price at its rates.\n id: 'claude-sonnet-5',\n provider: ANTHROPIC,\n label: 'Claude Sonnet 5',\n capabilities: anthropicCapabilities,\n providerRates: aiRatesPerMTok(2, 10),\n billedRates: aiRatesPerMTok(3, 15),\n tier: 'balanced',\n cacheMinTokens: 1_024,\n successor: 'claude-sonnet-5-5',\n },\n {\n id: 'claude-sonnet-4-6',\n provider: ANTHROPIC,\n label: 'Claude Sonnet 4.6',\n capabilities: anthropicCapabilities,\n ...aiRatesAtList(3, 15),\n tier: 'balanced',\n cacheMinTokens: 1_024,\n },\n {\n // THE FAST TIER'S DEFAULT (AGL-3781): the first fast row, so every step\n // routed to fast, a Free site's plan and look, and a page's listing run\n // here. Thinking is adaptive and ON when a request names none, so each\n // fast route says what it wants (`providers/routing.ts`); it accepts\n // `disabled` at effort high or below, refuses budgets, sampling\n // parameters and an assistant prefill, which no door sends, and has no\n // server-side fallback, which none asks for.\n //\n // The provider list is $0.10 / $0.50 for a prompt of 100,000 tokens or\n // fewer and five times that above it; no door sends a prompt near it.\n // Billed at the platform's markup on every figure, $0.15 / $0.75, as the\n // balanced tier and pictures are: Haiku 4.5 was billed at its cost, with\n // no margin at all. Its tokenizer counts the same text as about 30% more\n // tokens than Haiku 4.5's, which the credit figures derived from it say.\n id: 'claude-haiku-5-5',\n provider: ANTHROPIC,\n label: 'Claude Haiku 5.5',\n capabilities: anthropicCapabilities,\n ...aiRatesAtMarkup(0.1, 0.5),\n tier: 'fast',\n cacheMinTokens: 512,\n },\n {\n // The fast default until AGL-3781, retired to Haiku 5.5. Rejects an\n // explicit `thinking` setting; the runtime omits it.\n id: 'claude-haiku-4-5',\n provider: ANTHROPIC,\n label: 'Claude Haiku 4.5',\n capabilities: { ...anthropicCapabilities, thinking: false },\n ...aiRatesAtList(1, 5),\n tier: 'fast',\n // Four times the balanced tier's minimum: the cheapest model per token\n // was the hardest one to cache for, so no fast-tier prompt ever cached.\n cacheMinTokens: 4_096,\n successor: 'claude-haiku-5-5',\n },\n {\n id: 'claude-opus-5',\n provider: ANTHROPIC,\n label: 'Claude Opus 5',\n capabilities: anthropicCapabilities,\n ...aiRatesAtList(5, 25),\n tier: 'deep',\n cacheMinTokens: 512,\n },\n {\n // Listed for a side-by-side comparison (AGL-3660); the deep tier's\n // default stays claude-opus-5 above. Thinking cannot be disabled and its\n // effort defaults to medium, so the adapter omits thinking where a step\n // asks for it off and names effort high where a step names none — Opus\n // 5's own default. Forced tool choice is refused; the adapter sends auto.\n id: 'claude-opus-5-5',\n provider: ANTHROPIC,\n label: 'Claude Opus 5.5',\n capabilities: anthropicCapabilities,\n // At list, like its deep-tier siblings. A cache read is $0.20/MTok, a\n // twentieth of input rather than the usual tenth.\n ...aiRatesAtListWithCacheRead(4, 20, 0.2),\n tier: 'deep',\n cacheMinTokens: 512,\n },\n {\n id: 'claude-opus-4-8',\n provider: ANTHROPIC,\n label: 'Claude Opus 4.8',\n capabilities: anthropicCapabilities,\n ...aiRatesAtList(5, 25),\n tier: 'deep',\n cacheMinTokens: 1_024,\n },\n /**\n * The OpenAI-compatible adapter serves whatever the endpoint behind\n * `AI_OPENAI_COMPAT_BASE_URL` serves; these are the ids the routing table\n * may name on it. The figures are the vendor's public list, billed at\n * list: a deployment that reaches its own gateway at a negotiated price\n * is paying less than this says, so its margin reads low rather than\n * high — the direction a cost figure may be wrong in.\n */\n {\n id: 'gpt-5',\n provider: OPENAI_COMPATIBLE,\n label: 'GPT-5',\n capabilities: { streaming: true, tools: true, thinking: false, promptCache: true, vision: true },\n ...aiRatesAtList(1.25, 10),\n tier: 'balanced',\n cacheMinTokens: 1_024,\n },\n {\n id: 'gpt-5-mini',\n provider: OPENAI_COMPATIBLE,\n label: 'GPT-5 mini',\n capabilities: { streaming: true, tools: true, thinking: false, promptCache: true, vision: true },\n ...aiRatesAtList(0.25, 2),\n tier: 'fast',\n cacheMinTokens: 1_024,\n },\n]\n\n/**\n * The IMAGE models (AGL-3602): every model id the Media library's \"Create\n * with AI\" photo mode may route to — Google's Gemini image models on Vertex\n * AI — with a per-picture provider rate and a per-picture billed rate, and the\n * token rates the same request's prompt and thinking are billed at. Kept\n * apart from `AI_MODEL_CATALOG` because nothing that lists text models — the\n * model selector, the routing table, the allotments' allowlists — may ever\n * offer one of these for a conversation.\n *\n * ## The rates\n *\n * Google prices an output picture as image-output tokens: Gemini 3.1 Flash\n * Image writes a 1K picture as 1,120 tokens at $60 per million on the global\n * endpoint, so $0.0672 a picture. Its prompt is input tokens ($0.50 per\n * million) and its thinking is text output ($3.00 per million). Every figure\n * here is the global endpoint's list price, read from Google's Vertex AI\n * pricing page on 2026-10-06; a regional endpoint lists 10% higher, so a\n * deployment that moves off `global` reads its cost low by that much.\n *\n * Every billed figure is the provider figure at `AI_BILLED_MARKUP`:\n * the same ratio the balanced text tier is billed at over its provider rate\n * (Claude Sonnet 5, $3/$15 billed over $2/$10), so a credit buys the same\n * share of margin whether it is spent on words or on pictures. A picture is\n * NEVER billed at provider cost; `billed-rate-is-not-provider-cost.spec.ts`\n * refuses a row that is.\n *\n * A credit is $0.001 of billed spend (`ASSIST_CREDIT_COST_USD`), so the\n * default model's picture is 101 credits before its prompt and thinking.\n *\n * Every per-picture figure on a row is the 1K picture's. A 512 px picture —\n * what the Free plan makes — is written as fewer image tokens at the same\n * per-token rate (`AI_IMAGE_SIZE_OUTPUT_TOKENS`), so it is priced at the 1K\n * figure scaled by its share of tokens: $0.04482 from the provider and\n * $0.06723 billed on the default model, before its prompt and thinking.\n */\nexport interface AiImageCatalogEntry extends AiCatalogRates {\n id: string\n /** The image provider the model is served by. */\n provider: string\n label: string\n /** What the provider bills us for one generated picture. */\n providerUsdPerImage: number\n /** What one picture draws from a customer's credits. */\n billedUsdPerImage: number\n}\n\n/**\n * An image row's four figures from Google's list prices — USD per output\n * picture, and USD per million input and text-output tokens — each billed at\n * the platform's markup, `AI_BILLED_MARKUP`, so an image row cannot be written\n * at list by accident.\n */\nexport function aiImageRatesAtMarkup(\n providerUsdPerImage: number,\n inputPerMTok: number,\n outputPerMTok: number,\n): Pick<\n AiImageCatalogEntry,\n 'providerUsdPerImage' | 'billedUsdPerImage' | 'providerRates' | 'billedRates'\n> {\n return {\n providerUsdPerImage,\n billedUsdPerImage: roundUsd(providerUsdPerImage * AI_BILLED_MARKUP),\n ...aiRatesAtMarkup(inputPerMTok, outputPerMTok),\n }\n}\n\n/**\n * The image-output tokens Google writes a picture as, by size (AGL-3602),\n * read from the usage of real Gemini 3.1 Flash Image answers on 2026-10-07:\n * 747 at 512 px and 1,120 at 1K. A row's per-picture figures are the 1K\n * picture's; a 512 px picture is priced at its share of them.\n */\nexport const AI_IMAGE_SIZE_OUTPUT_TOKENS: Readonly<Record<AiImageSize, number>> = {\n '512': 747,\n '1K': 1_120,\n}\n\n/** A 1K per-picture figure at `size`, by the size's share of image tokens. */\nfunction atImageSize(usdAt1K: number, size: AiImageSize | undefined): number {\n const tokens = AI_IMAGE_SIZE_OUTPUT_TOKENS[size ?? '1K'] ?? AI_IMAGE_SIZE_OUTPUT_TOKENS['1K']\n return roundUsd((usdAt1K * tokens) / AI_IMAGE_SIZE_OUTPUT_TOKENS['1K'])\n}\n\n/** The image model a photo is made with when the operator names none. */\nexport const AI_IMAGE_DEFAULT_MODEL = 'gemini-3.1-flash-image'\n\n/** The image provider's id: Google's models on Vertex AI. */\nexport const AI_IMAGE_VERTEX_PROVIDER_ID = 'google-vertex'\n\n/**\n * The image providers' rows on the published subprocessor list, kept apart\n * from `AI_CATALOG_PROVIDERS` for the reason the image catalog is kept apart\n * from the text one: a settings form offers text providers from that list,\n * and an image provider answers no conversation. The host is the adapter's\n * published endpoint (`VERTEX_IMAGE_PUBLISHED_HOST`).\n *\n * Google's row is dated to its change-log entry on `/legal/subprocessors`,\n * published with the Privacy Policy §2 sentence naming Google for image\n * generation (legal v12).\n */\nexport const AI_IMAGE_CATALOG_PROVIDERS: readonly AiCatalogProvider[] = [\n {\n id: AI_IMAGE_VERTEX_PROVIDER_ID,\n label: 'Google Vertex AI',\n subprocessor: {\n entity: 'Google LLC (Google Cloud Vertex AI)',\n // The global endpoint, which Google documents as routing and\n // processing a request anywhere in the world, with no data residency\n // guarantee: Google, not Aglyn, chooses the location.\n region: 'Global — Google selects where requests are processed',\n purpose:\n \"AI image generation: creating images for a customer's media library from a description a user writes\",\n publishedOn: '2026-10-08',\n reason:\n \"Reached through the AI plugin's Vertex AI image adapter (`libs/plugins/ai/src/lib/providers/vertex-image.ts`) by the Media library's Create with AI door (`libs/plugins/ai/src/lib/server/ai-media-image.ts`) for every kind that is not drawn as SVG, as the platform's own service account. Off unless `AI_IMAGE_VERTEX_PROJECT` names a Google Cloud project; the console offers those kinds only where `NEXT_PUBLIC_AI_IMAGE_PHOTOS` is `on`. The request carries the description and the kind's fixed style wording, the shape and fixed settings, and nothing else.\",\n dataReceived:\n \"The description the user writes and the shape requested, and the generated image returned. No account identifiers, email addresses, or other content of the customer's site.\",\n },\n },\n]\n\nexport const AI_IMAGE_MODEL_CATALOG: readonly AiImageCatalogEntry[] = [\n {\n // The default: Google's own replacement for Imagen 4, which Vertex AI\n // discontinued in 2026.\n id: 'gemini-3.1-flash-image',\n provider: AI_IMAGE_VERTEX_PROVIDER_ID,\n label: 'Gemini 3.1 Flash Image',\n ...aiImageRatesAtMarkup(0.0672, 0.5, 3),\n },\n {\n id: 'gemini-3.1-flash-lite-image',\n provider: AI_IMAGE_VERTEX_PROVIDER_ID,\n label: 'Gemini 3.1 Flash-Lite Image',\n ...aiImageRatesAtMarkup(0.0336, 0.25, 1.5),\n },\n {\n id: 'gemini-3-pro-image',\n provider: AI_IMAGE_VERTEX_PROVIDER_ID,\n label: 'Gemini 3 Pro Image',\n ...aiImageRatesAtMarkup(0.1344, 2, 12),\n },\n]\n\n/**\n * The per-picture rates an unknown image model id is priced at: the dearest\n * row, on both rates, for the reason `AI_FALLBACK_RATES` gives — an estimate\n * that errs low is worse than one that errs high.\n */\nexport const AI_IMAGE_FALLBACK_RATES: Pick<\n AiImageCatalogEntry,\n 'providerUsdPerImage' | 'billedUsdPerImage'\n> = {\n providerUsdPerImage: Math.max(...AI_IMAGE_MODEL_CATALOG.map((row) => row.providerUsdPerImage)),\n billedUsdPerImage: Math.max(...AI_IMAGE_MODEL_CATALOG.map((row) => row.billedUsdPerImage)),\n}\n\n/** The image catalog row for a model id, or `undefined` for an unknown id. */\nexport function aiImageCatalogEntry(modelId: string): AiImageCatalogEntry | undefined {\n return AI_IMAGE_MODEL_CATALOG.find((entry) => entry.id === modelId)\n}\n\n/** What the provider charges us for one picture from `modelId`, at `size` (1K when absent). */\nexport function aiImageProviderUsdPerImage(modelId: string, size?: AiImageSize): number {\n return atImageSize((aiImageCatalogEntry(modelId) ?? AI_IMAGE_FALLBACK_RATES).providerUsdPerImage, size)\n}\n\n/** What one picture from `modelId` at `size` (1K when absent) draws from a customer's credits. */\nexport function aiImageBilledUsdPerImage(modelId: string, size?: AiImageSize): number {\n return atImageSize((aiImageCatalogEntry(modelId) ?? AI_IMAGE_FALLBACK_RATES).billedUsdPerImage, size)\n}\n\n/**\n * Usage as the meter prices it: a text exchange's tokens, and, for a door\n * that makes pictures, how many it delivered and at what size (1K when\n * absent). `images` is absent on every text exchange, which prices exactly\n * as it always did.\n */\nexport type AiMeteredUsage = AiUsage & { images?: number; imageSize?: AiImageSize }\n\n/** Pictures on a usage record: whole, finite, non-negative, else 0. */\nfunction aiImageCount(usage: AiMeteredUsage): number {\n const value = Number(usage.images ?? 0)\n return Number.isFinite(value) && value > 0 ? Math.floor(value) : 0\n}\n\nfunction roundUsd(value: number): number {\n return Math.round(value * 1_000_000) / 1_000_000\n}\n\n/** The dearest known tier, used when a model id is not in the catalog. */\nexport const AI_FALLBACK_RATES: AiTokenRates = aiRatesPerMTok(10, 50)\n\n/**\n * The minimum an unknown model id is assumed to have: the largest one the\n * catalog knows. It errs the way the rate fallback errs — toward the answer\n * that costs more — so an unrecognized id reads as \"this prompt does not\n * cache\" rather than promising a saving nobody measured.\n */\nexport const AI_FALLBACK_CACHE_MIN_TOKENS = 4_096\n\n/** The shortest prefix a model's provider will cache; the dearest assumption for an unknown id. */\nexport function aiModelCacheMinTokens(modelId: string): number {\n return aiCatalogEntry(modelId)?.cacheMinTokens ?? AI_FALLBACK_CACHE_MIN_TOKENS\n}\n\nconst ZERO_RATES = aiRatesPerMTok(0, 0)\n\n/** The catalog row for a model id, or `undefined` for an unknown id. */\nexport function aiCatalogEntry(modelId: string): AiCatalogEntry | undefined {\n return AI_MODEL_CATALOG.find((entry) => entry.id === modelId)\n}\n\nconst isSentinel = (modelId: string): boolean =>\n (Object.values(AI_METER_SENTINELS) as string[]).includes(modelId)\n\n/**\n * What the PROVIDER charges for a model id — our bill. A meter sentinel is\n * free; an image model's prompt and thinking are priced at its image row's\n * token rates (AGL-3602); an unknown id is priced at the dearest tier.\n *\n * The figure every cost and margin surface prices usage at. Answering the\n * customer's question from here would report a margin the platform does not\n * earn, and answering ours from `aiBilledRatesForModel` reports one it does\n * not pay; the two are separate functions so neither is reachable by\n * forgetting which one was meant.\n */\nexport function aiProviderRatesForModel(modelId: string): AiTokenRates {\n if (isSentinel(modelId)) return ZERO_RATES\n return (\n aiCatalogEntry(modelId)?.providerRates ??\n aiImageCatalogEntry(modelId)?.providerRates ??\n AI_FALLBACK_RATES\n )\n}\n\n/**\n * What a CUSTOMER'S CREDITS are charged at for a model id. A meter sentinel\n * is free; an unknown id is priced at the dearest tier.\n *\n * The figure the credit meter, the band and the model selector price usage\n * at. It is at or above `aiProviderRatesForModel` on every row.\n */\nexport function aiBilledRatesForModel(modelId: string): AiTokenRates {\n if (isSentinel(modelId)) return ZERO_RATES\n return (\n aiCatalogEntry(modelId)?.billedRates ??\n aiImageCatalogEntry(modelId)?.billedRates ??\n AI_FALLBACK_RATES\n )\n}\n\nfunction priceUsage(usage: AiUsage, rate: AiTokenRates): number {\n const raw =\n usage.inputTokens * rate.inputPerToken +\n usage.outputTokens * rate.outputPerToken +\n usage.cacheReadTokens * rate.cacheReadPerToken +\n usage.cacheWriteTokens * rate.cacheWritePerToken\n return Math.round(raw * 1_000_000) / 1_000_000\n}\n\n/**\n * What one exchange COST US, at the serving model's provider rates, rounded\n * to 6dp. Real money, and the only figure a margin may be taken against.\n */\nexport function estimateAiProviderCostUsd(usage: AiMeteredUsage, modelId: string): number {\n return roundUsd(\n priceUsage(usage, aiProviderRatesForModel(modelId)) +\n aiImageCount(usage) * aiImageProviderUsdPerImage(modelId, usage.imageSize),\n )\n}\n\n/**\n * What one exchange DRAWS FROM A CUSTOMER, at the serving model's billed\n * rates, rounded to 6dp — the figure `assistCreditsFromUsd` turns into\n * credits. At or above `estimateAiProviderCostUsd` for the same exchange.\n */\nexport function estimateAiBilledUsd(usage: AiMeteredUsage, modelId: string): number {\n return roundUsd(\n priceUsage(usage, aiBilledRatesForModel(modelId)) +\n aiImageCount(usage) * aiImageBilledUsdPerImage(modelId, usage.imageSize),\n )\n}\n\n/** Every catalog id a provider serves. */\nexport function aiModelIdsForProvider(providerId: string): string[] {\n return AI_MODEL_CATALOG.filter((entry) => entry.provider === providerId).map(\n (entry) => entry.id,\n )\n}\n\n/**\n * What a step asks for, and what the routing table answers with. Every\n * door names its kind here rather than a model, so a model swap — an\n * incident override, an org's own setting, a cheaper model for a cheap\n * step — is one row rather than a search through the doors (AGL-2937).\n */\nexport type AiStepKind =\n | 'assist.chat'\n | 'copy.element'\n | 'copy.section'\n | 'copy.blog'\n | 'generate.section'\n | 'job.component'\n | 'job.crm'\n | 'job.edit'\n | 'job.experiment'\n | 'job.form'\n | 'job.insight'\n | 'job.layout'\n | 'job.logic'\n | 'job.template'\n | 'job.page'\n | 'job.products'\n | 'job.seo'\n | 'job.text'\n | 'job.theme'\n | 'job.plan'\n | 'job.email'\n | 'job.campaign'\n | 'job.workflow'\n\n/** The tier each step kind is served from when no setting overrides it. */\nexport const AI_STEP_TIERS: Record<AiStepKind, AiCatalogEntry['tier']> = {\n 'assist.chat': 'balanced',\n 'copy.element': 'fast',\n 'copy.section': 'balanced',\n 'copy.blog': 'balanced',\n 'generate.section': 'balanced',\n // A reusable component is one structured tree with the typed props it\n // declares, and choosing what becomes a prop is the judgment the step sells.\n 'job.component': 'balanced',\n // CRM by AI (AGL-2917): a record's summary and next step, a deal's stage, a\n // lead's standing, a one-to-one email draft and an import's column matches.\n // Short answers through a strict tool, held to the facts the CRM reports\n // about the record the member opened.\n 'job.crm': 'fast',\n // A change to a page or a layout the site has (AGL-3616): the Assist edit\n // rung's protocol run as a job, held to the closed world of the document's\n // own element ids and to the palette validators. Finding the element a\n // request means, and changing only it, is the judgment; the chat door that\n // proposes the same edits runs on this tier.\n 'job.edit': 'balanced',\n // A/B tests by AI (AGL-2914): variants of one piece of copy, and a\n // result put into words for a verdict code already reached. Short answers\n // through a strict tool, but the judgment a variant sells — which ONE idea\n // to vary so the result says something — is the balanced tier's.\n 'job.experiment': 'balanced',\n // A form is one small tree held to the building rules and to the contract\n // its submissions are read by; a re-ask costs more than the tier saves.\n 'job.form': 'balanced',\n // An insight (AGL-2915) chooses which figures answer a question and says\n // what they show; the trace holds every number, and the judgment of what is\n // worth saying is what the fast tier does worse.\n 'job.insight': 'balanced',\n // A layout or a page template is one structured tree held to every\n // building rule; the fast tier re-asks more than it saves.\n 'job.layout': 'balanced',\n // A site function or variable (AGL-3603): a small structured answer held\n // to the evaluator's grammar, the names it may read and a first run, whose\n // judgment is turning a description into conditions and arithmetic; the\n // fast tier re-asks more than it saves.\n 'job.logic': 'balanced',\n 'job.template': 'balanced',\n // A page section (AGL-2907) is held to the whole page's building rules on\n // every pass, for the same reason.\n 'job.page': 'balanced',\n // A product's copy, a store's first products, or its categories and\n // discounts (AGL-2916): judgment about what a photo shows and what a shopper\n // needs, held to storefront claim rules a re-ask costs more to meet than the\n // tier saves.\n 'job.products': 'balanced',\n // SEO fields, alt text and an audit's fixes (AGL-2910): short answers\n // through a strict tool, held to a length and to the page's own text.\n 'job.seo': 'fast',\n 'job.text': 'balanced',\n // A theme is one structured answer over a small, fixed control set; the\n // judgment is in the color choices, which the fast tier makes worse.\n 'job.theme': 'balanced',\n 'job.plan': 'balanced',\n // An email is one tree held to every building rule, with subject lines\n // whose judgment is the point of asking; the fast tier re-asks more than it\n // saves. A campaign is the same email, drafted into a campaign.\n 'job.email': 'balanced',\n 'job.campaign': 'balanced',\n // An automation is a small structured answer whose judgment is choosing the\n // trigger and steps a description means, and an explanation reads one\n // closely; the fast tier re-asks more than it saves on both (AGL-2919).\n 'job.workflow': 'balanced',\n}\n\n/** The first current catalog model of a tier on a provider, or the provider's first current model. */\nexport function aiDefaultModelFor(providerId: string, tier: AiCatalogEntry['tier']): string | undefined {\n const onProvider = AI_MODEL_CATALOG.filter((entry) => entry.provider === providerId && !entry.successor)\n return (onProvider.find((entry) => entry.tier === tier) ?? onProvider[0])?.id\n}\n"],"names":["aiRatesPerMTok","inputPerMTok","outputPerMTok","inputPerToken","outputPerToken","cacheReadPerToken","cacheWritePerToken","aiRatesAtList","providerRates","billedRates","AI_BILLED_MARKUP","aiRatesMarkedUp","rates","aiRatesAtMarkup","aiRatesAtListWithCacheRead","cacheReadPerMTok","AI_METER_SENTINELS","docsRetrieval","docsLinks","answerCache","ANTHROPIC","OPENAI_COMPATIBLE","ANTHROPIC_DATA_RECEIVED_LEAD","ANTHROPIC_DATA_RECEIVED_CRM_DRAFTS_AND_IMPORTS","ANTHROPIC_CRM_ASSISTANCE_WHOLE_RECORD","record","never","anthropicDataReceived","crm","AI_CATALOG_PROVIDERS","id","label","subprocessor","entity","region","purpose","publishedOn","reason","dataReceived","anthropicCapabilities","streaming","tools","thinking","promptCache","vision","AI_MODEL_CATALOG","provider","capabilities","tier","cacheMinTokens","successor","aiImageRatesAtMarkup","providerUsdPerImage","billedUsdPerImage","roundUsd","AI_IMAGE_SIZE_OUTPUT_TOKENS","atImageSize","usdAt1K","size","tokens","AI_IMAGE_DEFAULT_MODEL","AI_IMAGE_VERTEX_PROVIDER_ID","AI_IMAGE_CATALOG_PROVIDERS","AI_IMAGE_MODEL_CATALOG","AI_IMAGE_FALLBACK_RATES","Math","max","map","row","aiImageCatalogEntry","modelId","find","entry","aiImageProviderUsdPerImage","aiImageBilledUsdPerImage","aiImageCount","usage","value","Number","images","isFinite","floor","round","AI_FALLBACK_RATES","AI_FALLBACK_CACHE_MIN_TOKENS","aiModelCacheMinTokens","aiCatalogEntry","ZERO_RATES","isSentinel","Object","values","includes","aiProviderRatesForModel","aiBilledRatesForModel","priceUsage","rate","raw","inputTokens","outputTokens","cacheReadTokens","cacheWriteTokens","estimateAiProviderCostUsd","imageSize","estimateAiBilledUsd","aiModelIdsForProvider","providerId","filter","AI_STEP_TIERS","aiDefaultModelFor","onProvider"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAiDD,4EAA4E,GAC5E,OAAO,SAASA,eAAeC,YAAoB,EAAEC,aAAqB;IACxE,OAAO;QACLC,eAAeF,eAAe;QAC9BG,gBAAgBF,gBAAgB;QAChCG,mBAAmB,AAACJ,eAAe,MAAO;QAC1CK,oBAAoB,AAACL,eAAe,OAAQ;IAC9C;AACF;AAeA;;;CAGC,GACD,OAAO,SAASM,cACdN,YAAoB,EACpBC,aAAqB;IAErB,OAAO;QACLM,eAAeR,eAAeC,cAAcC;QAC5CO,aAAaT,eAAeC,cAAcC;IAC5C;AACF;AAEA;;;;;;CAMC,GACD,OAAO,MAAMQ,mBAAmB,IAAG;AAEnC,mFAAmF,GACnF,OAAO,SAASC,gBAAgBC,KAAmB;IACjD,OAAO;QACLT,eAAeS,MAAMT,aAAa,GAAGO;QACrCN,gBAAgBQ,MAAMR,cAAc,GAAGM;QACvCL,mBAAmBO,MAAMP,iBAAiB,GAAGK;QAC7CJ,oBAAoBM,MAAMN,kBAAkB,GAAGI;IACjD;AACF;AAEA,mFAAmF,GACnF,OAAO,SAASG,gBAAgBZ,YAAoB,EAAEC,aAAqB;IACzE,MAAMM,gBAAgBR,eAAeC,cAAcC;IACnD,OAAO;QAAEM;QAAeC,aAAaE,gBAAgBH;IAAe;AACtE;AAEA,0FAA0F,GAC1F,OAAO,SAASM,2BACdb,YAAoB,EACpBC,aAAqB,EACrBa,gBAAwB;IAExB,MAAMH,QAAQ,aAAKZ,eAAeC,cAAcC;QAAgBG,mBAAmBU,mBAAmB;;IACtG,OAAO;QAAEP,eAAeI;QAAOH,aAAa,aAAKG;IAAQ;AAC3D;AAkCA;;;;;CAKC,GACD,OA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