@aglyn/plugins-ai 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -17
- package/src/lib/activity/ai-activity.js +4 -2
- package/src/lib/activity/ai-activity.js.map +1 -1
- package/src/lib/components/ai-credits-card.component.d.ts +4 -3
- package/src/lib/components/ai-credits-card.component.js +13 -12
- package/src/lib/components/ai-credits-card.component.js.map +1 -1
- package/src/lib/components/ai-site-import-job.component.js +14 -5
- package/src/lib/components/ai-site-import-job.component.js.map +1 -1
- package/src/lib/components/ai-upsell-dialog.component.d.ts +2 -2
- package/src/lib/components/ai-upsell-dialog.component.js +3 -3
- package/src/lib/components/ai-upsell-dialog.component.js.map +1 -1
- package/src/lib/components/staff-org-ai-card.component.js +2 -2
- package/src/lib/components/staff-org-ai-card.component.js.map +1 -1
- package/src/lib/declarations.d.ts +2 -2
- package/src/lib/declarations.js +10 -9
- package/src/lib/declarations.js.map +1 -1
- package/src/lib/jobs/ai-site-import-compile.js +3 -0
- package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
- package/src/lib/jobs/ai-site-import-document.js +6 -1
- package/src/lib/jobs/ai-site-import-document.js.map +1 -1
- package/src/lib/layout-language/ai-layout-compiler.js +38 -13
- package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
- package/src/lib/layout-language/ai-layout-language.d.ts +2 -0
- package/src/lib/layout-language/ai-layout-language.js.map +1 -1
- package/src/lib/model/ai-site-import-view.js +4 -3
- package/src/lib/model/ai-site-import-view.js.map +1 -1
- package/src/lib/model/ai-site-import.d.ts +2 -0
- package/src/lib/model/ai-site-import.js.map +1 -1
- package/src/lib/model/ai-upsell-copy.js +4 -3
- package/src/lib/model/ai-upsell-copy.js.map +1 -1
- package/src/lib/plan-entitlements.d.ts +3 -3
- package/src/lib/plan-entitlements.js +1 -1
- package/src/lib/plan-entitlements.js.map +1 -1
- package/src/lib/providers/model-choice.d.ts +6 -3
- package/src/lib/providers/model-choice.js +8 -4
- package/src/lib/providers/model-choice.js.map +1 -1
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.d.ts +1 -1
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +5 -1
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
- package/src/lib/site-import/site-import-layout.js +5 -1
- package/src/lib/site-import/site-import-layout.js.map +1 -1
- package/src/lib/usage/assist-credits.d.ts +5 -4
- package/src/lib/usage/assist-credits.js +5 -4
- package/src/lib/usage/assist-credits.js.map +1 -1
- package/src/lib/usage/staff-org-ai-view.js +6 -6
- package/src/lib/usage/staff-org-ai-view.js.map +1 -1
- package/src/lib/usage/staff-org-ai.d.ts +4 -4
- package/src/lib/usage/staff-org-ai.js +8 -7
- package/src/lib/usage/staff-org-ai.js.map +1 -1
- package/src/lib/usage/staff-org-usage-ai.js +2 -2
- package/src/lib/usage/staff-org-usage-ai.js.map +1 -1
|
@@ -79,10 +79,11 @@
|
|
|
79
79
|
* `feature` is what the entry is called: "Create with AI" unless it is an ask.
|
|
80
80
|
*/ export function aiUpsellOffer(canManageBilling, feature = AI_UPSELL_CREATE_LABEL) {
|
|
81
81
|
// Since AGL-3965 every paid plan's own credits pay for generation, so this
|
|
82
|
-
// door is reached only where it is switched off for the workspace and
|
|
83
|
-
// Aglyn AI
|
|
82
|
+
// door is reached only where it is switched off for the workspace and
|
|
83
|
+
// Aglyn AI credit blocks (which switch it on with their credits, AGL-4144)
|
|
84
|
+
// are for sale.
|
|
84
85
|
const addon = aiAddonName();
|
|
85
|
-
return canManageBilling ? `${feature} is switched off for this workspace. It comes with
|
|
86
|
+
return canManageBilling ? `${feature} is switched off for this workspace. It comes with ${addon} ` + 'credits, which you can add in Billing.' : `${feature} is switched off for this workspace. It comes with ${addon} ` + 'credits. Ask a workspace owner or admin to add them in Billing.';
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
//# sourceMappingURL=ai-upsell-copy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-upsell-copy.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 { aiAddonName } from '@aglyn/aglyn/app-utils/plan-entitlements'\nimport type { AiBriefKind } from './ai-brief-copy'\n\n/**\n * What a \"Create with AI\" or \"Ask AI\" entry makes: the brief kinds, an\n * automation, products, a function or variable, an overlay, and an answer\n * about the figures on a page.\n */\nexport type AiUpsellKind =\n | AiBriefKind\n | 'workflow'\n | 'product'\n | 'logic'\n | 'overlay'\n | 'funnel'\n | 'insight'\n\n/** What one entry's dialog says. */\nexport interface AiUpsellCopy {\n title: string\n does: string\n /** The entry's own label, which the button reads and the offer names; \"Create with AI\" when absent. */\n label?: string\n}\n\n/** The label every \"Create with AI\" entry reads. */\nexport const AI_UPSELL_CREATE_LABEL = 'Create with AI'\n\n/** What the dialog says one entry would do here. */\nexport const AI_UPSELL_COPY: Readonly<Record<AiUpsellKind, AiUpsellCopy>> = {\n page: {\n title: 'Create a page with AI',\n does:\n 'Describe the page you need and AI plans it from your brief, using your theme and ' +\n 'what the site already has. You confirm the plan, and the page is built as an ' +\n 'unpublished draft.',\n },\n template: {\n title: 'Create a page template with AI',\n does:\n 'Describe what each page should show and AI plans the template, filling what ' +\n 'changes from page to page from each record. You confirm the plan, and the template ' +\n 'is built as a draft in your library.',\n },\n layout: {\n title: 'Create a layout with AI',\n does:\n 'Describe what the layout should hold and AI plans it, linking your pages and placing ' +\n 'your navigation or menu component when the site has one. You confirm the plan, and ' +\n 'the layout is built as a draft no page uses until you assign it.',\n },\n form: {\n title: 'Create a form with AI',\n does:\n 'Describe what the form is for and AI plans its fields, its marketing consent and ' +\n 'where each submission goes. You confirm the plan, and the form is built as a draft.',\n },\n component: {\n title: 'Create a reusable component with AI',\n does:\n 'Describe what the component should show and AI plans it, making what each page can ' +\n 'change into its properties. You confirm the plan, and the component is built as a ' +\n 'draft.',\n },\n workflow: {\n title: 'Create an automation with AI',\n does:\n 'Describe what should happen, and when, and AI drafts the automation from the ' +\n 'triggers and steps your plan includes. It is saved switched off for you to review.',\n },\n email: {\n title: 'Create an email with AI',\n does:\n 'Describe the email you need and AI plans a design from the email blocks, with three ' +\n 'subject lines and three preheaders to choose between. You confirm the plan, and the ' +\n 'design is built as a draft that is sent to nobody.',\n },\n campaign: {\n title: 'Create a campaign with AI',\n does:\n 'Describe what the campaign is for and AI writes its email design and a draft campaign ' +\n 'that would send it. Nothing is sent or scheduled, and the campaign is aimed at nobody ' +\n 'until you pick its lists.',\n },\n product: {\n title: 'Create products with AI',\n does:\n 'Describe what the store sells and AI proposes up to twelve products. You review them ' +\n 'before any is created, and each is created as a draft at a suggested price that is not on ' +\n 'your storefront until you review it and activate it.',\n },\n logic: {\n title: 'Create a function or variable with AI',\n does:\n 'Describe what it should work out or hold and AI drafts the function or variable. It ' +\n 'opens unsaved in the editor for you to check and save.',\n },\n overlay: {\n title: 'Create an overlay with AI',\n does:\n 'Describe the announcement bar or popup you want and AI writes its copy within the ' +\n 'overlay’s limits. It is saved switched off, for you to check and turn on.',\n },\n funnel: {\n title: 'Create a funnel with AI',\n does:\n 'Describe the journey you want to measure and AI proposes its steps from the site’s ' +\n 'real pages, forms and products. It opens in the funnel editor for you to check and save.',\n },\n insight: {\n title: 'Ask AI about these numbers',\n label: 'Ask a question',\n does:\n 'Ask a question about the figures on this page and AI answers from them, every answer ' +\n 'traced to the figures it is built from. It reads; it changes nothing.',\n },\n}\n\n/** The label an entry's button reads. */\nexport function aiUpsellLabel(kind: AiUpsellKind): string {\n return AI_UPSELL_COPY[kind].label ?? AI_UPSELL_CREATE_LABEL\n}\n\n/**\n * The sentence that says where the feature comes from, and who can add it.\n * `feature` is what the entry is called: \"Create with AI\" unless it is an ask.\n */\nexport function aiUpsellOffer(canManageBilling: boolean, feature = AI_UPSELL_CREATE_LABEL): string {\n // Since AGL-3965 every paid plan's own credits pay for generation, so this\n // door is reached only where it is switched off for the workspace and
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-upsell-copy.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 { aiAddonName } from '@aglyn/aglyn/app-utils/plan-entitlements'\nimport type { AiBriefKind } from './ai-brief-copy'\n\n/**\n * What a \"Create with AI\" or \"Ask AI\" entry makes: the brief kinds, an\n * automation, products, a function or variable, an overlay, and an answer\n * about the figures on a page.\n */\nexport type AiUpsellKind =\n | AiBriefKind\n | 'workflow'\n | 'product'\n | 'logic'\n | 'overlay'\n | 'funnel'\n | 'insight'\n\n/** What one entry's dialog says. */\nexport interface AiUpsellCopy {\n title: string\n does: string\n /** The entry's own label, which the button reads and the offer names; \"Create with AI\" when absent. */\n label?: string\n}\n\n/** The label every \"Create with AI\" entry reads. */\nexport const AI_UPSELL_CREATE_LABEL = 'Create with AI'\n\n/** What the dialog says one entry would do here. */\nexport const AI_UPSELL_COPY: Readonly<Record<AiUpsellKind, AiUpsellCopy>> = {\n page: {\n title: 'Create a page with AI',\n does:\n 'Describe the page you need and AI plans it from your brief, using your theme and ' +\n 'what the site already has. You confirm the plan, and the page is built as an ' +\n 'unpublished draft.',\n },\n template: {\n title: 'Create a page template with AI',\n does:\n 'Describe what each page should show and AI plans the template, filling what ' +\n 'changes from page to page from each record. You confirm the plan, and the template ' +\n 'is built as a draft in your library.',\n },\n layout: {\n title: 'Create a layout with AI',\n does:\n 'Describe what the layout should hold and AI plans it, linking your pages and placing ' +\n 'your navigation or menu component when the site has one. You confirm the plan, and ' +\n 'the layout is built as a draft no page uses until you assign it.',\n },\n form: {\n title: 'Create a form with AI',\n does:\n 'Describe what the form is for and AI plans its fields, its marketing consent and ' +\n 'where each submission goes. You confirm the plan, and the form is built as a draft.',\n },\n component: {\n title: 'Create a reusable component with AI',\n does:\n 'Describe what the component should show and AI plans it, making what each page can ' +\n 'change into its properties. You confirm the plan, and the component is built as a ' +\n 'draft.',\n },\n workflow: {\n title: 'Create an automation with AI',\n does:\n 'Describe what should happen, and when, and AI drafts the automation from the ' +\n 'triggers and steps your plan includes. It is saved switched off for you to review.',\n },\n email: {\n title: 'Create an email with AI',\n does:\n 'Describe the email you need and AI plans a design from the email blocks, with three ' +\n 'subject lines and three preheaders to choose between. You confirm the plan, and the ' +\n 'design is built as a draft that is sent to nobody.',\n },\n campaign: {\n title: 'Create a campaign with AI',\n does:\n 'Describe what the campaign is for and AI writes its email design and a draft campaign ' +\n 'that would send it. Nothing is sent or scheduled, and the campaign is aimed at nobody ' +\n 'until you pick its lists.',\n },\n product: {\n title: 'Create products with AI',\n does:\n 'Describe what the store sells and AI proposes up to twelve products. You review them ' +\n 'before any is created, and each is created as a draft at a suggested price that is not on ' +\n 'your storefront until you review it and activate it.',\n },\n logic: {\n title: 'Create a function or variable with AI',\n does:\n 'Describe what it should work out or hold and AI drafts the function or variable. It ' +\n 'opens unsaved in the editor for you to check and save.',\n },\n overlay: {\n title: 'Create an overlay with AI',\n does:\n 'Describe the announcement bar or popup you want and AI writes its copy within the ' +\n 'overlay’s limits. It is saved switched off, for you to check and turn on.',\n },\n funnel: {\n title: 'Create a funnel with AI',\n does:\n 'Describe the journey you want to measure and AI proposes its steps from the site’s ' +\n 'real pages, forms and products. It opens in the funnel editor for you to check and save.',\n },\n insight: {\n title: 'Ask AI about these numbers',\n label: 'Ask a question',\n does:\n 'Ask a question about the figures on this page and AI answers from them, every answer ' +\n 'traced to the figures it is built from. It reads; it changes nothing.',\n },\n}\n\n/** The label an entry's button reads. */\nexport function aiUpsellLabel(kind: AiUpsellKind): string {\n return AI_UPSELL_COPY[kind].label ?? AI_UPSELL_CREATE_LABEL\n}\n\n/**\n * The sentence that says where the feature comes from, and who can add it.\n * `feature` is what the entry is called: \"Create with AI\" unless it is an ask.\n */\nexport function aiUpsellOffer(canManageBilling: boolean, feature = AI_UPSELL_CREATE_LABEL): string {\n // Since AGL-3965 every paid plan's own credits pay for generation, so this\n // door is reached only where it is switched off for the workspace and\n // Aglyn AI credit blocks (which switch it on with their credits, AGL-4144)\n // are for sale.\n const addon = aiAddonName()\n return canManageBilling\n ? `${feature} is switched off for this workspace. It comes with ${addon} ` +\n 'credits, which you can add in Billing.'\n : `${feature} is switched off for this workspace. It comes with ${addon} ` +\n 'credits. Ask a workspace owner or admin to add them in Billing.'\n}\n"],"names":["aiAddonName","AI_UPSELL_CREATE_LABEL","AI_UPSELL_COPY","page","title","does","template","layout","form","component","workflow","email","campaign","product","logic","overlay","funnel","insight","label","aiUpsellLabel","kind","aiUpsellOffer","canManageBilling","feature","addon"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,WAAW,QAAQ,2CAA0C;AAyBtE,kDAAkD,GAClD,OAAO,MAAMC,yBAAyB,iBAAgB;AAEtD,kDAAkD,GAClD,OAAO,MAAMC,iBAA+D;IAC1EC,MAAM;QACJC,OAAO;QACPC,MACE,sFACA,kFACA;IACJ;IACAC,UAAU;QACRF,OAAO;QACPC,MACE,iFACA,wFACA;IACJ;IACAE,QAAQ;QACNH,OAAO;QACPC,MACE,0FACA,wFACA;IACJ;IACAG,MAAM;QACJJ,OAAO;QACPC,MACE,sFACA;IACJ;IACAI,WAAW;QACTL,OAAO;QACPC,MACE,wFACA,uFACA;IACJ;IACAK,UAAU;QACRN,OAAO;QACPC,MACE,kFACA;IACJ;IACAM,OAAO;QACLP,OAAO;QACPC,MACE,yFACA,yFACA;IACJ;IACAO,UAAU;QACRR,OAAO;QACPC,MACE,2FACA,2FACA;IACJ;IACAQ,SAAS;QACPT,OAAO;QACPC,MACE,0FACA,+FACA;IACJ;IACAS,OAAO;QACLV,OAAO;QACPC,MACE,yFACA;IACJ;IACAU,SAAS;QACPX,OAAO;QACPC,MACE,uFACA;IACJ;IACAW,QAAQ;QACNZ,OAAO;QACPC,MACE,wFACA;IACJ;IACAY,SAAS;QACPb,OAAO;QACPc,OAAO;QACPb,MACE,0FACA;IACJ;AACF,EAAC;AAED,uCAAuC,GACvC,OAAO,SAASc,cAAcC,IAAkB;QACvClB;IAAP,QAAOA,6BAAAA,cAAc,CAACkB,KAAK,CAACF,KAAK,YAA1BhB,6BAA8BD;AACvC;AAEA;;;CAGC,GACD,OAAO,SAASoB,cAAcC,gBAAyB,EAAEC,UAAUtB,sBAAsB;IACvF,2EAA2E;IAC3E,sEAAsE;IACtE,2EAA2E;IAC3E,gBAAgB;IAChB,MAAMuB,QAAQxB;IACd,OAAOsB,mBACH,GAAGC,QAAQ,mDAAmD,EAAEC,MAAM,CAAC,CAAC,GACtE,2CACF,GAAGD,QAAQ,mDAAmD,EAAEC,MAAM,CAAC,CAAC,GACtE;AACR"}
|
|
@@ -62,9 +62,9 @@ declare module '@aglyn/aglyn/plugin-manager/plugin-entitlement-keys' {
|
|
|
62
62
|
* the resulting figures.
|
|
63
63
|
*
|
|
64
64
|
* ONE POOL FOR EVERYTHING (AGL-3965): this band pays for every Aglyn AI
|
|
65
|
-
* action, generation included, on every plan.
|
|
66
|
-
* credits (`
|
|
67
|
-
* — one pool, widened, rather than a second meter.
|
|
65
|
+
* action, generation included, on every plan. Aglyn AI credit blocks add
|
|
66
|
+
* 5,000 credits each (AGL-4144, `ai-credit-blocks.ts`) to it in
|
|
67
|
+
* `resolveOrgEntitlements` — one pool, widened, rather than a second meter.
|
|
68
68
|
*/
|
|
69
69
|
assistCreditsPerMonth?: number;
|
|
70
70
|
}
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
//
|
|
127
127
|
// Since AGL-3965 it opens `aiGenerative` too, as every paid rung does: the
|
|
128
128
|
// included band pays for generation and assist alike (one pool), and an
|
|
129
|
-
// Aglyn AI
|
|
129
|
+
// Aglyn AI credit block adds credits on top rather than opening a door.
|
|
130
130
|
//
|
|
131
131
|
// No cost moves: `tier-margin-floor.spec.ts` already prices this tier's
|
|
132
132
|
// assist term at 100% burn of the 750 credits, 75¢/mo. A door does not
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/plugins/ai/src/lib/plan-entitlements.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\n// Types only: the manifest generator loads this module on its own to compile\n// the plan figures, before the catalog file core reads them from exists in\n// its new shape, so nothing here may reach a core module at runtime.\nimport type { OrgPlan } from '@aglyn/aglyn/foundation/definitions/org-billing.types'\nimport type { PluginPlanEntitlementsDeclaration } from '@aglyn/aglyn/plugin-manager/plugin-plan-entitlements'\n\n/**\n * THE AI PLUGIN'S PLAN BAND (AGL-3080): how many AI credits each plan\n * includes a month. Compiled into core's `PLAN_ENTITLEMENTS` by the manifest\n * generator (`register.planEntitlements`), so `/pricing`, the plan comparison\n * and every gate read the same figure they always have; this is where it is\n * written, beside the reasoning that sized it.\n */\ndeclare module '@aglyn/aglyn/plugin-manager/plugin-entitlement-keys' {\n interface PluginEntitlementQuotas {\n /**\n * AI credits per calendar month — the band assist spends against.\n *\n * A CREDIT IS A UNIT OF MODEL COST, not a message. One assist action can\n * cost two orders of magnitude more than another: a question is a few\n * thousand tokens, while generating a screen carries the node tree, the\n * component catalog and the theme tokens in, structured markup out, and\n * iterates. A message allowance would price those the same, so one\n * workspace's ten screen builds would outspend another's thousand\n * questions and both would read as \"within allowance\".\n *\n * The unit is defined by `ASSIST_CREDIT_COST_USD` and the conversion\n * lives in `assist-credits.ts`. Only that module turns credits into\n * dollars; everything a customer sees counts credits, because the dollar\n * figure behind them is our provider bill and not a price.\n *\n * ## HOW THE BAND IS SIZED, and why it is not a share of the price\n *\n * A credit is a dollar of provider spend at `ASSIST_CREDIT_COST_USD`, so\n * the band IS a liability figure: the plan's whole assist give is\n * `assistCreditsPerMonth / 1000` dollars. Credits past it are not a give\n * — since AGL-2653 they are SOLD at `extraAssistCreditsUsdPer1k`, unless\n * the org's `assistOverage.hardCap` asks `reserveAssistMessage` to refuse\n * at the band instead. Sizing it as a share of the subscription price\n * says nothing about whether the tier can afford it, because the price is\n * also carrying storage, bandwidth, form submissions, dataset storage,\n * API requests, contacts and email.\n *\n * So each band is sized against what those SEVEN other terms leave.\n * Every paid band takes between a quarter and a third of that remainder,\n * which keeps the tier's worst case positive and keeps the ladder's\n * shape: the margin each tier holds at 100% of every band stays in\n * proportion to what it held before assist was sold at all.\n * `tier-margin-floor.spec.ts` is the model, and it pins both the rule and\n * the resulting figures.\n *\n * ONE POOL FOR EVERYTHING (AGL-3965): this band pays for every Aglyn AI\n * action, generation included, on every plan. An Aglyn AI tier adds its\n * credits (`AI_TIERS[tier].credits`) to it in `resolveOrgEntitlements`\n * — one pool, widened, rather than a second meter.\n */\n assistCreditsPerMonth?: number\n }\n}\n\n/**\n * AI credits an Enterprise agreement includes per month, before the contract\n * says otherwise.\n *\n * ## Never `UNLIMITED`, and the reason is not stylistic\n *\n * `UNLIMITED` is `Number.POSITIVE_INFINITY`, `JSON.stringify(Infinity)` is\n * `null`, and `Number(null)` is `0`. An unbounded assist band therefore\n * serialises to a band of ZERO through every route that does not also send\n * the explicit flag `restoreQuotaLimit` rebuilds from — which would hand the\n * only customers with a signed contract the one budget that refuses\n * everything. A finite number crosses the wire as itself.\n *\n * The band is also a real liability rather than a capacity we already own.\n * Storage and page views are infrastructure metered into the deal; assist is\n * a per-token charge from a third party, and generative building spends it in\n * units two orders of magnitude apart.\n *\n * ## Why this number\n *\n * Enterprise carries no list price, so the band cannot be sized the way every\n * self-serve tier's is — against what that tier's other cost terms leave out\n * of a known price. It is anchored to the top of the ladder instead: 116,000\n * credits is twice Agency's band, the rule every Enterprise fallback follows\n * since the 2026-09-07 pricing decision (see the `enterprise` row of\n * `PLAN_ENTITLEMENTS`). In cost that is $116 of provider spend a month, or\n * under 9% of any deal priced at or above the self-serve top. A deal below\n * that is sold as Agency, not written as an Enterprise agreement.\n *\n * ## It is a DEFAULT, and a contract raises it\n *\n * `resolveOrgEntitlements` applies a per-org\n * `entitlements.assistCreditsPerMonth` override ahead of this, so a deal that\n * buys more assist buys it on that org without moving the figure every other\n * agreement is measured against — the same mechanism the other contracted\n * bands use.\n */\nexport const ENTERPRISE_ASSIST_CREDITS_PER_MONTH = 116_000\n\n/**\n * The Free AI taste (AGL-2925): the credits a Free workspace draws on each\n * month, behind a hard wall.\n *\n * ## Why it exists\n *\n * So the AI landing pages can say \"generate your first page free\" and mean\n * it. Three hundred credits is one or two generated sections or a handful of\n * copy rewrites — enough to see what the assistant does, not enough to build\n * a site on. The band is a WALL: `PLAN_PRICING.free\n * .extraAssistCreditsUsdPer1k` stays `null`, so `assistBandRefuses` answers\n * true and the reservation refuses at 100% with no overage, no switch and no\n * invoice. Nothing about a Free workspace can produce a charge.\n *\n * ## What it costs, and why that is the number\n *\n * A credit is `ASSIST_CREDIT_COST_USD` of provider spend, so the band costs\n * at most **$0.30 per Free workspace per month** — asserted by\n * `apps/console/specs/tier-margin-floor.spec.ts`. It is the one AI band with\n * no invoice behind it, which is why the same issue closes every multiplier\n * a script could use before the flag flips:\n *\n * - it is metered per ACCOUNT as well as per workspace, so the three free\n * workspaces an account may hold (AGL-2265) share one 300-credit\n * allowance rather than tripling it (`reserveAssistMessage`);\n * - every free request is bounded per IP, per uid and per account per\n * day (a minimum account age, `AI_FREE_MIN_ACCOUNT_AGE_HOURS`, is\n * available and off by default — AGL-3591);\n * - a platform-wide daily ceiling on free spend pauses the taste for\n * everyone until the UTC day rolls, paid workspaces untouched.\n *\n * The account allowance reads THIS constant rather than the workspace's\n * resolved band, because a staff override that widens one workspace's band\n * is a decision about that workspace, not about how much one person may draw\n * across all of theirs.\n */\nexport const FREE_AI_TASTE_CREDITS_PER_MONTH = 300\n\n/** The AI credits each plan includes a month — see the key's own docblock. */\nexport const AI_CREDITS_BY_PLAN: Readonly<Record<OrgPlan, number>> = {\n // The Free AI taste (AGL-2925): a real band, and a wall. See the constant\n // for what it buys, what it costs and the precautions that keep one person\n // from drawing it three times over.\n free: FREE_AI_TASTE_CREDITS_PER_MONTH,\n // The first paid rung of the assist ladder (AGL-3203). Starter banded at 0\n // until 2026-09-20, which put a PAYING workspace below the Free taste's 300\n // on the one axis a visitor compares straight down the column — the\n // `/pricing` row read `300 / mo` for Free and `—` for Starter. A paid plan\n // that includes less of something than the free plan is not a packaging\n // subtlety; it is the comparison table arguing against the upgrade.\n //\n // 750 is deliberately small: 2.5x the taste, enough that the assistant is a\n // thing the tier HAS rather than a thing it is shown, and $0.75 of provider\n // spend a month at `ASSIST_CREDIT_COST_USD` against a $16 annual price — a\n // twentieth of the $8.81 the tier's other metered bands already cost, and\n // the widest margin on the ladder absorbs it with room left\n // (`tier-margin-floor.spec.ts` carries the arithmetic).\n //\n // It is NOT a wall, unlike Free's: `PLAN_PRICING.starter\n // .extraAssistCreditsUsdPer1k` is $3.00, so past 750 the tier meters and\n // bills like every paid plan above it. The two fields move together by rule\n // — a positive band with no rate beside it is usage past a bound that is\n // silently free, which `plan-entitlements.spec.ts` forbids.\n //\n // `features.aiAssist` is TRUE, and AGL-3203 shipping it false was the\n // defect AGL-3207 closes. The reasoning then was \"the band is credits, not\n // the guided rung, exactly as on Free\" — but on Free the band IS spendable,\n // through `aiGenerative`, which is the door the taste exists for. Starter\n // carried neither flag, so it was the only row on the ladder sold a band\n // with nothing to spend it through: 750 credits reachable only by buying\n // the $9 add-on that was also the only thing that made them usable. \"No\n // plan bands at zero any more\" was true of the number and false of the\n // capability.\n //\n // Since AGL-3965 it opens `aiGenerative` too, as every paid rung does: the\n // included band pays for generation and assist alike (one pool), and an\n // Aglyn AI tier adds credits on top rather than opening a door.\n //\n // No cost moves: `tier-margin-floor.spec.ts` already prices this tier's\n // assist term at 100% burn of the 750 credits, 75¢/mo. A door does not\n // widen a band; it only makes spend that was already modeled reachable.\n starter: 750,\n // $2.75 of provider spend, against the $8.35 the tier's other seven cost\n // terms leave out of $56. See the key's docblock for why the remainder and\n // not the price is what sizes this.\n pro: 2_750,\n // $7.50, against the $22.69 the other seven terms leave out of $139.\n business: 7_500,\n // $10.00, against the $30.62 the other seven terms leave out of $249.\n scale: 10_000,\n // $13.00, against the $39.74 the other seven terms leave out of $399 — the\n // thinnest remainder on the ladder, and the tier that binds the whole\n // assist ladder's share of it.\n advanced: 13_000,\n // $58.00, against the $176.71 the other seven terms leave out of $1,299.\n agency: 58_000,\n enterprise: ENTERPRISE_ASSIST_CREDITS_PER_MONTH,\n}\n\n/** The AI plugin's plan figures, for the manifest generator. */\nexport function aiPlanEntitlements(): PluginPlanEntitlementsDeclaration {\n return {\n quotas: [\n {\n key: 'assistCreditsPerMonth',\n label: 'AI credits / mo',\n byPlan: AI_CREDITS_BY_PLAN,\n },\n ],\n }\n}\n"],"names":["ENTERPRISE_ASSIST_CREDITS_PER_MONTH","FREE_AI_TASTE_CREDITS_PER_MONTH","AI_CREDITS_BY_PLAN","free","starter","pro","business","scale","advanced","agency","enterprise","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C,OAAO;gBACPC,QAAQb;YACV;SACD;IACH;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/plugins/ai/src/lib/plan-entitlements.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\n// Types only: the manifest generator loads this module on its own to compile\n// the plan figures, before the catalog file core reads them from exists in\n// its new shape, so nothing here may reach a core module at runtime.\nimport type { OrgPlan } from '@aglyn/aglyn/foundation/definitions/org-billing.types'\nimport type { PluginPlanEntitlementsDeclaration } from '@aglyn/aglyn/plugin-manager/plugin-plan-entitlements'\n\n/**\n * THE AI PLUGIN'S PLAN BAND (AGL-3080): how many AI credits each plan\n * includes a month. Compiled into core's `PLAN_ENTITLEMENTS` by the manifest\n * generator (`register.planEntitlements`), so `/pricing`, the plan comparison\n * and every gate read the same figure they always have; this is where it is\n * written, beside the reasoning that sized it.\n */\ndeclare module '@aglyn/aglyn/plugin-manager/plugin-entitlement-keys' {\n interface PluginEntitlementQuotas {\n /**\n * AI credits per calendar month — the band assist spends against.\n *\n * A CREDIT IS A UNIT OF MODEL COST, not a message. One assist action can\n * cost two orders of magnitude more than another: a question is a few\n * thousand tokens, while generating a screen carries the node tree, the\n * component catalog and the theme tokens in, structured markup out, and\n * iterates. A message allowance would price those the same, so one\n * workspace's ten screen builds would outspend another's thousand\n * questions and both would read as \"within allowance\".\n *\n * The unit is defined by `ASSIST_CREDIT_COST_USD` and the conversion\n * lives in `assist-credits.ts`. Only that module turns credits into\n * dollars; everything a customer sees counts credits, because the dollar\n * figure behind them is our provider bill and not a price.\n *\n * ## HOW THE BAND IS SIZED, and why it is not a share of the price\n *\n * A credit is a dollar of provider spend at `ASSIST_CREDIT_COST_USD`, so\n * the band IS a liability figure: the plan's whole assist give is\n * `assistCreditsPerMonth / 1000` dollars. Credits past it are not a give\n * — since AGL-2653 they are SOLD at `extraAssistCreditsUsdPer1k`, unless\n * the org's `assistOverage.hardCap` asks `reserveAssistMessage` to refuse\n * at the band instead. Sizing it as a share of the subscription price\n * says nothing about whether the tier can afford it, because the price is\n * also carrying storage, bandwidth, form submissions, dataset storage,\n * API requests, contacts and email.\n *\n * So each band is sized against what those SEVEN other terms leave.\n * Every paid band takes between a quarter and a third of that remainder,\n * which keeps the tier's worst case positive and keeps the ladder's\n * shape: the margin each tier holds at 100% of every band stays in\n * proportion to what it held before assist was sold at all.\n * `tier-margin-floor.spec.ts` is the model, and it pins both the rule and\n * the resulting figures.\n *\n * ONE POOL FOR EVERYTHING (AGL-3965): this band pays for every Aglyn AI\n * action, generation included, on every plan. Aglyn AI credit blocks add\n * 5,000 credits each (AGL-4144, `ai-credit-blocks.ts`) to it in\n * `resolveOrgEntitlements` — one pool, widened, rather than a second meter.\n */\n assistCreditsPerMonth?: number\n }\n}\n\n/**\n * AI credits an Enterprise agreement includes per month, before the contract\n * says otherwise.\n *\n * ## Never `UNLIMITED`, and the reason is not stylistic\n *\n * `UNLIMITED` is `Number.POSITIVE_INFINITY`, `JSON.stringify(Infinity)` is\n * `null`, and `Number(null)` is `0`. An unbounded assist band therefore\n * serialises to a band of ZERO through every route that does not also send\n * the explicit flag `restoreQuotaLimit` rebuilds from — which would hand the\n * only customers with a signed contract the one budget that refuses\n * everything. A finite number crosses the wire as itself.\n *\n * The band is also a real liability rather than a capacity we already own.\n * Storage and page views are infrastructure metered into the deal; assist is\n * a per-token charge from a third party, and generative building spends it in\n * units two orders of magnitude apart.\n *\n * ## Why this number\n *\n * Enterprise carries no list price, so the band cannot be sized the way every\n * self-serve tier's is — against what that tier's other cost terms leave out\n * of a known price. It is anchored to the top of the ladder instead: 116,000\n * credits is twice Agency's band, the rule every Enterprise fallback follows\n * since the 2026-09-07 pricing decision (see the `enterprise` row of\n * `PLAN_ENTITLEMENTS`). In cost that is $116 of provider spend a month, or\n * under 9% of any deal priced at or above the self-serve top. A deal below\n * that is sold as Agency, not written as an Enterprise agreement.\n *\n * ## It is a DEFAULT, and a contract raises it\n *\n * `resolveOrgEntitlements` applies a per-org\n * `entitlements.assistCreditsPerMonth` override ahead of this, so a deal that\n * buys more assist buys it on that org without moving the figure every other\n * agreement is measured against — the same mechanism the other contracted\n * bands use.\n */\nexport const ENTERPRISE_ASSIST_CREDITS_PER_MONTH = 116_000\n\n/**\n * The Free AI taste (AGL-2925): the credits a Free workspace draws on each\n * month, behind a hard wall.\n *\n * ## Why it exists\n *\n * So the AI landing pages can say \"generate your first page free\" and mean\n * it. Three hundred credits is one or two generated sections or a handful of\n * copy rewrites — enough to see what the assistant does, not enough to build\n * a site on. The band is a WALL: `PLAN_PRICING.free\n * .extraAssistCreditsUsdPer1k` stays `null`, so `assistBandRefuses` answers\n * true and the reservation refuses at 100% with no overage, no switch and no\n * invoice. Nothing about a Free workspace can produce a charge.\n *\n * ## What it costs, and why that is the number\n *\n * A credit is `ASSIST_CREDIT_COST_USD` of provider spend, so the band costs\n * at most **$0.30 per Free workspace per month** — asserted by\n * `apps/console/specs/tier-margin-floor.spec.ts`. It is the one AI band with\n * no invoice behind it, which is why the same issue closes every multiplier\n * a script could use before the flag flips:\n *\n * - it is metered per ACCOUNT as well as per workspace, so the three free\n * workspaces an account may hold (AGL-2265) share one 300-credit\n * allowance rather than tripling it (`reserveAssistMessage`);\n * - every free request is bounded per IP, per uid and per account per\n * day (a minimum account age, `AI_FREE_MIN_ACCOUNT_AGE_HOURS`, is\n * available and off by default — AGL-3591);\n * - a platform-wide daily ceiling on free spend pauses the taste for\n * everyone until the UTC day rolls, paid workspaces untouched.\n *\n * The account allowance reads THIS constant rather than the workspace's\n * resolved band, because a staff override that widens one workspace's band\n * is a decision about that workspace, not about how much one person may draw\n * across all of theirs.\n */\nexport const FREE_AI_TASTE_CREDITS_PER_MONTH = 300\n\n/** The AI credits each plan includes a month — see the key's own docblock. */\nexport const AI_CREDITS_BY_PLAN: Readonly<Record<OrgPlan, number>> = {\n // The Free AI taste (AGL-2925): a real band, and a wall. See the constant\n // for what it buys, what it costs and the precautions that keep one person\n // from drawing it three times over.\n free: FREE_AI_TASTE_CREDITS_PER_MONTH,\n // The first paid rung of the assist ladder (AGL-3203). Starter banded at 0\n // until 2026-09-20, which put a PAYING workspace below the Free taste's 300\n // on the one axis a visitor compares straight down the column — the\n // `/pricing` row read `300 / mo` for Free and `—` for Starter. A paid plan\n // that includes less of something than the free plan is not a packaging\n // subtlety; it is the comparison table arguing against the upgrade.\n //\n // 750 is deliberately small: 2.5x the taste, enough that the assistant is a\n // thing the tier HAS rather than a thing it is shown, and $0.75 of provider\n // spend a month at `ASSIST_CREDIT_COST_USD` against a $16 annual price — a\n // twentieth of the $8.81 the tier's other metered bands already cost, and\n // the widest margin on the ladder absorbs it with room left\n // (`tier-margin-floor.spec.ts` carries the arithmetic).\n //\n // It is NOT a wall, unlike Free's: `PLAN_PRICING.starter\n // .extraAssistCreditsUsdPer1k` is $3.00, so past 750 the tier meters and\n // bills like every paid plan above it. The two fields move together by rule\n // — a positive band with no rate beside it is usage past a bound that is\n // silently free, which `plan-entitlements.spec.ts` forbids.\n //\n // `features.aiAssist` is TRUE, and AGL-3203 shipping it false was the\n // defect AGL-3207 closes. The reasoning then was \"the band is credits, not\n // the guided rung, exactly as on Free\" — but on Free the band IS spendable,\n // through `aiGenerative`, which is the door the taste exists for. Starter\n // carried neither flag, so it was the only row on the ladder sold a band\n // with nothing to spend it through: 750 credits reachable only by buying\n // the $9 add-on that was also the only thing that made them usable. \"No\n // plan bands at zero any more\" was true of the number and false of the\n // capability.\n //\n // Since AGL-3965 it opens `aiGenerative` too, as every paid rung does: the\n // included band pays for generation and assist alike (one pool), and an\n // Aglyn AI credit block adds credits on top rather than opening a door.\n //\n // No cost moves: `tier-margin-floor.spec.ts` already prices this tier's\n // assist term at 100% burn of the 750 credits, 75¢/mo. A door does not\n // widen a band; it only makes spend that was already modeled reachable.\n starter: 750,\n // $2.75 of provider spend, against the $8.35 the tier's other seven cost\n // terms leave out of $56. See the key's docblock for why the remainder and\n // not the price is what sizes this.\n pro: 2_750,\n // $7.50, against the $22.69 the other seven terms leave out of $139.\n business: 7_500,\n // $10.00, against the $30.62 the other seven terms leave out of $249.\n scale: 10_000,\n // $13.00, against the $39.74 the other seven terms leave out of $399 — the\n // thinnest remainder on the ladder, and the tier that binds the whole\n // assist ladder's share of it.\n advanced: 13_000,\n // $58.00, against the $176.71 the other seven terms leave out of $1,299.\n agency: 58_000,\n enterprise: ENTERPRISE_ASSIST_CREDITS_PER_MONTH,\n}\n\n/** The AI plugin's plan figures, for the manifest generator. */\nexport function aiPlanEntitlements(): PluginPlanEntitlementsDeclaration {\n return {\n quotas: [\n {\n key: 'assistCreditsPerMonth',\n label: 'AI credits / mo',\n byPlan: AI_CREDITS_BY_PLAN,\n },\n ],\n }\n}\n"],"names":["ENTERPRISE_ASSIST_CREDITS_PER_MONTH","FREE_AI_TASTE_CREDITS_PER_MONTH","AI_CREDITS_BY_PLAN","free","starter","pro","business","scale","advanced","agency","enterprise","aiPlanEntitlements","quotas","key","label","byPlan"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,6EAA6E;AAC7E,2EAA2E;AAC3E,qEAAqE;AA0DrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCC,GACD,OAAO,MAAMA,sCAAsC,OAAO;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCC,GACD,OAAO,MAAMC,kCAAkC,IAAG;AAElD,4EAA4E,GAC5E,OAAO,MAAMC,qBAAwD;IACnE,0EAA0E;IAC1E,2EAA2E;IAC3E,oCAAoC;IACpCC,MAAMF;IACN,2EAA2E;IAC3E,4EAA4E;IAC5E,oEAAoE;IACpE,2EAA2E;IAC3E,wEAAwE;IACxE,oEAAoE;IACpE,EAAE;IACF,4EAA4E;IAC5E,4EAA4E;IAC5E,2EAA2E;IAC3E,0EAA0E;IAC1E,4DAA4D;IAC5D,wDAAwD;IACxD,EAAE;IACF,yDAAyD;IACzD,yEAAyE;IACzE,4EAA4E;IAC5E,yEAAyE;IACzE,4DAA4D;IAC5D,EAAE;IACF,sEAAsE;IACtE,2EAA2E;IAC3E,4EAA4E;IAC5E,0EAA0E;IAC1E,yEAAyE;IACzE,yEAAyE;IACzE,wEAAwE;IACxE,uEAAuE;IACvE,cAAc;IACd,EAAE;IACF,2EAA2E;IAC3E,wEAAwE;IACxE,wEAAwE;IACxE,EAAE;IACF,wEAAwE;IACxE,uEAAuE;IACvE,wEAAwE;IACxEG,SAAS;IACT,yEAAyE;IACzE,2EAA2E;IAC3E,oCAAoC;IACpCC,KAAK;IACL,qEAAqE;IACrEC,UAAU;IACV,sEAAsE;IACtEC,OAAO;IACP,2EAA2E;IAC3E,sEAAsE;IACtE,+BAA+B;IAC/BC,UAAU;IACV,yEAAyE;IACzEC,QAAQ;IACRC,YAAYV;AACd,EAAC;AAED,8DAA8D,GAC9D,OAAO,SAASW;IACd,OAAO;QACLC,QAAQ;YACN;gBACEC,KAAK;gBACLC,OAAO;gBACPC,QAAQb;YACV;SACD;IACH;AACF"}
|
|
@@ -55,9 +55,12 @@ export declare const AI_MODEL_AUTO = "auto";
|
|
|
55
55
|
/**
|
|
56
56
|
* The catalog tiers a MANUAL pick may name, per plan. Free runs on Auto only:
|
|
57
57
|
* its taste is a wall, and a pick there would spend the account's credits at
|
|
58
|
-
* a rate nobody chose on purpose. The dearest tier
|
|
59
|
-
* the band is large enough that a slower, deeper model is a real choice
|
|
60
|
-
* rather than a fast way to end the month
|
|
58
|
+
* a rate nobody chose on purpose. The dearest tier opened from Scale up,
|
|
59
|
+
* where the band is large enough that a slower, deeper model is a real choice
|
|
60
|
+
* rather than a fast way to end the month — and from Pro since pricing v4
|
|
61
|
+
* (2026-11-03, AGL-4126), which moved the deep model picks into the plan that
|
|
62
|
+
* became the full platform. A credit is a fixed quantity of provider spend,
|
|
63
|
+
* so a deeper pick spends the band faster and never past what it covers.
|
|
61
64
|
*/
|
|
62
65
|
export declare const AI_PLAN_MODEL_TIERS: Record<OrgPlan, readonly AiCatalogEntry['tier'][]>;
|
|
63
66
|
/** The plans whose admins may restrict the model set org-wide. */
|
|
@@ -51,9 +51,12 @@ import { aiServingModelId, resolveAiRoute } from "./routing.js";
|
|
|
51
51
|
/**
|
|
52
52
|
* The catalog tiers a MANUAL pick may name, per plan. Free runs on Auto only:
|
|
53
53
|
* its taste is a wall, and a pick there would spend the account's credits at
|
|
54
|
-
* a rate nobody chose on purpose. The dearest tier
|
|
55
|
-
* the band is large enough that a slower, deeper model is a real choice
|
|
56
|
-
* rather than a fast way to end the month
|
|
54
|
+
* a rate nobody chose on purpose. The dearest tier opened from Scale up,
|
|
55
|
+
* where the band is large enough that a slower, deeper model is a real choice
|
|
56
|
+
* rather than a fast way to end the month — and from Pro since pricing v4
|
|
57
|
+
* (2026-11-03, AGL-4126), which moved the deep model picks into the plan that
|
|
58
|
+
* became the full platform. A credit is a fixed quantity of provider spend,
|
|
59
|
+
* so a deeper pick spends the band faster and never past what it covers.
|
|
57
60
|
*/ export const AI_PLAN_MODEL_TIERS = {
|
|
58
61
|
free: [],
|
|
59
62
|
starter: [
|
|
@@ -62,7 +65,8 @@ import { aiServingModelId, resolveAiRoute } from "./routing.js";
|
|
|
62
65
|
],
|
|
63
66
|
pro: [
|
|
64
67
|
'fast',
|
|
65
|
-
'balanced'
|
|
68
|
+
'balanced',
|
|
69
|
+
'deep'
|
|
66
70
|
],
|
|
67
71
|
business: [
|
|
68
72
|
'fast',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/providers/model-choice.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { assistCreditsFromUsd } from '../usage/assist-credits'\nimport type { OrgPlan } from '@aglyn/aglyn/foundation/definitions/org-billing.types'\nimport {\n AI_MODEL_CATALOG,\n AI_STEP_TIERS,\n aiCatalogEntry,\n aiBilledRatesForModel,\n estimateAiBilledUsd,\n type AiCatalogEntry,\n type AiStepKind,\n} from './catalog'\nimport type { AiUsage } from './contract'\nimport { aiServingModelId, resolveAiRoute, type AiPluginSettings } from './routing'\n\n/**\n * THE MODEL SWITCH (AGL-2942): what a person may pick, what \"Auto\" means,\n * and what a pick costs.\n *\n * ## Auto is the routing table\n *\n * A request that names no model — or names one it may not have — runs on\n * `resolveAiRoute(kind)`, the table that maps a step kind to a catalog model\n * (AGL-2937). Picking a model is an override of that one row for one request,\n * never a second table.\n *\n * ## Three bounds, one intersection\n *\n * A manual pick must be served by the active provider, in a tier the org's\n * plan offers (`AI_PLAN_MODEL_TIERS`), on the org's own restriction when it\n * set one, and on the allotment allowlists that apply to the request. The\n * two allowlists bound Auto too: when the routing table's answer is not on\n * them, Auto runs on the allowed model of the same tier, else the cheapest\n * allowed one. The plan bounds only a pick — Auto is the platform's choice,\n * made for the step, and a plan never makes it worse.\n *\n * An allowlist that leaves nothing this deployment serves is not a way to\n * switch AI off by mistake: the choice falls back to the routing table, and\n * the permission keys are how AI is switched off on purpose.\n *\n * ## The price beside each option\n *\n * Credits per typical request at each model's list rates, over the step's\n * measured median exchange when the workspace has enough of them, and over\n * `AI_STEP_NOMINAL_USAGE` until it does — with the multiple of what Auto\n * would cost for the same request. Every figure is credits, never dollars.\n */\n\n/** The value a request sends for \"let the platform route it\". */\nexport const AI_MODEL_AUTO = 'auto'\n\n/**\n * The catalog tiers a MANUAL pick may name, per plan. Free runs on Auto only:\n * its taste is a wall, and a pick there would spend the account's credits at\n * a rate nobody chose on purpose. The dearest tier opens from Scale up, where\n * the band is large enough that a slower, deeper model is a real choice\n * rather than a fast way to end the month.\n */\nexport const AI_PLAN_MODEL_TIERS: Record<OrgPlan, readonly AiCatalogEntry['tier'][]> = {\n free: [],\n starter: ['fast', 'balanced'],\n pro: ['fast', 'balanced'],\n business: ['fast', 'balanced'],\n scale: ['fast', 'balanced', 'deep'],\n advanced: ['fast', 'balanced', 'deep'],\n agency: ['fast', 'balanced', 'deep'],\n enterprise: ['fast', 'balanced', 'deep'],\n}\n\n/** The plans whose admins may restrict the model set org-wide. */\nexport const AI_MODEL_RESTRICTION_PLANS: readonly OrgPlan[] = ['agency', 'enterprise']\n\n/**\n * A typical exchange per step kind, before a workspace has measured one: the\n * doors' own prompt sizes and output ceilings, read conservatively. Replaced\n * by the workspace's measured median as soon as `aiMedianUsage` has enough\n * samples, and only ever used for the price beside an option.\n */\nexport const AI_STEP_NOMINAL_USAGE: Record<AiStepKind, AiUsage> = {\n 'assist.chat': { inputTokens: 900, outputTokens: 450, cacheReadTokens: 1_050, cacheWriteTokens: 0 },\n // One element's rewrite on the fast tier, counted as Claude Haiku 5.5 counts\n // it: about 30% more tokens than Haiku 4.5 for the same text (AGL-3781).\n 'copy.element': { inputTokens: 455, outputTokens: 156, cacheReadTokens: 0, cacheWriteTokens: 0 },\n 'copy.section': { inputTokens: 700, outputTokens: 1_400, cacheReadTokens: 0, cacheWriteTokens: 0 },\n 'copy.blog': { inputTokens: 600, outputTokens: 1_100, cacheReadTokens: 0, cacheWriteTokens: 0 },\n 'generate.section': { inputTokens: 700, outputTokens: 1_400, cacheReadTokens: 0, cacheWriteTokens: 0 },\n // The text step's rules are about 500 characters — far under the balanced\n // tier's cacheable minimum, so they are billed as input every time rather\n // than read from a cache (`runtime/ai-prompt-cache.spec.ts` measures it).\n 'job.text': { inputTokens: 450, outputTokens: 500, cacheReadTokens: 0, cacheWriteTokens: 0 },\n // The theme step: the tool's schema and both system blocks (about 7,500\n // characters) are the cached prefix, the site's inventory and the brief ride\n // uncached, and a full-palette answer is about 1,300 characters of JSON with\n // as much again to think in.\n 'job.theme': { inputTokens: 500, outputTokens: 850, cacheReadTokens: 2_500, cacheWriteTokens: 0 },\n // The plan step: the tool's schema, the doctrine and the plan instructions\n // (about 10,000 characters) are the cached prefix, the site inventory and the\n // brief ride uncached, and a plan answer is about 600 characters of JSON with\n // as much again to think in.\n 'job.plan': { inputTokens: 500, outputTokens: 400, cacheReadTokens: 3_600, cacheWriteTokens: 0 },\n // The component step: the doctrine, the component instructions, the\n // component surface's catalog and the tool are the cached prefix, the site\n // inventory, the brief and the confirmed plan ride uncached, and a card-sized\n // answer — its tree and declared props as JSON — is about 1,700 characters.\n // The component step's spec measures the prefix and the answer against this.\n 'job.component': { inputTokens: 700, outputTokens: 600, cacheReadTokens: 5_800, cacheWriteTokens: 0 },\n // The CRM step's exchange (AGL-2917), counted as the fast tier's Claude\n // Haiku 5.5 counts it, about 30% more tokens than Haiku 4.5 (AGL-3781). The\n // doctrine's field rules, the CRM rules and the tool come to 650 to 913\n // tokens, as `runtime/ai-prompt-cache.spec.ts` measures them, which caches on\n // that model; one question about a record writes it, so it is counted as\n // input. A record's facts ride with them, a timeline cut to its newest twelve\n // entries, and the typical answer is a summary and a next step of a few\n // sentences, with no thinking.\n 'job.crm': { inputTokens: 2_340, outputTokens: 325, cacheReadTokens: 0, cacheWriteTokens: 0 },\n // A layout: a tree layout's 1,000 output tokens until AGL-3660, now a\n // site's header and footer in the layout language — 442 to 583 output\n // tokens live on 2026-10-07 — with up to 1,500 more for the adaptive\n // thinking it is asked with, an estimate until a workspace measures it.\n 'job.layout': { inputTokens: 700, outputTokens: 2_000, cacheReadTokens: 5_600, cacheWriteTokens: 0 },\n 'job.template': { inputTokens: 1_200, outputTokens: 700, cacheReadTokens: 6_400, cacheWriteTokens: 0 },\n // One page section's exchange (AGL-2907), from the modules' own text: the\n // doctrine (6,281 characters), the page instructions (1,524), the screen\n // palette catalog (8,353) and the section tool (484) are the cached prefix;\n // the site inventory (711 on the median golden site), the brief, the plan\n // and the section line ride uncached; and a golden section answer is 901\n // characters at the median, asked for with no thinking.\n // Since AGL-3660 a site's and a build's pages are one answer a page in\n // the layout language: 683 to 1,745 output tokens live on 2026-10-07, about\n // 1,150 at the median, with up to 1,500 more for the adaptive thinking it\n // is asked with — an estimate until a workspace measures it, read high so\n // the quote beside a model never undersells the exchange.\n 'job.page': { inputTokens: 600, outputTokens: 2_650, cacheReadTokens: 4_400, cacheWriteTokens: 0 },\n // One product's copy (AGL-2916), the exchange a bulk job makes once a\n // product: the doctrine, the copy rules and the tool (about 9,500 characters)\n // are the cached prefix; the product's facts, the site's categories and a\n // photo at most 768 pixels on its long edge (about 790 tokens) ride\n // uncached; and the answer is a description with its search listing, tags,\n // categories and option names, about 1,300 characters of JSON.\n 'job.products': { inputTokens: 1_500, outputTokens: 450, cacheReadTokens: 2_400, cacheWriteTokens: 0 },\n // The SEO step's listing exchange, which a page's or a product's listing is\n // exactly one of: the median of 146 production listings of October 8–14\n // (2,255 input and 213 output tokens on Claude Haiku 4.5), counted as the\n // fast tier's Claude Haiku 5.5 counts them, about 30% more (AGL-3781). The\n // doctrine's block in its field scope, the listing rules and the tool's\n // schema are its prefix, which caches on that model and which a site's next\n // listing reads; a lone listing writes it, so it is counted as input. The\n // page text, capped at 2,000 characters, rides with the current listing and a\n // dozen other titles. The largest answer the tool accepts is about 600\n // characters of JSON, and the request asks for no thinking. An audit pass is\n // heavier: eight pages' findings and text, about 9,000 characters, with up to\n // about 8,000 back.\n 'job.seo': { inputTokens: 2_930, outputTokens: 277, cacheReadTokens: 0, cacheWriteTokens: 0 },\n // The experiment step (AGL-2914). NOTHING is cached: the A/B test rules\n // and the acceptable-use block come to about 2,300 characters, under the\n // balanced tier's cacheable minimum, so they are billed as input every\n // time. The copy under test, or a test's arms with its verdict, rides with\n // them, and a four-variant answer is about 800 characters of JSON.\n 'job.experiment': { inputTokens: 900, outputTokens: 300, cacheReadTokens: 0, cacheWriteTokens: 0 },\n // The form step: the doctrine, the form instructions, the form surface's\n // catalog (about 150 tokens) and the tool's schema are the cached prefix, the\n // site inventory and the brief ride uncached, and a form's answer is 200 to\n // 400 tokens of JSON with no extended thinking.\n 'job.form': { inputTokens: 700, outputTokens: 450, cacheReadTokens: 3_900, cacheWriteTokens: 0 },\n // An insight (AGL-2915): two exchanges, and NOTHING cached — the rules and\n // the acceptable-use block are under the balanced tier's minimum, so they\n // are billed as input on both. The read call carries the question and the\n // readers' catalog (about 2,000 characters) and answers a few reads; the\n // answer call carries four tables of about ten rows each (about 4,000\n // characters) and answers three to five insights as JSON.\n 'job.insight': { inputTokens: 2_800, outputTokens: 650, cacheReadTokens: 0, cacheWriteTokens: 0 },\n // The email step, and the campaign step that shares its generation: the\n // doctrine, the email instructions, the email palette catalog and the\n // tool's schema (about 10,300 characters) are the cached prefix, the site\n // inventory and the brief ride uncached, and the answer is one email's\n // node map with three subject lines and three preheaders.\n 'job.email': { inputTokens: 600, outputTokens: 1_500, cacheReadTokens: 3_600, cacheWriteTokens: 0 },\n 'job.campaign': { inputTokens: 600, outputTokens: 1_500, cacheReadTokens: 3_600, cacheWriteTokens: 0 },\n // The workflow step's draft (AGL-2919): the doctrine, the automation\n // vocabulary and the tool's schema are the cached prefix (4,564 tokens, as\n // `runtime/ai-prompt-cache.spec.ts` measures it); what the workspace can\n // run, the site's forms and datasets and the description ride uncached; and\n // an automation of a few steps is about 1,300 characters of JSON with as\n // much again to think in. An explanation caches half as much.\n 'job.workflow': { inputTokens: 500, outputTokens: 1_000, cacheReadTokens: 4_500, cacheWriteTokens: 0 },\n // The logic step (AGL-3603): the fields doctrine, one rules block and the\n // tool's schema are the cached prefix (1,556 tokens for a function, as\n // `runtime/ai-prompt-cache.spec.ts` measures it); the site's variables and\n // the request ride uncached, and a function of a few operations is about\n // 1,200 characters of JSON with as much again to think in.\n 'job.logic': { inputTokens: 700, outputTokens: 900, cacheReadTokens: 1_500, cacheWriteTokens: 0 },\n // The edit step (AGL-3616): the document doctrine, the job's rules and the\n // edit rung's protocol and catalog for the document's kind are the cached\n // prefix (5,970 tokens for a page, as `runtime/ai-prompt-cache.spec.ts`\n // measures it); the outline of up to sixty elements with their settings\n // and the request ride uncached, and a change of a few operations is about\n // 1,500 characters of tool call with as much again to think in.\n 'job.edit': { inputTokens: 2_500, outputTokens: 1_000, cacheReadTokens: 6_000, cacheWriteTokens: 0 },\n}\n\n/** The fewest measured exchanges a median is taken over. */\nexport const AI_MEASURED_MEDIAN_MIN_SAMPLES = 3\n\nexport interface AiModelBounds {\n plan: OrgPlan\n /** The allotment allowlists that apply, intersected; `null` for none. */\n allotmentModels?: readonly string[] | null\n /** The org-wide restriction; `null` for none. */\n orgModels?: readonly string[] | null\n}\n\n/** Whether a list names a model, a retired id on it naming its successor (AGL-3781). */\nfunction names(list: readonly string[], id: string): boolean {\n return list.some((listed) => aiServingModelId(listed) === id)\n}\n\nfunction onLists(entry: AiCatalogEntry, bounds: AiModelBounds): boolean {\n if (bounds.orgModels?.length && !names(bounds.orgModels, entry.id)) return false\n if (bounds.allotmentModels && !names(bounds.allotmentModels, entry.id)) return false\n return true\n}\n\n/** The current catalog models a manual pick may name on a provider under these bounds. */\nexport function aiModelsSelectable(\n providerId: string,\n bounds: AiModelBounds,\n): AiCatalogEntry[] {\n const tiers = AI_PLAN_MODEL_TIERS[bounds.plan] ?? []\n return AI_MODEL_CATALOG.filter(\n (entry) =>\n entry.provider === providerId &&\n !entry.successor &&\n tiers.includes(entry.tier) &&\n onLists(entry, bounds),\n )\n}\n\n/**\n * A model's blended BILLED rate, for \"the cheapest allowed\" and nothing\n * else.\n *\n * Billed and not provider (AGL-3015): the substitution below happens when a\n * workspace asked for a model its bounds do not allow, and the party it\n * falls back for is the one whose credits are drawn. \"Cheapest\" has to mean\n * the same thing here as in the selector this substitution stands in for,\n * which sorts on `creditsPerRequest`.\n */\nconst blendedRate = (id: string): number => {\n const rates = aiBilledRatesForModel(id)\n return rates.inputPerToken + rates.outputPerToken\n}\n\nexport interface AiModelChoice {\n /** The catalog id the request runs, and is metered, on. */\n model: string\n /** True when the routing table decided: Auto, or a pick that was declined. */\n auto: boolean\n /** A pick that was asked for and is not allowed, for the envelope. */\n declined: string | null\n}\n\n/**\n * The model one request runs on, or `null` when no provider is registered —\n * which every door has refused before it asks.\n */\nexport function resolveAiModelChoice(\n kind: AiStepKind,\n requested: unknown,\n bounds: AiModelBounds,\n settings?: AiPluginSettings,\n): AiModelChoice | null {\n const route = resolveAiRoute(kind, settings)\n if (!route) return null\n // A pick of a retired model, from a job made before it retired, is a pick\n // of the model that serves in its place.\n const wanted =\n typeof requested === 'string' && requested.trim() && requested.trim() !== AI_MODEL_AUTO\n ? aiServingModelId(requested.trim())\n : null\n if (wanted && aiModelsSelectable(route.provider.id, bounds).some((entry) => entry.id === wanted)) {\n return { model: wanted, auto: false, declined: null }\n }\n const restricted = Boolean(bounds.orgModels?.length) || Boolean(bounds.allotmentModels)\n let model = route.model\n if (restricted) {\n const allowed = AI_MODEL_CATALOG.filter(\n (entry) => entry.provider === route.provider.id && !entry.successor && onLists(entry, bounds),\n )\n if (allowed.length && !allowed.some((entry) => entry.id === model)) {\n const tier = aiCatalogEntry(model)?.tier ?? AI_STEP_TIERS[kind]\n const sameTier = allowed.find((entry) => entry.tier === tier)\n const cheapest = [...allowed].sort((a, b) => blendedRate(a.id) - blendedRate(b.id))[0]\n model = (sameTier ?? cheapest).id\n }\n }\n return { model, auto: true, declined: wanted }\n}\n\n/** The median exchange over measured samples, or `null` below the minimum. */\nexport function aiMedianUsage(samples: readonly AiUsage[]): AiUsage | null {\n if (samples.length < AI_MEASURED_MEDIAN_MIN_SAMPLES) return null\n const median = (field: keyof AiUsage): number => {\n const values = samples\n .map((sample) => Number(sample[field] ?? 0))\n .filter((value) => Number.isFinite(value) && value >= 0)\n .sort((a, b) => a - b)\n if (!values.length) return 0\n const middle = Math.floor(values.length / 2)\n return values.length % 2\n ? values[middle]\n : Math.round((values[middle - 1] + values[middle]) / 2)\n }\n return {\n inputTokens: median('inputTokens'),\n outputTokens: median('outputTokens'),\n cacheReadTokens: median('cacheReadTokens'),\n cacheWriteTokens: median('cacheWriteTokens'),\n }\n}\n\nexport interface AiModelOption {\n /** A catalog id, or `AI_MODEL_AUTO`. */\n id: string\n label: string\n tier: AiCatalogEntry['tier']\n /** Credits a typical request of this kind costs on the option. */\n creditsPerRequest: number\n /** That cost as a multiple of Auto's, to one decimal. */\n multiplier: number\n}\n\nexport interface AiModelOptions {\n /** Auto, labeled with the model it routes this kind to under these bounds. */\n auto: AiModelOption & { model: string }\n /** The manual picks, cheapest first; empty where the plan offers none. */\n options: AiModelOption[]\n /** Whether the price came from the workspace's own measured exchanges. */\n measured: boolean\n}\n\n/** What the selector lists for one step kind, or `null` without a provider. */\nexport function aiModelOptions(\n kind: AiStepKind,\n bounds: AiModelBounds,\n measured: AiUsage | null,\n settings?: AiPluginSettings,\n): AiModelOptions | null {\n const route = resolveAiRoute(kind, settings)\n const auto = resolveAiModelChoice(kind, null, bounds, settings)\n if (!route || !auto) return null\n const typical = measured ?? AI_STEP_NOMINAL_USAGE[kind]\n // Billed rates throughout (AGL-3015): every figure below is what the\n // workspace will be charged for picking this model — credits per request\n // and the multiple of Auto those credits come to. Our own cost for the\n // same request is not this selector's subject and would misstate both.\n const autoCost = estimateAiBilledUsd(typical, auto.model)\n const priced = (entry: AiCatalogEntry): AiModelOption => {\n const cost = estimateAiBilledUsd(typical, entry.id)\n return {\n id: entry.id,\n label: entry.label,\n tier: entry.tier,\n creditsPerRequest: assistCreditsFromUsd(cost),\n multiplier: autoCost > 0 ? Math.round((cost / autoCost) * 10) / 10 : 1,\n }\n }\n const autoEntry = aiCatalogEntry(auto.model)\n return {\n auto: {\n id: AI_MODEL_AUTO,\n label: autoEntry ? `Auto (${autoEntry.label})` : 'Auto',\n tier: autoEntry?.tier ?? AI_STEP_TIERS[kind],\n creditsPerRequest: assistCreditsFromUsd(autoCost),\n multiplier: 1,\n model: auto.model,\n },\n options: aiModelsSelectable(route.provider.id, bounds)\n .map(priced)\n .sort((a, b) => a.creditsPerRequest - b.creditsPerRequest || a.label.localeCompare(b.label)),\n measured: measured !== null,\n }\n}\n"],"names":["assistCreditsFromUsd","AI_MODEL_CATALOG","AI_STEP_TIERS","aiCatalogEntry","aiBilledRatesForModel","estimateAiBilledUsd","aiServingModelId","resolveAiRoute","AI_MODEL_AUTO","AI_PLAN_MODEL_TIERS","free","starter","pro","business","scale","advanced","agency","enterprise","AI_MODEL_RESTRICTION_PLANS","AI_STEP_NOMINAL_USAGE","inputTokens","outputTokens","cacheReadTokens","cacheWriteTokens","AI_MEASURED_MEDIAN_MIN_SAMPLES","names","list","id","some","listed","onLists","entry","bounds","orgModels","length","allotmentModels","aiModelsSelectable","providerId","tiers","plan","filter","provider","successor","includes","tier","blendedRate","rates","inputPerToken","outputPerToken","resolveAiModelChoice","kind","requested","settings","route","wanted","trim","model","auto","declined","restricted","Boolean","allowed","sameTier","find","cheapest","sort","a","b","aiMedianUsage","samples","median","field","values","map","sample","Number","value","isFinite","middle","Math","floor","round","aiModelOptions","measured","typical","autoCost","priced","cost","label","creditsPerRequest","multiplier","autoEntry","options","localeCompare"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,oBAAoB,QAAQ,6BAAyB;AAE9D,SACEC,gBAAgB,EAChBC,aAAa,EACbC,cAAc,EACdC,qBAAqB,EACrBC,mBAAmB,QAGd,eAAW;AAElB,SAASC,gBAAgB,EAAEC,cAAc,QAA+B,eAAW;AAEnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BC,GAED,+DAA+D,GAC/D,OAAO,MAAMC,gBAAgB,OAAM;AAEnC;;;;;;CAMC,GACD,OAAO,M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Y,MAAM,KAAK;QACvE;IACF;IACA,MAAMM,YAAYxF,eAAesD,KAAKD,KAAK;IAC3C,OAAO;QACLC,MAAM;YACJ9B,IAAInB;YACJgF,OAAOG,YAAY,CAAC,MAAM,EAAEA,UAAUH,KAAK,CAAC,CAAC,CAAC,GAAG;YACjD5C,IAAI,UAAE+C,6BAAAA,UAAW/C,IAAI,mBAAI1C,aAAa,CAACgD,KAAK;YAC5CuC,mBAAmBzF,qBAAqBqF;YACxCK,YAAY;YACZlC,OAAOC,KAAKD,KAAK;QACnB;QACAoC,SAASxD,mBAAmBiB,MAAMZ,QAAQ,CAACd,EAAE,EAAEK,QAC5CyC,GAAG,CAACa,QACJrB,IAAI,CAAC,CAACC,GAAGC,IAAMD,EAAEuB,iBAAiB,GAAGtB,EAAEsB,iBAAiB,IAAIvB,EAAEsB,KAAK,CAACK,aAAa,CAAC1B,EAAEqB,KAAK;QAC5FL,UAAUA,aAAa;IACzB;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/providers/model-choice.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { assistCreditsFromUsd } from '../usage/assist-credits'\nimport type { OrgPlan } from '@aglyn/aglyn/foundation/definitions/org-billing.types'\nimport {\n AI_MODEL_CATALOG,\n AI_STEP_TIERS,\n aiCatalogEntry,\n aiBilledRatesForModel,\n estimateAiBilledUsd,\n type AiCatalogEntry,\n type AiStepKind,\n} from './catalog'\nimport type { AiUsage } from './contract'\nimport { aiServingModelId, resolveAiRoute, type AiPluginSettings } from './routing'\n\n/**\n * THE MODEL SWITCH (AGL-2942): what a person may pick, what \"Auto\" means,\n * and what a pick costs.\n *\n * ## Auto is the routing table\n *\n * A request that names no model — or names one it may not have — runs on\n * `resolveAiRoute(kind)`, the table that maps a step kind to a catalog model\n * (AGL-2937). Picking a model is an override of that one row for one request,\n * never a second table.\n *\n * ## Three bounds, one intersection\n *\n * A manual pick must be served by the active provider, in a tier the org's\n * plan offers (`AI_PLAN_MODEL_TIERS`), on the org's own restriction when it\n * set one, and on the allotment allowlists that apply to the request. The\n * two allowlists bound Auto too: when the routing table's answer is not on\n * them, Auto runs on the allowed model of the same tier, else the cheapest\n * allowed one. The plan bounds only a pick — Auto is the platform's choice,\n * made for the step, and a plan never makes it worse.\n *\n * An allowlist that leaves nothing this deployment serves is not a way to\n * switch AI off by mistake: the choice falls back to the routing table, and\n * the permission keys are how AI is switched off on purpose.\n *\n * ## The price beside each option\n *\n * Credits per typical request at each model's list rates, over the step's\n * measured median exchange when the workspace has enough of them, and over\n * `AI_STEP_NOMINAL_USAGE` until it does — with the multiple of what Auto\n * would cost for the same request. Every figure is credits, never dollars.\n */\n\n/** The value a request sends for \"let the platform route it\". */\nexport const AI_MODEL_AUTO = 'auto'\n\n/**\n * The catalog tiers a MANUAL pick may name, per plan. Free runs on Auto only:\n * its taste is a wall, and a pick there would spend the account's credits at\n * a rate nobody chose on purpose. The dearest tier opened from Scale up,\n * where the band is large enough that a slower, deeper model is a real choice\n * rather than a fast way to end the month — and from Pro since pricing v4\n * (2026-11-03, AGL-4126), which moved the deep model picks into the plan that\n * became the full platform. A credit is a fixed quantity of provider spend,\n * so a deeper pick spends the band faster and never past what it covers.\n */\nexport const AI_PLAN_MODEL_TIERS: Record<OrgPlan, readonly AiCatalogEntry['tier'][]> = {\n free: [],\n starter: ['fast', 'balanced'],\n pro: ['fast', 'balanced', 'deep'],\n business: ['fast', 'balanced'],\n scale: ['fast', 'balanced', 'deep'],\n advanced: ['fast', 'balanced', 'deep'],\n agency: ['fast', 'balanced', 'deep'],\n enterprise: ['fast', 'balanced', 'deep'],\n}\n\n/** The plans whose admins may restrict the model set org-wide. */\nexport const AI_MODEL_RESTRICTION_PLANS: readonly OrgPlan[] = ['agency', 'enterprise']\n\n/**\n * A typical exchange per step kind, before a workspace has measured one: the\n * doors' own prompt sizes and output ceilings, read conservatively. Replaced\n * by the workspace's measured median as soon as `aiMedianUsage` has enough\n * samples, and only ever used for the price beside an option.\n */\nexport const AI_STEP_NOMINAL_USAGE: Record<AiStepKind, AiUsage> = {\n 'assist.chat': { inputTokens: 900, outputTokens: 450, cacheReadTokens: 1_050, cacheWriteTokens: 0 },\n // One element's rewrite on the fast tier, counted as Claude Haiku 5.5 counts\n // it: about 30% more tokens than Haiku 4.5 for the same text (AGL-3781).\n 'copy.element': { inputTokens: 455, outputTokens: 156, cacheReadTokens: 0, cacheWriteTokens: 0 },\n 'copy.section': { inputTokens: 700, outputTokens: 1_400, cacheReadTokens: 0, cacheWriteTokens: 0 },\n 'copy.blog': { inputTokens: 600, outputTokens: 1_100, cacheReadTokens: 0, cacheWriteTokens: 0 },\n 'generate.section': { inputTokens: 700, outputTokens: 1_400, cacheReadTokens: 0, cacheWriteTokens: 0 },\n // The text step's rules are about 500 characters — far under the balanced\n // tier's cacheable minimum, so they are billed as input every time rather\n // than read from a cache (`runtime/ai-prompt-cache.spec.ts` measures it).\n 'job.text': { inputTokens: 450, outputTokens: 500, cacheReadTokens: 0, cacheWriteTokens: 0 },\n // The theme step: the tool's schema and both system blocks (about 7,500\n // characters) are the cached prefix, the site's inventory and the brief ride\n // uncached, and a full-palette answer is about 1,300 characters of JSON with\n // as much again to think in.\n 'job.theme': { inputTokens: 500, outputTokens: 850, cacheReadTokens: 2_500, cacheWriteTokens: 0 },\n // The plan step: the tool's schema, the doctrine and the plan instructions\n // (about 10,000 characters) are the cached prefix, the site inventory and the\n // brief ride uncached, and a plan answer is about 600 characters of JSON with\n // as much again to think in.\n 'job.plan': { inputTokens: 500, outputTokens: 400, cacheReadTokens: 3_600, cacheWriteTokens: 0 },\n // The component step: the doctrine, the component instructions, the\n // component surface's catalog and the tool are the cached prefix, the site\n // inventory, the brief and the confirmed plan ride uncached, and a card-sized\n // answer — its tree and declared props as JSON — is about 1,700 characters.\n // The component step's spec measures the prefix and the answer against this.\n 'job.component': { inputTokens: 700, outputTokens: 600, cacheReadTokens: 5_800, cacheWriteTokens: 0 },\n // The CRM step's exchange (AGL-2917), counted as the fast tier's Claude\n // Haiku 5.5 counts it, about 30% more tokens than Haiku 4.5 (AGL-3781). The\n // doctrine's field rules, the CRM rules and the tool come to 650 to 913\n // tokens, as `runtime/ai-prompt-cache.spec.ts` measures them, which caches on\n // that model; one question about a record writes it, so it is counted as\n // input. A record's facts ride with them, a timeline cut to its newest twelve\n // entries, and the typical answer is a summary and a next step of a few\n // sentences, with no thinking.\n 'job.crm': { inputTokens: 2_340, outputTokens: 325, cacheReadTokens: 0, cacheWriteTokens: 0 },\n // A layout: a tree layout's 1,000 output tokens until AGL-3660, now a\n // site's header and footer in the layout language — 442 to 583 output\n // tokens live on 2026-10-07 — with up to 1,500 more for the adaptive\n // thinking it is asked with, an estimate until a workspace measures it.\n 'job.layout': { inputTokens: 700, outputTokens: 2_000, cacheReadTokens: 5_600, cacheWriteTokens: 0 },\n 'job.template': { inputTokens: 1_200, outputTokens: 700, cacheReadTokens: 6_400, cacheWriteTokens: 0 },\n // One page section's exchange (AGL-2907), from the modules' own text: the\n // doctrine (6,281 characters), the page instructions (1,524), the screen\n // palette catalog (8,353) and the section tool (484) are the cached prefix;\n // the site inventory (711 on the median golden site), the brief, the plan\n // and the section line ride uncached; and a golden section answer is 901\n // characters at the median, asked for with no thinking.\n // Since AGL-3660 a site's and a build's pages are one answer a page in\n // the layout language: 683 to 1,745 output tokens live on 2026-10-07, about\n // 1,150 at the median, with up to 1,500 more for the adaptive thinking it\n // is asked with — an estimate until a workspace measures it, read high so\n // the quote beside a model never undersells the exchange.\n 'job.page': { inputTokens: 600, outputTokens: 2_650, cacheReadTokens: 4_400, cacheWriteTokens: 0 },\n // One product's copy (AGL-2916), the exchange a bulk job makes once a\n // product: the doctrine, the copy rules and the tool (about 9,500 characters)\n // are the cached prefix; the product's facts, the site's categories and a\n // photo at most 768 pixels on its long edge (about 790 tokens) ride\n // uncached; and the answer is a description with its search listing, tags,\n // categories and option names, about 1,300 characters of JSON.\n 'job.products': { inputTokens: 1_500, outputTokens: 450, cacheReadTokens: 2_400, cacheWriteTokens: 0 },\n // The SEO step's listing exchange, which a page's or a product's listing is\n // exactly one of: the median of 146 production listings of October 8–14\n // (2,255 input and 213 output tokens on Claude Haiku 4.5), counted as the\n // fast tier's Claude Haiku 5.5 counts them, about 30% more (AGL-3781). The\n // doctrine's block in its field scope, the listing rules and the tool's\n // schema are its prefix, which caches on that model and which a site's next\n // listing reads; a lone listing writes it, so it is counted as input. The\n // page text, capped at 2,000 characters, rides with the current listing and a\n // dozen other titles. The largest answer the tool accepts is about 600\n // characters of JSON, and the request asks for no thinking. An audit pass is\n // heavier: eight pages' findings and text, about 9,000 characters, with up to\n // about 8,000 back.\n 'job.seo': { inputTokens: 2_930, outputTokens: 277, cacheReadTokens: 0, cacheWriteTokens: 0 },\n // The experiment step (AGL-2914). NOTHING is cached: the A/B test rules\n // and the acceptable-use block come to about 2,300 characters, under the\n // balanced tier's cacheable minimum, so they are billed as input every\n // time. The copy under test, or a test's arms with its verdict, rides with\n // them, and a four-variant answer is about 800 characters of JSON.\n 'job.experiment': { inputTokens: 900, outputTokens: 300, cacheReadTokens: 0, cacheWriteTokens: 0 },\n // The form step: the doctrine, the form instructions, the form surface's\n // catalog (about 150 tokens) and the tool's schema are the cached prefix, the\n // site inventory and the brief ride uncached, and a form's answer is 200 to\n // 400 tokens of JSON with no extended thinking.\n 'job.form': { inputTokens: 700, outputTokens: 450, cacheReadTokens: 3_900, cacheWriteTokens: 0 },\n // An insight (AGL-2915): two exchanges, and NOTHING cached — the rules and\n // the acceptable-use block are under the balanced tier's minimum, so they\n // are billed as input on both. The read call carries the question and the\n // readers' catalog (about 2,000 characters) and answers a few reads; the\n // answer call carries four tables of about ten rows each (about 4,000\n // characters) and answers three to five insights as JSON.\n 'job.insight': { inputTokens: 2_800, outputTokens: 650, cacheReadTokens: 0, cacheWriteTokens: 0 },\n // The email step, and the campaign step that shares its generation: the\n // doctrine, the email instructions, the email palette catalog and the\n // tool's schema (about 10,300 characters) are the cached prefix, the site\n // inventory and the brief ride uncached, and the answer is one email's\n // node map with three subject lines and three preheaders.\n 'job.email': { inputTokens: 600, outputTokens: 1_500, cacheReadTokens: 3_600, cacheWriteTokens: 0 },\n 'job.campaign': { inputTokens: 600, outputTokens: 1_500, cacheReadTokens: 3_600, cacheWriteTokens: 0 },\n // The workflow step's draft (AGL-2919): the doctrine, the automation\n // vocabulary and the tool's schema are the cached prefix (4,564 tokens, as\n // `runtime/ai-prompt-cache.spec.ts` measures it); what the workspace can\n // run, the site's forms and datasets and the description ride uncached; and\n // an automation of a few steps is about 1,300 characters of JSON with as\n // much again to think in. An explanation caches half as much.\n 'job.workflow': { inputTokens: 500, outputTokens: 1_000, cacheReadTokens: 4_500, cacheWriteTokens: 0 },\n // The logic step (AGL-3603): the fields doctrine, one rules block and the\n // tool's schema are the cached prefix (1,556 tokens for a function, as\n // `runtime/ai-prompt-cache.spec.ts` measures it); the site's variables and\n // the request ride uncached, and a function of a few operations is about\n // 1,200 characters of JSON with as much again to think in.\n 'job.logic': { inputTokens: 700, outputTokens: 900, cacheReadTokens: 1_500, cacheWriteTokens: 0 },\n // The edit step (AGL-3616): the document doctrine, the job's rules and the\n // edit rung's protocol and catalog for the document's kind are the cached\n // prefix (5,970 tokens for a page, as `runtime/ai-prompt-cache.spec.ts`\n // measures it); the outline of up to sixty elements with their settings\n // and the request ride uncached, and a change of a few operations is about\n // 1,500 characters of tool call with as much again to think in.\n 'job.edit': { inputTokens: 2_500, outputTokens: 1_000, cacheReadTokens: 6_000, cacheWriteTokens: 0 },\n}\n\n/** The fewest measured exchanges a median is taken over. */\nexport const AI_MEASURED_MEDIAN_MIN_SAMPLES = 3\n\nexport interface AiModelBounds {\n plan: OrgPlan\n /** The allotment allowlists that apply, intersected; `null` for none. */\n allotmentModels?: readonly string[] | null\n /** The org-wide restriction; `null` for none. */\n orgModels?: readonly string[] | null\n}\n\n/** Whether a list names a model, a retired id on it naming its successor (AGL-3781). */\nfunction names(list: readonly string[], id: string): boolean {\n return list.some((listed) => aiServingModelId(listed) === id)\n}\n\nfunction onLists(entry: AiCatalogEntry, bounds: AiModelBounds): boolean {\n if (bounds.orgModels?.length && !names(bounds.orgModels, entry.id)) return false\n if (bounds.allotmentModels && !names(bounds.allotmentModels, entry.id)) return false\n return true\n}\n\n/** The current catalog models a manual pick may name on a provider under these bounds. */\nexport function aiModelsSelectable(\n providerId: string,\n bounds: AiModelBounds,\n): AiCatalogEntry[] {\n const tiers = AI_PLAN_MODEL_TIERS[bounds.plan] ?? []\n return AI_MODEL_CATALOG.filter(\n (entry) =>\n entry.provider === providerId &&\n !entry.successor &&\n tiers.includes(entry.tier) &&\n onLists(entry, bounds),\n )\n}\n\n/**\n * A model's blended BILLED rate, for \"the cheapest allowed\" and nothing\n * else.\n *\n * Billed and not provider (AGL-3015): the substitution below happens when a\n * workspace asked for a model its bounds do not allow, and the party it\n * falls back for is the one whose credits are drawn. \"Cheapest\" has to mean\n * the same thing here as in the selector this substitution stands in for,\n * which sorts on `creditsPerRequest`.\n */\nconst blendedRate = (id: string): number => {\n const rates = aiBilledRatesForModel(id)\n return rates.inputPerToken + rates.outputPerToken\n}\n\nexport interface AiModelChoice {\n /** The catalog id the request runs, and is metered, on. */\n model: string\n /** True when the routing table decided: Auto, or a pick that was declined. */\n auto: boolean\n /** A pick that was asked for and is not allowed, for the envelope. */\n declined: string | null\n}\n\n/**\n * The model one request runs on, or `null` when no provider is registered —\n * which every door has refused before it asks.\n */\nexport function resolveAiModelChoice(\n kind: AiStepKind,\n requested: unknown,\n bounds: AiModelBounds,\n settings?: AiPluginSettings,\n): AiModelChoice | null {\n const route = resolveAiRoute(kind, settings)\n if (!route) return null\n // A pick of a retired model, from a job made before it retired, is a pick\n // of the model that serves in its place.\n const wanted =\n typeof requested === 'string' && requested.trim() && requested.trim() !== AI_MODEL_AUTO\n ? aiServingModelId(requested.trim())\n : null\n if (wanted && aiModelsSelectable(route.provider.id, bounds).some((entry) => entry.id === wanted)) {\n return { model: wanted, auto: false, declined: null }\n }\n const restricted = Boolean(bounds.orgModels?.length) || Boolean(bounds.allotmentModels)\n let model = route.model\n if (restricted) {\n const allowed = AI_MODEL_CATALOG.filter(\n (entry) => entry.provider === route.provider.id && !entry.successor && onLists(entry, bounds),\n )\n if (allowed.length && !allowed.some((entry) => entry.id === model)) {\n const tier = aiCatalogEntry(model)?.tier ?? AI_STEP_TIERS[kind]\n const sameTier = allowed.find((entry) => entry.tier === tier)\n const cheapest = [...allowed].sort((a, b) => blendedRate(a.id) - blendedRate(b.id))[0]\n model = (sameTier ?? cheapest).id\n }\n }\n return { model, auto: true, declined: wanted }\n}\n\n/** The median exchange over measured samples, or `null` below the minimum. */\nexport function aiMedianUsage(samples: readonly AiUsage[]): AiUsage | null {\n if (samples.length < AI_MEASURED_MEDIAN_MIN_SAMPLES) return null\n const median = (field: keyof AiUsage): number => {\n const values = samples\n .map((sample) => Number(sample[field] ?? 0))\n .filter((value) => Number.isFinite(value) && value >= 0)\n .sort((a, b) => a - b)\n if (!values.length) return 0\n const middle = Math.floor(values.length / 2)\n return values.length % 2\n ? values[middle]\n : Math.round((values[middle - 1] + values[middle]) / 2)\n }\n return {\n inputTokens: median('inputTokens'),\n outputTokens: median('outputTokens'),\n cacheReadTokens: median('cacheReadTokens'),\n cacheWriteTokens: median('cacheWriteTokens'),\n }\n}\n\nexport interface AiModelOption {\n /** A catalog id, or `AI_MODEL_AUTO`. */\n id: string\n label: string\n tier: AiCatalogEntry['tier']\n /** Credits a typical request of this kind costs on the option. */\n creditsPerRequest: number\n /** That cost as a multiple of Auto's, to one decimal. */\n multiplier: number\n}\n\nexport interface AiModelOptions {\n /** Auto, labeled with the model it routes this kind to under these bounds. */\n auto: AiModelOption & { model: string }\n /** The manual picks, cheapest first; empty where the plan offers none. */\n options: AiModelOption[]\n /** Whether the price came from the workspace's own measured exchanges. */\n measured: boolean\n}\n\n/** What the selector lists for one step kind, or `null` without a provider. */\nexport function aiModelOptions(\n kind: AiStepKind,\n bounds: AiModelBounds,\n measured: AiUsage | null,\n settings?: AiPluginSettings,\n): AiModelOptions | null {\n const route = resolveAiRoute(kind, settings)\n const auto = resolveAiModelChoice(kind, null, bounds, settings)\n if (!route || !auto) return null\n const typical = measured ?? AI_STEP_NOMINAL_USAGE[kind]\n // Billed rates throughout (AGL-3015): every figure below is what the\n // workspace will be charged for picking this model — credits per request\n // and the multiple of Auto those credits come to. Our own cost for the\n // same request is not this selector's subject and would misstate both.\n const autoCost = estimateAiBilledUsd(typical, auto.model)\n const priced = (entry: AiCatalogEntry): AiModelOption => {\n const cost = estimateAiBilledUsd(typical, entry.id)\n return {\n id: entry.id,\n label: entry.label,\n tier: entry.tier,\n creditsPerRequest: assistCreditsFromUsd(cost),\n multiplier: autoCost > 0 ? Math.round((cost / autoCost) * 10) / 10 : 1,\n }\n }\n const autoEntry = aiCatalogEntry(auto.model)\n return {\n auto: {\n id: AI_MODEL_AUTO,\n label: autoEntry ? `Auto (${autoEntry.label})` : 'Auto',\n tier: autoEntry?.tier ?? AI_STEP_TIERS[kind],\n creditsPerRequest: assistCreditsFromUsd(autoCost),\n multiplier: 1,\n model: auto.model,\n },\n options: aiModelsSelectable(route.provider.id, bounds)\n .map(priced)\n .sort((a, b) => a.creditsPerRequest - b.creditsPerRequest || a.label.localeCompare(b.label)),\n measured: measured !== null,\n }\n}\n"],"names":["assistCreditsFromUsd","AI_MODEL_CATALOG","AI_STEP_TIERS","aiCatalogEntry","aiBilledRatesForModel","estimateAiBilledUsd","aiServingModelId","resolveAiRoute","AI_MODEL_AUTO","AI_PLAN_MODEL_TIERS","free","starter","pro","business","scale","advanced","agency","enterprise","AI_MODEL_RESTRICTION_PLANS","AI_STEP_NOMINAL_USAGE","inputTokens","outputTokens","cacheReadTokens","cacheWriteTokens","AI_MEASURED_MEDIAN_MIN_SAMPLES","names","list","id","some","listed","onLists","entry","bounds","orgModels","length","allotmentModels","aiModelsSelectable","providerId","tiers","plan","filter","provider","successor","includes","tier","blendedRate","rates","inputPerToken","outputPerToken","resolveAiModelChoice","kind","requested","settings","route","wanted","trim","model","auto","declined","restricted","Boolean","allowed","sameTier","find","cheapest","sort","a","b","aiMedianUsage","samples","median","field","values","map","sample","Number","value","isFinite","middle","Math","floor","round","aiModelOptions","measured","typical","autoCost","priced","cost","label","creditsPerRequest","multiplier","autoEntry","options","localeCompare"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,oBAAoB,QAAQ,6BAAyB;AAE9D,SACEC,gBAAgB,EAChBC,aAAa,EACbC,cAAc,EACdC,qBAAqB,EACrBC,mBAAmB,QAGd,eAAW;AAElB,SAASC,gBAAgB,EAAEC,cAAc,QAA+B,eAAW;AAEnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BC,GAED,+DAA+D,GAC/D,OAAO,MAAMC,gBAAgB,OAAM;AAEnC;;;;;;;;;CASC,GACD,OAAO,MAAMC,sBAA0E;IACrFC,MAAM,EAAE;IACRC,SAAS;QAAC;QAAQ;KAAW;IAC7BC,KAAK;QAAC;QAAQ;QAAY;KAAO;IACjCC,UAAU;QAAC;QAAQ;KAAW;IAC9BC,OAAO;QAAC;QAAQ;QAAY;KAAO;IACnCC,UAAU;QAAC;QAAQ;QAAY;KAAO;IACtCC,QAAQ;QAAC;QAAQ;QAAY;KAAO;IACpCC,YAAY;QAAC;QAAQ;QAAY;KAAO;AAC1C,EAAC;AAED,gEAAgE,GAChE,OAAO,MAAMC,6BAAiD;IAAC;IAAU;CAAa,CAAA;AAEtF;;;;;CAKC,GACD,OAAO,MAAMC,wBAAqD;I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,CAACa,QACJrB,IAAI,CAAC,CAACC,GAAGC,IAAMD,EAAEuB,iBAAiB,GAAGtB,EAAEsB,iBAAiB,IAAIvB,EAAEsB,KAAK,CAACK,aAAa,CAAC1B,EAAEqB,KAAK;QAC5FL,UAAUA,aAAa;IACzB;AACF"}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
import type
|
|
17
|
+
import { type AiSiteImportDocument } from '../../jobs/ai-site-import-document';
|
|
18
18
|
import { type SiteImportFooter, type SiteImportNavTree } from '../../model/ai-site-import';
|
|
19
19
|
import type { SiteImportFidelitySource, SiteImportFidelityTree } from '../../model/ai-site-import-fidelity';
|
|
20
20
|
import { type SiteLayoutPageName } from './site-layout-recordings';
|
|
@@ -29,6 +29,7 @@ import { aiSiteImportFrameJob, aiSiteImportHomeOf } from "../../jobs/ai-job-impo
|
|
|
29
29
|
import { aiLayoutSiteBrandOf, aiLayoutSiteFrameOf, aiLayoutSourceFrameBuild } from "../../jobs/ai-job-layout-language.js";
|
|
30
30
|
import { aiLayoutChecks } from "../../jobs/ai-job-layout-step.js";
|
|
31
31
|
import { aiSiteImportSectionNames } from "../../jobs/ai-site-import-compile.js";
|
|
32
|
+
import { AI_LAYOUT_IMPORTED_SECTIONS_INPUT, aiSiteImportDocumentOf } from "../../jobs/ai-site-import-document.js";
|
|
32
33
|
import { aiSiteImportLedger } from "../../model/ai-site-import.js";
|
|
33
34
|
import { emptyAiSiteInventory } from "../../model/ai-site-inventory.js";
|
|
34
35
|
import { extractSiteImportPage } from "../site-import-html.js";
|
|
@@ -114,7 +115,10 @@ import { SITE_LAYOUT_PAGES, siteLayoutRecording, siteLayoutSameSite } from "./si
|
|
|
114
115
|
const { layout } = read, rest = _object_without_properties_loose(read, [
|
|
115
116
|
"layout"
|
|
116
117
|
]);
|
|
117
|
-
|
|
118
|
+
// As the page step reads it: through the job's input, so a fact the reader drops is dropped here too (AGL-4138).
|
|
119
|
+
const doc = aiSiteImportDocumentOf({
|
|
120
|
+
[AI_LAYOUT_IMPORTED_SECTIONS_INPUT]: JSON.parse(JSON.stringify(options.layout === false ? rest : read))
|
|
121
|
+
});
|
|
118
122
|
const names = aiSiteImportSectionNames(doc);
|
|
119
123
|
const sectionIds = names.map((_, index)=>`sec-${index}`);
|
|
120
124
|
const screen = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/plugins/ai/src/lib/site-import/fixtures/site-import-fidelity-replay.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\n/**\n * The recorded pages brought in again, offline (AGL-4109), for the fidelity\n * spec and the fidelity report: each page of `site-layout/` read by the\n * reader, built by the import's compile and held to its page check as the\n * page step stores it, and each recorded home page's header and footer drawn\n * as the frame step draws them, with no model. Every page the source links\n * on its own site is a page the import plans, as on a whole-site import. No\n * live AI: a design answer here is a recorded one, in the shape the tool\n * answers.\n */\n\nimport { aiImportedPageCheck } from '../../jobs/ai-job-page-language'\nimport { aiSiteImportFrameJob, aiSiteImportHomeOf } from '../../jobs/ai-job-import-step'\nimport { aiLayoutSiteBrandOf, aiLayoutSiteFrameOf, aiLayoutSourceFrameBuild } from '../../jobs/ai-job-layout-language'\nimport { aiLayoutChecks } from '../../jobs/ai-job-layout-step'\nimport { aiSiteImportSectionNames } from '../../jobs/ai-site-import-compile'\nimport type { AiSiteImportDocument } from '../../jobs/ai-site-import-document'\nimport type { AiLayoutFrameSource } from '../../layout-language/ai-layout-frame-source'\nimport type { AiJob } from '../../model/ai-jobs.types'\nimport { aiSiteImportLedger, type AiSiteImportPage, type AiSiteImportState, type SiteImportFooter, type SiteImportNavTree } from '../../model/ai-site-import'\nimport type { SiteImportFidelitySource, SiteImportFidelityTree } from '../../model/ai-site-import-fidelity'\nimport { emptyAiSiteInventory } from '../../model/ai-site-inventory'\nimport type { SiteImportInventory } from '../site-import-crawl'\nimport { extractSiteImportPage, type SiteImportBlock } from '../site-import-html'\nimport { siteImportLayout, siteImportLookOf } from '../site-import-layout'\nimport { siteImportFooterColumns, siteImportNavTree, type SiteImportFrameSource } from '../site-import-nav'\nimport { siteImportPageRead } from '../site-import-page'\nimport { SITE_LAYOUT_PAGES, siteLayoutRecording, siteLayoutSameSite, type SiteLayoutPageName } from './site-layout-recordings'\n\n/** The page's same-site addresses, each a page the import plans: every page a link may go to. */\nfunction plannedLinks(blocks: readonly SiteImportBlock[], origin: string): Array<{ path: string; id: string }> {\n const paths = new Set<string>()\n for (const block of blocks) {\n if (block.kind !== 'link') continue\n try {\n const url = new URL(block.href)\n const path = url.pathname.replace(/\\/+$/, '') || '/'\n if (url.origin === origin && path !== '/') paths.add(path)\n } catch {\n // Not an address.\n }\n }\n return [...paths].map((path) => ({ path, id: `p${path.replace(/[^a-z0-9]+/gi, '-')}` }))\n}\n\n/** A recorded page as a wave's read keeps it and the import step hands it on: its blocks, its layout, its photos in the library. */\nexport function siteImportReplayDocument(name: SiteLayoutPageName): AiSiteImportDocument {\n const { url } = SITE_LAYOUT_PAGES[name]\n const page = extractSiteImportPage(siteLayoutRecording(name), url, siteLayoutSameSite(name), { structure: true })\n const layout = siteImportLayout(page as Parameters<typeof siteImportLayout>[0])\n const path = new URL(url).pathname\n const read = siteImportPageRead({ ...page, layout, url, path, foundBy: path === '/' ? 'home' : 'sitemap', bytes: 0 } as never, 'now')\n const blocks = read.blocks ?? []\n const origin = new URL(url).origin\n const pictures = [...new Set(blocks.flatMap((block) => (block.kind === 'image' ? [block.url] : [])))]\n return {\n build: 'arranged',\n title: read.title,\n url,\n blocks,\n photos: pictures.map((from, index) => ({ mediaId: `m${index}`, src: `media:host-import/m${index}`, from, width: 1600, height: 900 })),\n links: plannedLinks(blocks, origin),\n origins: [origin, origin.replace('://', '://www.')],\n ...(read.layout ? { layout: read.layout } : {}),\n ...(read.videos?.length ? { videos: read.videos } : {}),\n }\n}\n\n/** A recorded page built as the page step builds it: its source, its stored nodes, and what the page check said. */\nexport interface SiteImportReplayPage {\n doc: AiSiteImportDocument\n source: SiteImportFidelitySource\n tree: SiteImportFidelityTree\n violations: unknown[]\n}\n\n/**\n * A recorded page built and checked as the page step stores it (AGL-4109):\n * with a recorded design `answer`, as a main page is arranged, or with none,\n * as a page is drawn from its layout alone; `forms` are the site's saved\n * forms. `layout: false` builds it as a read with no layout was built, one\n * section at each second-level heading, as the 10/29 import did.\n */\nexport function siteImportReplayPage(\n name: SiteLayoutPageName,\n options: { answer?: Record<string, unknown> | null; forms?: Array<{ id: string; name: string }>; layout?: boolean } = {},\n): SiteImportReplayPage {\n const read = siteImportReplayDocument(name)\n const { layout, ...rest } = read\n const doc: AiSiteImportDocument = options.layout === false ? rest : read\n const names = aiSiteImportSectionNames(doc)\n const sectionIds = names.map((_, index) => `sec-${index}`)\n const screen = { title: doc.title, slug: name === 'home' ? '/' : `/${name}`, sections: names.map((section) => ({ name: section, uses: [] as string[], items: 0 })) }\n const forms = options.forms ?? []\n const targets = { pageId: 'p0', pages: [], homeIds: [], forms, formPageId: null, components: [], facts: '' }\n const check = aiImportedPageCheck({\n screen: screen as never,\n sectionIds,\n targets: targets as never,\n context: { screenIds: doc.links.map((link) => link.id), formIds: forms.map((form) => form.id), componentIds: [], codeBuilt: true },\n design: { kind: 'business', seed: 7, home: name === 'home' } as never,\n doc,\n })\n const result = check(options.answer ?? null)\n const nodes = (result.value?.nodes ?? {}) as unknown as SiteImportFidelityTree['nodes']\n return {\n doc,\n source: { layout: layout as NonNullable<typeof layout>, blocks: read.blocks, photos: read.photos },\n tree: { rootId: '_@_', nodes },\n violations: result.violations,\n }\n}\n\n/**\n * The design answer recorded for aglyn.com's Home, in the tool's shape: a\n * split hero, ruled cards, a dark band asked where the source drew its own\n * white, a style of pictures for a group that has none. The compile spec\n * holds the same one.\n */\nexport const SITE_IMPORT_REPLAY_HOME_ANSWER: Readonly<Record<string, unknown>> = {\n sections: [\n { hero: 'split', band: 'source', align: 'start', groups: [] },\n { hero: 'none', band: 'source', align: 'source', groups: [{ kind: 'source', style: 'ruled' }] },\n { hero: 'none', band: 'dark', align: 'source', groups: [] },\n { hero: 'none', band: 'source', align: 'source', groups: [{ kind: 'source', style: 'pictures' }] },\n ],\n}\n\n/** The recorded home pages a header and footer is drawn from. */\nexport type SiteImportReplayHome = Extract<SiteLayoutPageName, 'home' | 'pottery'>\n\nconst NOW = new Date('2026-10-29T18:00:00.000Z')\n\n/** A recorded home page as the crawl keeps it: its menu, footer and look read as the source builds them. */\nfunction crawledHome(name: SiteImportReplayHome): SiteImportInventory['pages'][number] {\n const { url } = SITE_LAYOUT_PAGES[name]\n const extract = extractSiteImportPage(siteLayoutRecording(name), url, siteLayoutSameSite(name), { structure: true })\n const source = extract as SiteImportFrameSource\n const { structure: _structure, loginForm: _loginForm, ...rest } = extract\n return { ...rest, url, path: '/', foundBy: 'home', bytes: 0, nav: siteImportNavTree(source), footer: siteImportFooterColumns(source), look: siteImportLookOf(source) }\n}\n\n/** A site planned for its first wave: Home, and two pages of its own. */\nfunction replayState(name: SiteImportReplayHome): AiSiteImportState {\n const origin = new URL(SITE_LAYOUT_PAGES[name].url).origin\n const paths = name === 'home' ? ['/', '/product', '/pricing'] : ['/', '/classes', '/gallery']\n const home = aiSiteImportHomeOf({ pages: [crawledHome(name)] })\n const pages: AiSiteImportPage[] = paths.map((path, index) => {\n const slug = path === '/' ? '/' : (path.split('/').filter(Boolean).pop() as string)\n return { slot: `p${index}`, url: `${origin}${path}`, path, title: slug, group: 'main', wave: 1, draftId: `draft${index}`, slug, words: 300, images: 0 }\n })\n return {\n domain: new URL(origin).hostname.replace(/^www\\./, ''),\n siteName: 'import-check',\n ownership: { method: 'dns', provenAt: 1, detail: null },\n readAt: NOW.toISOString(),\n pageLimit: null,\n existingPages: 0,\n found: pages.length,\n stoppedBy: null,\n groups: [],\n pages,\n waves: [{ index: 1, label: 'Wave 1', group: 'main', slots: pages.map((page) => page.slot), frame: true, status: 'running', startedAt: NOW.toISOString(), finishedAt: null }],\n leftOut: [],\n leftOutCount: {},\n frame: { draftId: 'frameDraft' },\n home,\n look: {\n at: NOW.toISOString(),\n theme: 'applied',\n colors: [],\n logo: name === 'home' ? { mediaId: 'm1', src: 'media:host-import/m1', width: 632, height: 192 } : null,\n // The menus' pictures, in the library as the look pass brings them in (AGL-4139).\n pictures: siteImportMenuPictures(home).map((from, index) => ({ mediaId: `mp${index}`, src: `media:host-import/mp${index}`, from, width: 1200, height: 750 })),\n seo: true,\n seed: 7,\n },\n }\n}\n\n/** The pictures a home page's menus show, each once: what the look pass brings in. */\nfunction siteImportMenuPictures(home: AiSiteImportState['home']): string[] {\n const urls = (home?.nav?.items ?? []).flatMap((group) => (group.columns ?? []).flatMap((column) => (column.image ? [column.image.url] : [])))\n return [...new Set(urls)]\n}\n\n/** A recorded home page's header and footer as the frame step draws them: the source's menu and footer, the stored nodes, the check's word. */\nexport interface SiteImportReplayFrame {\n nav: SiteImportNavTree | null\n footer: SiteImportFooter | null\n tree: SiteImportFidelityTree\n violations: unknown[]\n}\n\n/** A recorded home page's header and footer, drawn with no model as the layout step stores them (AGL-4108). */\nexport function siteImportReplayFrame(name: SiteImportReplayHome): SiteImportReplayFrame {\n const state = replayState(name)\n const job = {\n $id: 'importJob',\n orgId: 'org-replay',\n hostId: 'host-replay',\n kind: 'import',\n status: 'running',\n brief: `Bring in ${state.domain}`,\n inputs: { domain: state.domain },\n steps: [],\n outputs: [],\n createdBy: 'uid-replay',\n createdAt: NOW,\n updatedAt: NOW,\n expiresAt: NOW,\n } as unknown as AiJob\n const frameJob = aiSiteImportFrameJob(job, state, state.waves[0] as AiSiteImportState['waves'][number], aiSiteImportLedger(state))\n const home = state.pages[0] as AiSiteImportPage\n const built = aiLayoutSourceFrameBuild({\n siteName: String(frameJob.inputs?.['businessName']),\n homeId: home.draftId,\n pages: [{ id: home.draftId, label: 'Home', slug: '/' }],\n targets: { pageId: null, pages: [], homeIds: [home.draftId], forms: [], formPageId: null, components: [], facts: '' } as never,\n extend: aiLayoutChecks(emptyAiSiteInventory('host-replay'), frameJob.plan ?? null, [frameJob.brief, ...(state.home?.facts.lines ?? [])].join('\\n')),\n brand: aiLayoutSiteBrandOf(frameJob.inputs),\n source: aiLayoutSiteFrameOf(frameJob.inputs) as AiLayoutFrameSource,\n })\n const nodes = (built.value?.nodes ?? {}) as unknown as SiteImportFidelityTree['nodes']\n return { nav: state.home?.nav ?? null, footer: state.home?.footer ?? null, tree: { rootId: '_@_', nodes }, violations: built.violations }\n}\n"],"names":["aiImportedPageCheck","aiSiteImportFrameJob","aiSiteImportHomeOf","aiLayoutSiteBrandOf","aiLayoutSiteFrameOf","aiLayoutSourceFrameBuild","aiLayoutChecks","aiSiteImportSectionNames","aiSiteImportLedger","emptyAiSiteInventory","extractSiteImportPage","siteImportLayout","siteImportLookOf","siteImportFooterColumns","siteImportNavTree","siteImportPageRead","SITE_LAYOUT_PAGES","siteLayoutRecording","siteLayoutSameSite","plannedLinks","blocks","origin","paths","Set","block","kind","url","URL","href","path","pathname","replace","add","map","id","siteImportReplayDocument","name","read","page","structure","layout","foundBy","bytes","pictures","flatMap","build","title","photos","from","index","mediaId","src","width","height","links","origins","videos","length","siteImportReplayPage","options","result","rest","doc","names","sectionIds","_","screen","slug","sections","section","uses","items","forms","targets","pageId","pages","homeIds","formPageId","components","facts","check","context","screenIds","link","formIds","form","componentIds","codeBuilt","design","seed","home","answer","nodes","value","source","tree","rootId","violations","SITE_IMPORT_REPLAY_HOME_ANSWER","hero","band","align","groups","style","NOW","Date","crawledHome","extract","_structure","loginForm","_loginForm","nav","footer","look","replayState","split","filter","Boolean","pop","slot","group","wave","draftId","words","images","domain","hostname","siteName","ownership","method","provenAt","detail","readAt","toISOString","pageLimit","existingPages","found","stoppedBy","waves","label","slots","frame","status","startedAt","finishedAt","leftOut","leftOutCount","at","theme","colors","logo","siteImportMenuPictures","seo","urls","columns","column","image","siteImportReplayFrame","frameJob","state","built","job","$id","orgId","hostId","brief","inputs","steps","outputs","createdBy","createdAt","updatedAt","expiresAt","String","homeId","extend","plan","lines","join","brand"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;CASC,GAED,SAASA,mBAAmB,QAAQ,qCAAiC;AACrE,SAASC,oBAAoB,EAAEC,kBAAkB,QAAQ,mCAA+B;AACxF,SAASC,mBAAmB,EAAEC,mBAAmB,EAAEC,wBAAwB,QAAQ,uCAAmC;AACtH,SAASC,cAAc,QAAQ,mCAA+B;AAC9D,SAASC,wBAAwB,QAAQ,uCAAmC;AAI5E,SAASC,kBAAkB,QAAsG,gCAA4B;AAE7J,SAASC,oBAAoB,QAAQ,mCAA+B;AAEpE,SAASC,qBAAqB,QAA8B,yBAAqB;AACjF,SAASC,gBAAgB,EAAEC,gBAAgB,QAAQ,2BAAuB;AAC1E,SAASC,uBAAuB,EAAEC,iBAAiB,QAAoC,wBAAoB;AAC3G,SAASC,kBAAkB,QAAQ,yBAAqB;AACxD,SAASC,iBAAiB,EAAEC,mBAAmB,EAAEC,kBAAkB,QAAiC,8BAA0B;AAE9H,+FAA+F,GAC/F,SAASC,aAAaC,MAAkC,EAAEC,MAAc;IACtE,MAAMC,QAAQ,IAAIC;IAClB,KAAK,MAAMC,SAASJ,OAAQ;QAC1B,IAAII,MAAMC,IAAI,KAAK,QAAQ;QAC3B,IAAI;YACF,MAAMC,MAAM,IAAIC,IAAIH,MAAMI,IAAI;YAC9B,MAAMC,OAAOH,IAAII,QAAQ,CAACC,OAAO,CAAC,QAAQ,OAAO;YACjD,IAAIL,IAAIL,MAAM,KA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A,MAAMrE,IAAI,qBAAVqE,aAAYhD,GAAG,oBAAI;QAAMC,MAAM,YAAE+C,eAAAA,MAAMrE,IAAI,qBAAVqE,aAAY/C,MAAM,oBAAI;QAAMjB,MAAM;YAAEC,QAAQ;YAAOJ;QAAM;QAAGK,YAAY+D,MAAM/D,UAAU;IAAC;AAC1I"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/plugins/ai/src/lib/site-import/fixtures/site-import-fidelity-replay.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\n/**\n * The recorded pages brought in again, offline (AGL-4109), for the fidelity\n * spec and the fidelity report: each page of `site-layout/` read by the\n * reader, built by the import's compile and held to its page check as the\n * page step stores it, and each recorded home page's header and footer drawn\n * as the frame step draws them, with no model. Every page the source links\n * on its own site is a page the import plans, as on a whole-site import. No\n * live AI: a design answer here is a recorded one, in the shape the tool\n * answers.\n */\n\nimport { aiImportedPageCheck } from '../../jobs/ai-job-page-language'\nimport { aiSiteImportFrameJob, aiSiteImportHomeOf } from '../../jobs/ai-job-import-step'\nimport { aiLayoutSiteBrandOf, aiLayoutSiteFrameOf, aiLayoutSourceFrameBuild } from '../../jobs/ai-job-layout-language'\nimport { aiLayoutChecks } from '../../jobs/ai-job-layout-step'\nimport { aiSiteImportSectionNames } from '../../jobs/ai-site-import-compile'\nimport { AI_LAYOUT_IMPORTED_SECTIONS_INPUT, aiSiteImportDocumentOf, type AiSiteImportDocument } from '../../jobs/ai-site-import-document'\nimport type { AiLayoutFrameSource } from '../../layout-language/ai-layout-frame-source'\nimport type { AiJob } from '../../model/ai-jobs.types'\nimport { aiSiteImportLedger, type AiSiteImportPage, type AiSiteImportState, type SiteImportFooter, type SiteImportNavTree } from '../../model/ai-site-import'\nimport type { SiteImportFidelitySource, SiteImportFidelityTree } from '../../model/ai-site-import-fidelity'\nimport { emptyAiSiteInventory } from '../../model/ai-site-inventory'\nimport type { SiteImportInventory } from '../site-import-crawl'\nimport { extractSiteImportPage, type SiteImportBlock } from '../site-import-html'\nimport { siteImportLayout, siteImportLookOf } from '../site-import-layout'\nimport { siteImportFooterColumns, siteImportNavTree, type SiteImportFrameSource } from '../site-import-nav'\nimport { siteImportPageRead } from '../site-import-page'\nimport { SITE_LAYOUT_PAGES, siteLayoutRecording, siteLayoutSameSite, type SiteLayoutPageName } from './site-layout-recordings'\n\n/** The page's same-site addresses, each a page the import plans: every page a link may go to. */\nfunction plannedLinks(blocks: readonly SiteImportBlock[], origin: string): Array<{ path: string; id: string }> {\n const paths = new Set<string>()\n for (const block of blocks) {\n if (block.kind !== 'link') continue\n try {\n const url = new URL(block.href)\n const path = url.pathname.replace(/\\/+$/, '') || '/'\n if (url.origin === origin && path !== '/') paths.add(path)\n } catch {\n // Not an address.\n }\n }\n return [...paths].map((path) => ({ path, id: `p${path.replace(/[^a-z0-9]+/gi, '-')}` }))\n}\n\n/** A recorded page as a wave's read keeps it and the import step hands it on: its blocks, its layout, its photos in the library. */\nexport function siteImportReplayDocument(name: SiteLayoutPageName): AiSiteImportDocument {\n const { url } = SITE_LAYOUT_PAGES[name]\n const page = extractSiteImportPage(siteLayoutRecording(name), url, siteLayoutSameSite(name), { structure: true })\n const layout = siteImportLayout(page as Parameters<typeof siteImportLayout>[0])\n const path = new URL(url).pathname\n const read = siteImportPageRead({ ...page, layout, url, path, foundBy: path === '/' ? 'home' : 'sitemap', bytes: 0 } as never, 'now')\n const blocks = read.blocks ?? []\n const origin = new URL(url).origin\n const pictures = [...new Set(blocks.flatMap((block) => (block.kind === 'image' ? [block.url] : [])))]\n return {\n build: 'arranged',\n title: read.title,\n url,\n blocks,\n photos: pictures.map((from, index) => ({ mediaId: `m${index}`, src: `media:host-import/m${index}`, from, width: 1600, height: 900 })),\n links: plannedLinks(blocks, origin),\n origins: [origin, origin.replace('://', '://www.')],\n ...(read.layout ? { layout: read.layout } : {}),\n ...(read.videos?.length ? { videos: read.videos } : {}),\n }\n}\n\n/** A recorded page built as the page step builds it: its source, its stored nodes, and what the page check said. */\nexport interface SiteImportReplayPage {\n doc: AiSiteImportDocument\n source: SiteImportFidelitySource\n tree: SiteImportFidelityTree\n violations: unknown[]\n}\n\n/**\n * A recorded page built and checked as the page step stores it (AGL-4109):\n * with a recorded design `answer`, as a main page is arranged, or with none,\n * as a page is drawn from its layout alone; `forms` are the site's saved\n * forms. `layout: false` builds it as a read with no layout was built, one\n * section at each second-level heading, as the 10/29 import did.\n */\nexport function siteImportReplayPage(\n name: SiteLayoutPageName,\n options: { answer?: Record<string, unknown> | null; forms?: Array<{ id: string; name: string }>; layout?: boolean } = {},\n): SiteImportReplayPage {\n const read = siteImportReplayDocument(name)\n const { layout, ...rest } = read\n // As the page step reads it: through the job's input, so a fact the reader drops is dropped here too (AGL-4138).\n const doc = aiSiteImportDocumentOf({ [AI_LAYOUT_IMPORTED_SECTIONS_INPUT]: JSON.parse(JSON.stringify(options.layout === false ? rest : read)) }) as AiSiteImportDocument\n const names = aiSiteImportSectionNames(doc)\n const sectionIds = names.map((_, index) => `sec-${index}`)\n const screen = { title: doc.title, slug: name === 'home' ? '/' : `/${name}`, sections: names.map((section) => ({ name: section, uses: [] as string[], items: 0 })) }\n const forms = options.forms ?? []\n const targets = { pageId: 'p0', pages: [], homeIds: [], forms, formPageId: null, components: [], facts: '' }\n const check = aiImportedPageCheck({\n screen: screen as never,\n sectionIds,\n targets: targets as never,\n context: { screenIds: doc.links.map((link) => link.id), formIds: forms.map((form) => form.id), componentIds: [], codeBuilt: true },\n design: { kind: 'business', seed: 7, home: name === 'home' } as never,\n doc,\n })\n const result = check(options.answer ?? null)\n const nodes = (result.value?.nodes ?? {}) as unknown as SiteImportFidelityTree['nodes']\n return {\n doc,\n source: { layout: layout as NonNullable<typeof layout>, blocks: read.blocks, photos: read.photos },\n tree: { rootId: '_@_', nodes },\n violations: result.violations,\n }\n}\n\n/**\n * The design answer recorded for aglyn.com's Home, in the tool's shape: a\n * split hero, ruled cards, a dark band asked where the source drew its own\n * white, a style of pictures for a group that has none. The compile spec\n * holds the same one.\n */\nexport const SITE_IMPORT_REPLAY_HOME_ANSWER: Readonly<Record<string, unknown>> = {\n sections: [\n { hero: 'split', band: 'source', align: 'start', groups: [] },\n { hero: 'none', band: 'source', align: 'source', groups: [{ kind: 'source', style: 'ruled' }] },\n { hero: 'none', band: 'dark', align: 'source', groups: [] },\n { hero: 'none', band: 'source', align: 'source', groups: [{ kind: 'source', style: 'pictures' }] },\n ],\n}\n\n/** The recorded home pages a header and footer is drawn from. */\nexport type SiteImportReplayHome = Extract<SiteLayoutPageName, 'home' | 'pottery'>\n\nconst NOW = new Date('2026-10-29T18:00:00.000Z')\n\n/** A recorded home page as the crawl keeps it: its menu, footer and look read as the source builds them. */\nfunction crawledHome(name: SiteImportReplayHome): SiteImportInventory['pages'][number] {\n const { url } = SITE_LAYOUT_PAGES[name]\n const extract = extractSiteImportPage(siteLayoutRecording(name), url, siteLayoutSameSite(name), { structure: true })\n const source = extract as SiteImportFrameSource\n const { structure: _structure, loginForm: _loginForm, ...rest } = extract\n return { ...rest, url, path: '/', foundBy: 'home', bytes: 0, nav: siteImportNavTree(source), footer: siteImportFooterColumns(source), look: siteImportLookOf(source) }\n}\n\n/** A site planned for its first wave: Home, and two pages of its own. */\nfunction replayState(name: SiteImportReplayHome): AiSiteImportState {\n const origin = new URL(SITE_LAYOUT_PAGES[name].url).origin\n const paths = name === 'home' ? ['/', '/product', '/pricing'] : ['/', '/classes', '/gallery']\n const home = aiSiteImportHomeOf({ pages: [crawledHome(name)] })\n const pages: AiSiteImportPage[] = paths.map((path, index) => {\n const slug = path === '/' ? '/' : (path.split('/').filter(Boolean).pop() as string)\n return { slot: `p${index}`, url: `${origin}${path}`, path, title: slug, group: 'main', wave: 1, draftId: `draft${index}`, slug, words: 300, images: 0 }\n })\n return {\n domain: new URL(origin).hostname.replace(/^www\\./, ''),\n siteName: 'import-check',\n ownership: { method: 'dns', provenAt: 1, detail: null },\n readAt: NOW.toISOString(),\n pageLimit: null,\n existingPages: 0,\n found: pages.length,\n stoppedBy: null,\n groups: [],\n pages,\n waves: [{ index: 1, label: 'Wave 1', group: 'main', slots: pages.map((page) => page.slot), frame: true, status: 'running', startedAt: NOW.toISOString(), finishedAt: null }],\n leftOut: [],\n leftOutCount: {},\n frame: { draftId: 'frameDraft' },\n home,\n look: {\n at: NOW.toISOString(),\n theme: 'applied',\n colors: [],\n logo: name === 'home' ? { mediaId: 'm1', src: 'media:host-import/m1', width: 632, height: 192 } : null,\n // The menus' pictures, in the library as the look pass brings them in (AGL-4139).\n pictures: siteImportMenuPictures(home).map((from, index) => ({ mediaId: `mp${index}`, src: `media:host-import/mp${index}`, from, width: 1200, height: 750 })),\n seo: true,\n seed: 7,\n },\n }\n}\n\n/** The pictures a home page's menus show, each once: what the look pass brings in. */\nfunction siteImportMenuPictures(home: AiSiteImportState['home']): string[] {\n const urls = (home?.nav?.items ?? []).flatMap((group) => (group.columns ?? []).flatMap((column) => (column.image ? [column.image.url] : [])))\n return [...new Set(urls)]\n}\n\n/** A recorded home page's header and footer as the frame step draws them: the source's menu and footer, the stored nodes, the check's word. */\nexport interface SiteImportReplayFrame {\n nav: SiteImportNavTree | null\n footer: SiteImportFooter | null\n tree: SiteImportFidelityTree\n violations: unknown[]\n}\n\n/** A recorded home page's header and footer, drawn with no model as the layout step stores them (AGL-4108). */\nexport function siteImportReplayFrame(name: SiteImportReplayHome): SiteImportReplayFrame {\n const state = replayState(name)\n const job = {\n $id: 'importJob',\n orgId: 'org-replay',\n hostId: 'host-replay',\n kind: 'import',\n status: 'running',\n brief: `Bring in ${state.domain}`,\n inputs: { domain: state.domain },\n steps: [],\n outputs: [],\n createdBy: 'uid-replay',\n createdAt: NOW,\n updatedAt: NOW,\n expiresAt: NOW,\n } as unknown as AiJob\n const frameJob = aiSiteImportFrameJob(job, state, state.waves[0] as AiSiteImportState['waves'][number], aiSiteImportLedger(state))\n const home = state.pages[0] as AiSiteImportPage\n const built = aiLayoutSourceFrameBuild({\n siteName: String(frameJob.inputs?.['businessName']),\n homeId: home.draftId,\n pages: [{ id: home.draftId, label: 'Home', slug: '/' }],\n targets: { pageId: null, pages: [], homeIds: [home.draftId], forms: [], formPageId: null, components: [], facts: '' } as never,\n extend: aiLayoutChecks(emptyAiSiteInventory('host-replay'), frameJob.plan ?? null, [frameJob.brief, ...(state.home?.facts.lines ?? [])].join('\\n')),\n brand: aiLayoutSiteBrandOf(frameJob.inputs),\n source: aiLayoutSiteFrameOf(frameJob.inputs) as AiLayoutFrameSource,\n })\n const nodes = (built.value?.nodes ?? {}) as unknown as SiteImportFidelityTree['nodes']\n return { nav: state.home?.nav ?? null, footer: state.home?.footer ?? null, tree: { rootId: '_@_', nodes }, violations: built.violations }\n}\n"],"names":["aiImportedPageCheck","aiSiteImportFrameJob","aiSiteImportHomeOf","aiLayoutSiteBrandOf","aiLayoutSiteFrameOf","aiLayoutSourceFrameBuild","aiLayoutChecks","aiSiteImportSectionNames","AI_LAYOUT_IMPORTED_SECTIONS_INPUT","aiSiteImportDocumentOf","aiSiteImportLedger","emptyAiSiteInventory","extractSiteImportPage","siteImportLayout","siteImportLookOf","siteImportFooterColumns","siteImportNavTree","siteImportPageRead","SITE_LAYOUT_PAGES","siteLayoutRecording","siteLayoutSameSite","plannedLinks","blocks","origin","paths","Set","block","kind","url","URL","href","path","pathname","replace","add","map","id","siteImportReplayDocument","name","read","page","structure","layout","foundBy","bytes","pictures","flatMap","build","title","photos","from","index","mediaId","src","width","height","links","origins","videos","length","siteImportReplayPage","options","result","rest","doc","JSON","parse","stringify","names","sectionIds","_","screen","slug","sections","section","uses","items","forms","targets","pageId","pages","homeIds","formPageId","components","facts","check","context","screenIds","link","formIds","form","componentIds","codeBuilt","design","seed","home","answer","nodes","value","source","tree","rootId","violations","SITE_IMPORT_REPLAY_HOME_ANSWER","hero","band","align","groups","style","NOW","Date","crawledHome","extract","_structure","loginForm","_loginForm","nav","footer","look","replayState","split","filter","Boolean","pop","slot","group","wave","draftId","words","images","domain","hostname","siteName","ownership","method","provenAt","detail","readAt","toISOString","pageLimit","existingPages","found","stoppedBy","waves","label","slots","frame","status","startedAt","finishedAt","leftOut","leftOutCount","at","theme","colors","logo","siteImportMenuPictures","seo","urls","columns","column","image","siteImportReplayFrame","frameJob","state","built","job","$id","orgId","hostId","brief","inputs","steps","outputs","createdBy","createdAt","updatedAt","expiresAt","String","homeId","extend","plan","lines","join","brand"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;CASC,GAED,SAASA,mBAAmB,QAAQ,qCAAiC;AACrE,SAASC,oBAAoB,EAAEC,kBAAkB,QAAQ,mCAA+B;AACxF,SAASC,mBAAmB,EAAEC,mBAAmB,EAAEC,wBAAwB,QAAQ,uCAAmC;AACtH,SAASC,cAAc,QAAQ,mCAA+B;AAC9D,SAASC,wBAAwB,QAAQ,uCAAmC;AAC5E,SAASC,iCAAiC,EAAEC,sBAAsB,QAAmC,wCAAoC;AAGzI,SAASC,kBAAkB,QAAsG,gCAA4B;AAE7J,SAASC,oBAAoB,QAAQ,mCAA+B;AAEpE,SAASC,qBAAqB,QAA8B,yBAAqB;AACjF,SAASC,gBAAgB,EAAEC,gBAAgB,QAAQ,2BAAuB;AAC1E,SAASC,uBAAuB,EAAEC,iBAAiB,QAAoC,wBAAoB;AAC3G,SAASC,kBAAkB,QAAQ,yBAAqB;AACxD,SAASC,iBAAiB,EAAEC,mBAAmB,EAAEC,kBAAkB,QAAiC,8BAA0B;AAE9H,+FAA+F,GAC/F,SAASC,aAAaC,MAAkC,EAAEC,MAAc;IACtE,MAAMC,QAAQ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YAACA,SAASO,KAAK;wBAAMN,cAAAA,MAAMrE,IAAI,qBAAVqE,YAAYhF,KAAK,CAACkG,KAAK,mBAAI,EAAE;SAAE,CAACC,IAAI,CAAC;QAC7IC,OAAOrL,oBAAoBgK,SAASQ,MAAM;QAC1CxE,QAAQ/F,oBAAoB+J,SAASQ,MAAM;IAC7C;IACA,MAAM1E,kBAASoE,eAAAA,MAAMnE,KAAK,qBAAXmE,aAAapE,KAAK,oBAAI,CAAC;IACtC,OAAO;QAAEmB,GAAG,YAAEgD,eAAAA,MAAMrE,IAAI,qBAAVqE,aAAYhD,GAAG,oBAAI;QAAMC,MAAM,YAAE+C,eAAAA,MAAMrE,IAAI,qBAAVqE,aAAY/C,MAAM,oBAAI;QAAMjB,MAAM;YAAEC,QAAQ;YAAOJ;QAAM;QAAGK,YAAY+D,MAAM/D,UAAU;IAAC;AAC1I"}
|
|
@@ -654,7 +654,7 @@ let LayoutReader = class LayoutReader {
|
|
|
654
654
|
// The picture fills its box where it is set to the box's whole height.
|
|
655
655
|
const fills = /^100%$/.test((_ref = (_own_get = own.get('height')) == null ? void 0 : _own_get.trim()) != null ? _ref : '');
|
|
656
656
|
for(let at = element, depth = 0; at >= 0 && depth <= 2; at = (_ref1 = (_this_elements_at = this.elements[at]) == null ? void 0 : _this_elements_at.parent) != null ? _ref1 : -1, depth += 1){
|
|
657
|
-
var _style_get;
|
|
657
|
+
var _style_get, _style_get1;
|
|
658
658
|
if (depth > 0 && this.leaves(at).some((other)=>other.kind === 'line' && other.order !== leaf.order)) break;
|
|
659
659
|
const style = this.style(at);
|
|
660
660
|
const box = siteImportAspectRatio(style.get('aspect-ratio'));
|
|
@@ -664,6 +664,8 @@ let LayoutReader = class LayoutReader {
|
|
|
664
664
|
const radius = siteImportRadiusPx(style);
|
|
665
665
|
if (radius !== null && radius > 0 && fit.radius === undefined) fit.radius = Math.min(radius, 999);
|
|
666
666
|
if (siteImportHasShadow(style)) fit.shadow = true;
|
|
667
|
+
const cap = siteImportLengthPx((_style_get1 = style.get('max-width')) != null ? _style_get1 : '');
|
|
668
|
+
if (cap !== null && cap > 0 && fit.measure === undefined) fit.measure = cap;
|
|
667
669
|
}
|
|
668
670
|
return Object.keys(fit).length ? fit : undefined;
|
|
669
671
|
}
|
|
@@ -1012,6 +1014,8 @@ let LayoutReader = class LayoutReader {
|
|
|
1012
1014
|
const leaves = this.leaves(element).filter((leaf)=>this.inRange(leaf, range));
|
|
1013
1015
|
const lines = leaves.filter((leaf)=>leaf.kind === 'line');
|
|
1014
1016
|
if (lines.length !== 1) return false;
|
|
1017
|
+
// A short line with a mark of its own and no pill around it is a checklist's line, not a tag (AGL-4138).
|
|
1018
|
+
if (leaves.some((leaf)=>leaf.kind === 'icon') && !this.framed(element)) return false;
|
|
1015
1019
|
const block = this.block(lines[0]);
|
|
1016
1020
|
return !!block && block.kind !== 'image' && block.kind !== 'heading' && block.text.length <= 40;
|
|
1017
1021
|
}
|