@aglyn/aglyn 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.
Files changed (51) hide show
  1. package/package.json +11 -11
  2. package/src/lib/app-utils/ai-credit-blocks.d.ts +124 -0
  3. package/src/lib/app-utils/ai-credit-blocks.js +122 -0
  4. package/src/lib/app-utils/ai-credit-blocks.js.map +1 -0
  5. package/src/lib/app-utils/bundle-intent.d.ts +17 -51
  6. package/src/lib/app-utils/bundle-intent.js +30 -74
  7. package/src/lib/app-utils/bundle-intent.js.map +1 -1
  8. package/src/lib/app-utils/contacts.d.ts +4 -1
  9. package/src/lib/app-utils/contacts.js.map +1 -1
  10. package/src/lib/app-utils/docs-help-sections.generated.js +3 -3
  11. package/src/lib/app-utils/docs-help-sections.generated.js.map +1 -1
  12. package/src/lib/app-utils/docs-help.generated.d.ts +1 -1
  13. package/src/lib/app-utils/docs-help.generated.js +1 -1
  14. package/src/lib/app-utils/docs-help.generated.js.map +1 -1
  15. package/src/lib/app-utils/docs-index.generated.js +84 -84
  16. package/src/lib/app-utils/docs-index.generated.js.map +1 -1
  17. package/src/lib/app-utils/margin-utilization.js +6 -5
  18. package/src/lib/app-utils/margin-utilization.js.map +1 -1
  19. package/src/lib/app-utils/onboarding-deep-link.d.ts +10 -11
  20. package/src/lib/app-utils/onboarding-deep-link.js +37 -32
  21. package/src/lib/app-utils/onboarding-deep-link.js.map +1 -1
  22. package/src/lib/app-utils/operator-alerts.js +17 -0
  23. package/src/lib/app-utils/operator-alerts.js.map +1 -1
  24. package/src/lib/app-utils/plan-entitlements.d.ts +142 -150
  25. package/src/lib/app-utils/plan-entitlements.js +202 -201
  26. package/src/lib/app-utils/plan-entitlements.js.map +1 -1
  27. package/src/lib/app-utils/release-flags.d.ts +6 -4
  28. package/src/lib/app-utils/release-flags.js +8 -9
  29. package/src/lib/app-utils/release-flags.js.map +1 -1
  30. package/src/lib/app-utils/server.d.ts +1 -0
  31. package/src/lib/app-utils/server.js +3 -0
  32. package/src/lib/app-utils/server.js.map +1 -1
  33. package/src/lib/app-utils/site-interactions.d.ts +1 -1
  34. package/src/lib/app-utils/site-interactions.js +2 -2
  35. package/src/lib/app-utils/site-interactions.js.map +1 -1
  36. package/src/lib/app-utils/transactional-email-ceiling.d.ts +119 -0
  37. package/src/lib/app-utils/transactional-email-ceiling.js +134 -0
  38. package/src/lib/app-utils/transactional-email-ceiling.js.map +1 -0
  39. package/src/lib/app-utils/upgrade-proposal.d.ts +17 -7
  40. package/src/lib/app-utils/upgrade-proposal.js +20 -13
  41. package/src/lib/app-utils/upgrade-proposal.js.map +1 -1
  42. package/src/lib/foundation/definitions/org-billing.types.d.ts +4 -29
  43. package/src/lib/foundation/definitions/org-billing.types.js.map +1 -1
  44. package/src/lib/foundation/definitions/organization.types.d.ts +1 -3
  45. package/src/lib/foundation/definitions/organization.types.js.map +1 -1
  46. package/src/lib/foundation/index.d.ts +1 -1
  47. package/src/lib/foundation/index.js.map +1 -1
  48. package/src/lib/plugin-manager/first-party-plugins.generated.js +9 -4
  49. package/src/lib/plugin-manager/first-party-plugins.generated.js.map +1 -1
  50. package/src/lib/plugin-manager/plugin-usage-axes.d.ts +14 -0
  51. package/src/lib/plugin-manager/plugin-usage-axes.js.map +1 -1
@@ -16,6 +16,7 @@
16
16
  */ import { _ as _extends } from "@swc/helpers/_/_extends";
17
17
  import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
18
18
  import { isOrgOverrideReasonCode } from "./org-override-reason.js";
19
+ import { AI_CREDIT_BLOCK_MONTHLY_USD, AI_CREDITS_PER_BLOCK, aiCreditBlockCount } from "./ai-credit-blocks.js";
19
20
  import { PLATFORM_BRAND_NAME, PLATFORM_BRANDING_PROFILE } from "./platform-brand.js";
20
21
  import { listPluginFeatures, listPluginSeatAddons, pluginSeatAddon } from "../plugin-manager/plugin-entitlements.js";
21
22
  import { pluginOrgCapacity } from "../plugin-manager/plugin-org-capacity.js";
@@ -399,16 +400,26 @@ export const PLAN_ENTITLEMENTS = {
399
400
  ssoEnabled: false
400
401
  }
401
402
  },
403
+ // Pricing v4 (2026-11-03, AGL-4126): Pro is the full platform, priced by
404
+ // use. Every Business feature moved in, and every count with no cost term
405
+ // (pages, saved forms, variables, functions, workflows, redirects,
406
+ // products, records per dataset) is UNLIMITED, as are the add-on ceilings
407
+ // on seats, collaborators and datasets. What costs money stays banded at
408
+ // Pro's size (sites, storage, bandwidth, seats, collaborators, datasets,
409
+ // data, CRM records, campaign email, runs, API requests, AI credits), and
410
+ // past each band the plan meters rather than refuses. `full-use-cost.ts`
411
+ // prices exactly the banded terms, so the counts lifted here move no cost
412
+ // figure; the API band is the one new cost term.
402
413
  pro: {
403
414
  hostLimit: 3,
404
- screensPerHost: 100,
415
+ screensPerHost: UNLIMITED,
405
416
  sharedLayoutsPerHost: UNLIMITED,
406
417
  templatesPerHost: UNLIMITED,
407
418
  storagePerHostMb: 5120,
408
419
  membersPerHost: 3,
409
420
  managersPerOrg: 3,
410
- maxManagersPerOrg: 20,
411
- maxMembersPerHost: 25,
421
+ maxManagersPerOrg: UNLIMITED,
422
+ maxMembersPerHost: UNLIMITED,
412
423
  // Page views are the largest term of this tier's modeled COGS. One GB is
413
424
  // 1,035 views at `ESTIMATED_PAGE_TRANSFER_BYTES`, priced where Vercel is
414
425
  // dearest because it bills in the region that serves a visitor: $0.413 of
@@ -419,8 +430,8 @@ export const PLAN_ENTITLEMENTS = {
419
430
  // bandwidth costs $0.637, and the bandwidth band is what decides whether
420
431
  // the tier survives a customer spending the whole allowance it was sold.
421
432
  //
422
- // The invariant the band is sized against is the ANNUAL price ($39 a
423
- // month) net of Stripe's fee, with every band at 100% and the CRM seat
433
+ // The invariant the band is sized against is the ANNUAL price ($49 a
434
+ // month since v4, $39 when the band was sized) net of Stripe's fee, with every band at 100% and the CRM seat
424
435
  // and one-to-one email terms counted — the 2026-09-07 pricing decision —
425
436
  // at that all-in gigabyte (AGL-3444), and it must cover that cost plus
426
437
  // 30%, the same markup the metered overages carry (AGL-3469). 25 GB is
@@ -431,30 +442,43 @@ export const PLAN_ENTITLEMENTS = {
431
442
  // `meteredInfraPassThrough` is true here, so traffic past the band BILLS
432
443
  // at the page-view pass-through rather than being refused or absorbed.
433
444
  bandwidthGb: 25,
434
- formsPerHost: 25,
445
+ formsPerHost: UNLIMITED,
435
446
  componentsPerHost: UNLIMITED,
436
- variablesPerHost: 100,
437
- functionsPerHost: 50,
438
- workflowsPerHost: 25,
447
+ variablesPerHost: UNLIMITED,
448
+ functionsPerHost: UNLIMITED,
449
+ workflowsPerHost: UNLIMITED,
439
450
  servicesPerHost: UNLIMITED,
440
- redirectsPerHost: 100,
451
+ redirectsPerHost: UNLIMITED,
441
452
  contactsPerHost: 10000,
442
453
  emailSendsPerMonth: 2500,
443
454
  actionRunsPerMonth: 5000,
444
- apiRequestsPerMonth: 0,
455
+ // API access moved in from Business with Business's band (v4), and the
456
+ // excess meters at Business's rate rather than refusing mid-integration.
457
+ apiRequestsPerMonth: 1500,
445
458
  datasetsPerOrg: 5,
446
- maxDatasetsPerOrg: 50,
447
- recordsPerDataset: 10000,
459
+ maxDatasetsPerOrg: UNLIMITED,
460
+ recordsPerDataset: UNLIMITED,
448
461
  dataStorageMbPerOrg: 2048,
449
- productsPerHost: 2500,
462
+ productsPerHost: UNLIMITED,
450
463
  inventoryLocations: 2,
451
464
  posRegisters: 1,
452
- transactionFeePhysicalPct: 0,
453
- // Pricing v3 (2026-07): softened 5→3 to smooth the digital fee ladder
454
- // (Starter 5 → Pro 3 → Business 2 → Scale 1 → Advanced/Agency 0).
465
+ // 0.5% on physical sales (v4, decision 9): Stripe Connect's account and
466
+ // payout fees ($2 a month per active account, 0.25% + $0.25 a payout) are
467
+ // paid by the platform, and at 0% a register doing $10k a month cost
468
+ // about $32 against Pro's margin. Fractional on purpose: every reader
469
+ // rounds the fee in cents (`resolveTransactionFeeCents`, the cart, the
470
+ // register) and prints the rate as it stands, so 0.5 reads "0.5%".
471
+ transactionFeePhysicalPct: 0.5,
472
+ // Pricing v3 (2026-07): softened 5→3 to smooth the digital fee ladder.
473
+ // v4 keeps it: the fee is the usage price of memberships, subscriptions,
474
+ // gift cards and digital goods, the features that moved into Pro.
455
475
  transactionFeeDigitalPct: 3,
476
+ // Every Business feature, at no charge (v4): A/B tests, scheduled
477
+ // publishing, webhooks, the API, multilingual sites and members-only
478
+ // content here; recurring billing, paid memberships and gift cards in the
479
+ // commerce plugin's declaration; the deep model tier in the AI plugin's.
456
480
  features: {
457
- abTesting: false,
481
+ abTesting: true,
458
482
  versioning: true,
459
483
  reusableComponents: true,
460
484
  customDomain: true,
@@ -482,7 +506,7 @@ export const PLAN_ENTITLEMENTS = {
482
506
  // request is filled.
483
507
  dedicatedSendingDomain: true,
484
508
  removeBranding: true,
485
- scheduledPublishing: false,
509
+ scheduledPublishing: true,
486
510
  aiAssist: true,
487
511
  aiGenerative: true,
488
512
  workflows: true,
@@ -493,10 +517,10 @@ export const PLAN_ENTITLEMENTS = {
493
517
  outreach: false,
494
518
  interactions: true,
495
519
  actions: true,
496
- webhooks: false,
497
- apiAccess: false,
520
+ webhooks: true,
521
+ apiAccess: true,
498
522
  siteExport: true,
499
- multilingual: false,
523
+ multilingual: true,
500
524
  eventCalendar: false,
501
525
  siteCare: false,
502
526
  redirects: true,
@@ -505,7 +529,7 @@ export const PLAN_ENTITLEMENTS = {
505
529
  marketingOverlays: true,
506
530
  commerce: true,
507
531
  pos: true,
508
- contentGating: false,
532
+ contentGating: true,
509
533
  productReviews: true,
510
534
  abandonedCart: true,
511
535
  dropshipRouting: true,
@@ -952,15 +976,42 @@ fillPluginPlanEntitlements(PLAN_ENTITLEMENTS);
952
976
  * marketing pricing table, the plan-change dialog) MUST iterate this rather
953
977
  * than `Object.keys(PLAN_ENTITLEMENTS)`, so a custom-priced tier can never
954
978
  * show a self-serve Upgrade button or a $0 headline price.
979
+ *
980
+ * Pricing v4 (2026-11-03, AGL-4126): three self-serve plans and Custom above
981
+ * them. Business, Scale, Advanced and Agency are RETIRED_PLANS: never sold
982
+ * again, their rows kept so a stored `plan`, a comp and an old record still
983
+ * resolve and type-check.
955
984
  */ export const SELF_SERVE_PLANS = [
956
985
  'free',
957
986
  'starter',
958
- 'pro',
987
+ 'pro'
988
+ ];
989
+ /**
990
+ * The plans pricing v4 retired (2026-11-03, AGL-4126). Nothing offers them:
991
+ * no plan card, no checkout price, no comp picker, no sign-up link. Their
992
+ * `PLAN_ENTITLEMENTS` and `PLAN_PRICING` rows stay, read-only, so an org whose
993
+ * stored `plan` still names one resolves exactly as it always did. When v4
994
+ * shipped no subscription was on any of them.
995
+ */ export const RETIRED_PLANS = [
959
996
  'business',
960
997
  'scale',
961
998
  'advanced',
962
999
  'agency'
963
1000
  ];
1001
+ /**
1002
+ * Every plan a workspace can be ON, cheapest first: the self-serve ladder,
1003
+ * the retired plans in their old place above it, then the custom plan. The
1004
+ * ORDER question ("is this move down?", "what is the plan below this one?")
1005
+ * reads this, so a workspace left on a retired plan is still placed on the
1006
+ * ladder; the SALE question ("what may be bought?") reads `SELF_SERVE_PLANS`.
1007
+ */ export const PLAN_LADDER = [
1008
+ ...SELF_SERVE_PLANS,
1009
+ ...RETIRED_PLANS,
1010
+ 'enterprise'
1011
+ ];
1012
+ /** Whether a plan is one pricing v4 retired (`RETIRED_PLANS`). */ export function isRetiredPlan(plan) {
1013
+ return RETIRED_PLANS.includes(plan);
1014
+ }
964
1015
  /**
965
1016
  * Whether the plan has no list price and is quoted per deal (AGL-1118).
966
1017
  * `PLAN_PRICING` still carries a row for it — the record is exhaustive by
@@ -988,7 +1039,9 @@ fillPluginPlanEntitlements(PLAN_ENTITLEMENTS);
988
1039
  scale: 'Scale',
989
1040
  advanced: 'Advanced',
990
1041
  agency: 'Agency',
991
- enterprise: 'Enterprise'
1042
+ // The top plan reads "Custom" since pricing v4 (2026-11-03, AGL-4126); its
1043
+ // code id stays `enterprise`, and `ENTERPRISE_PLAN_LABEL` reads this.
1044
+ enterprise: 'Custom'
992
1045
  };
993
1046
  /**
994
1047
  * Event Calendar add-on (AGL-145): first-party, Aglyn-supported, $9/mo
@@ -1053,113 +1106,12 @@ fillPluginPlanEntitlements(PLAN_ENTITLEMENTS);
1053
1106
  * `posRegisters` entitlement override, which
1054
1107
  * `resolveOrgEntitlements` already applies over the plan default.
1055
1108
  */ export const POS_REGISTER_ADDON_MONTHLY_USD = 89;
1056
- /** The tiers, smallest first — the order every picker lists them in. */ export const AI_TIER_IDS = [
1057
- 'spark',
1058
- 'boost',
1059
- 'plus',
1060
- 'max',
1061
- 'ultra',
1062
- 'studio'
1063
- ];
1064
- export const AI_TIERS = {
1065
- spark: {
1066
- label: 'Spark',
1067
- monthlyUsd: 9,
1068
- yearlyUsd: 108,
1069
- credits: 4000
1070
- },
1071
- boost: {
1072
- label: 'Boost',
1073
- monthlyUsd: 19,
1074
- yearlyUsd: 228,
1075
- credits: 9000
1076
- },
1077
- plus: {
1078
- label: 'Plus',
1079
- monthlyUsd: 39,
1080
- yearlyUsd: 468,
1081
- credits: 19000
1082
- },
1083
- max: {
1084
- label: 'Max',
1085
- monthlyUsd: 69,
1086
- yearlyUsd: 828,
1087
- credits: 34000
1088
- },
1089
- ultra: {
1090
- label: 'Ultra',
1091
- monthlyUsd: 99,
1092
- yearlyUsd: 1188,
1093
- credits: 49000
1094
- },
1095
- studio: {
1096
- label: 'Studio',
1097
- monthlyUsd: 299,
1098
- yearlyUsd: 3588,
1099
- credits: 149000
1100
- }
1101
- };
1102
- /**
1103
- * The tier an add-on bought before AGL-3965 is (AGL-3965): the one with the
1104
- * same price and the same band the plan sold it at, so a workspace that
1105
- * held "the Pro add-on" holds Boost — $19, 9,000 credits — and neither its
1106
- * bill nor its credits move. Read when `aiTier` is absent and to classify a
1107
- * per-plan `STRIPE_PRICE_{PLAN}_AI_ADDON` item still on a subscription.
1108
- */ export const LEGACY_AI_ADDON_TIER_BY_PLAN = {
1109
- starter: 'spark',
1110
- pro: 'boost',
1111
- business: 'plus',
1112
- scale: 'max',
1113
- advanced: 'ultra',
1114
- agency: 'studio'
1115
- };
1116
- /**
1117
- * The tier a purchase that names a plan and no tier means (AGL-3965): a
1118
- * `?plan=pro&ai=1` deep link, a checkout posting `aiAddon: true` alone. The
1119
- * tier with that plan's old price and band, so a link published before tiers
1120
- * existed still sells what it quoted. Null where the plan sells no tier.
1121
- */ export function defaultAiTierForPlan(plan) {
1122
- var _LEGACY_AI_ADDON_TIER_BY_PLAN_plan;
1123
- if (!planSellsAiTiers(plan)) return null;
1124
- return (_LEGACY_AI_ADDON_TIER_BY_PLAN_plan = LEGACY_AI_ADDON_TIER_BY_PLAN[plan]) != null ? _LEGACY_AI_ADDON_TIER_BY_PLAN_plan : null;
1125
- }
1126
- /** Whether a value is one of the tier ids. */ export function isAiTierId(value) {
1127
- return typeof value === 'string' && AI_TIER_IDS.includes(value);
1128
- }
1129
- /** `ai:<tier>` for a tier. */ export function aiTierAddonKey(tier) {
1130
- return `ai:${tier}`;
1131
- }
1132
1109
  /**
1133
- * The tier an `ai:<tier>` key names, or null for anything else — another
1134
- * add-on's key, a bare `ai`, an unknown tier, a non-string. Exact and
1135
- * case-sensitive: a key is read off a link, and guessing is the expensive
1136
- * direction to be wrong in (`parseOnboardingPlanIntent` reads `?ai=` the
1137
- * same way).
1138
- */ export function parseAiTierAddonKey(key) {
1139
- if (typeof key !== 'string' || !key.startsWith('ai:')) return null;
1140
- const tier = key.slice(3);
1141
- return isAiTierId(tier) ? tier : null;
1142
- }
1143
- /**
1144
- * Every tier as an `ai:<tier>` add-on, smallest first — what a picker that
1145
- * offers "Aglyn AI" beside the other add-ons lists. Empty for a plan that
1146
- * sells no tier (Free, Enterprise) when a plan is given.
1147
- */ export function listAiTierAddons(plan) {
1148
- if (plan !== undefined && !planSellsAiTiers(plan)) return [];
1149
- return AI_TIER_IDS.map((tier)=>({
1150
- key: aiTierAddonKey(tier),
1151
- tier,
1152
- label: AI_TIERS[tier].label,
1153
- monthlyUsd: AI_TIERS[tier].monthlyUsd,
1154
- yearlyUsd: AI_TIERS[tier].yearlyUsd,
1155
- credits: AI_TIERS[tier].credits
1156
- }));
1157
- }
1158
- /**
1159
- * Whether a plan may buy an Aglyn AI tier (AGL-3965): every paid self-serve
1160
- * plan. Not Free, which has no subscription to carry it, and not Enterprise,
1161
- * whose AI is in the agreement.
1162
- */ export function planSellsAiTiers(plan) {
1110
+ * Whether a plan sells Aglyn AI credit blocks (AGL-4144): every paid
1111
+ * self-serve plan. Not Free, which has no subscription to carry them, and
1112
+ * not Enterprise, whose AI is in the agreement. The block itself — 5,000
1113
+ * credits for $10 a month, up to 30 — is `ai-credit-blocks.ts`.
1114
+ */ export function planSellsAiCredits(plan) {
1163
1115
  return planSellsSiteCare(plan);
1164
1116
  }
1165
1117
  /**
@@ -1193,6 +1145,14 @@ export const AI_TIERS = {
1193
1145
  * band (`registers-card.component.tsx` still windows at 25; AGL-1738).
1194
1146
  */ export const EXTRA_HOSTS_ADDON_MAX = 100;
1195
1147
  /** @see EXTRA_HOSTS_ADDON_MAX — the flat register ceiling, per org. */ export const POS_REGISTERS_ADDON_MAX = 50;
1148
+ /**
1149
+ * The run overage, per 1,000 workflow or action runs past the bands (pricing
1150
+ * v4, 2026-11-03, AGL-4126): `ORG_COGS_UNIT_RATES_USD.perRun` × 1,000 ×
1151
+ * `METERED_PRICE_MULTIPLE`, rounded up to the cent — $0.013 × 1.3388 is
1152
+ * $0.0174, published as $0.02. A literal because the cost table and the
1153
+ * multiple are declared below `PLAN_PRICING`, which reads this at load;
1154
+ * `tier-margin-floor.spec.ts` derives it from them and pins it.
1155
+ */ export const RUN_OVERAGE_USD_PER_1K = 0.02;
1196
1156
  /**
1197
1157
  * Flat subscription pricing per tier (AGL-68). Kept beside the entitlements
1198
1158
  * so price changes ride the same review path; Stripe price ids map to plans
@@ -1210,6 +1170,7 @@ export const AI_TIERS = {
1210
1170
  extraAssistCreditsUsdPer1k: null,
1211
1171
  extraContactsUsdPer1k: null,
1212
1172
  extraEmailSendsUsdPer1k: null,
1173
+ extraRunsUsdPer1k: null,
1213
1174
  meteredInfraPassThrough: false
1214
1175
  },
1215
1176
  starter: {
@@ -1234,20 +1195,28 @@ export const AI_TIERS = {
1234
1195
  // so a rate here would price volume that can never be computed, which is
1235
1196
  // the same defect as a rate beside an UNLIMITED band.
1236
1197
  extraEmailSendsUsdPer1k: null,
1198
+ // Starter keeps every wall (v4): its run bands stop rather than bill.
1199
+ extraRunsUsdPer1k: null,
1237
1200
  meteredInfraPassThrough: true
1238
1201
  },
1202
+ // Pricing v4 (2026-11-03, AGL-4126): $49 a month billed yearly ($588 a
1203
+ // year), $69 month to month, from $39/$56, for the full platform. Live
1204
+ // Stripe prices `aglyn_pro_v4` and `aglyn_pro_v4_yearly`; the v2 prices
1205
+ // stay in Stripe as history.
1239
1206
  pro: {
1240
- basePriceMonthlyUsd: 56,
1241
- basePriceAnnualMonthlyUsd: 39,
1207
+ basePriceMonthlyUsd: 69,
1208
+ basePriceAnnualMonthlyUsd: 49,
1242
1209
  extraHostMonthlyUsd: 20,
1243
1210
  extraSeatMonthlyUsd: 4,
1244
1211
  extraCollaboratorMonthlyUsd: 2,
1245
1212
  extraDatasetMonthlyUsd: 2,
1246
1213
  extraDataGbMonthlyUsd: 0.36,
1247
- extraApiRequestsUsdPer1k: null,
1214
+ // Business's rate, with the band and the API that moved in from it (v4).
1215
+ extraApiRequestsUsdPer1k: 0.5,
1248
1216
  extraAssistCreditsUsdPer1k: 3,
1249
1217
  extraContactsUsdPer1k: 0.75,
1250
1218
  extraEmailSendsUsdPer1k: 2.25,
1219
+ extraRunsUsdPer1k: RUN_OVERAGE_USD_PER_1K,
1251
1220
  meteredInfraPassThrough: true
1252
1221
  },
1253
1222
  business: {
@@ -1262,6 +1231,9 @@ export const AI_TIERS = {
1262
1231
  extraAssistCreditsUsdPer1k: 2.75,
1263
1232
  extraContactsUsdPer1k: 0.5,
1264
1233
  extraEmailSendsUsdPer1k: 2,
1234
+ // A runs band and the pass-through: the rate every such plan carries
1235
+ // since v4. Retired with the plan; kept so the row reads whole.
1236
+ extraRunsUsdPer1k: RUN_OVERAGE_USD_PER_1K,
1265
1237
  meteredInfraPassThrough: true
1266
1238
  },
1267
1239
  scale: {
@@ -1276,6 +1248,7 @@ export const AI_TIERS = {
1276
1248
  extraAssistCreditsUsdPer1k: 2.5,
1277
1249
  extraContactsUsdPer1k: 0.4,
1278
1250
  extraEmailSendsUsdPer1k: 1.9,
1251
+ extraRunsUsdPer1k: RUN_OVERAGE_USD_PER_1K,
1279
1252
  meteredInfraPassThrough: true
1280
1253
  },
1281
1254
  advanced: {
@@ -1298,6 +1271,7 @@ export const AI_TIERS = {
1298
1271
  // infrastructure pass-through earns while being sold as cost recovery.
1299
1272
  extraContactsUsdPer1k: 0.4,
1300
1273
  extraEmailSendsUsdPer1k: 1.85,
1274
+ extraRunsUsdPer1k: RUN_OVERAGE_USD_PER_1K,
1301
1275
  meteredInfraPassThrough: true
1302
1276
  },
1303
1277
  // Agency is the one tier whose PRICE moved. It included 100 hosts, 20 TB of
@@ -1346,6 +1320,7 @@ export const AI_TIERS = {
1346
1320
  // sentinel.
1347
1321
  extraContactsUsdPer1k: 0.4,
1348
1322
  extraEmailSendsUsdPer1k: 1.8,
1323
+ extraRunsUsdPer1k: RUN_OVERAGE_USD_PER_1K,
1349
1324
  meteredInfraPassThrough: true
1350
1325
  },
1351
1326
  // Enterprise (AGL-1118) has NO list price — every figure here is the
@@ -1368,6 +1343,7 @@ export const AI_TIERS = {
1368
1343
  extraAssistCreditsUsdPer1k: null,
1369
1344
  extraContactsUsdPer1k: null,
1370
1345
  extraEmailSendsUsdPer1k: null,
1346
+ extraRunsUsdPer1k: null,
1371
1347
  meteredInfraPassThrough: false
1372
1348
  }
1373
1349
  };
@@ -1713,22 +1689,15 @@ function trimmedOrNull(value) {
1713
1689
  const annual = (org == null ? void 0 : (_org_subscription1 = org.subscription) == null ? void 0 : _org_subscription1.interval) === 'year';
1714
1690
  const addons = (_ref = org == null ? void 0 : org.seatAddons) != null ? _ref : {};
1715
1691
  const seats = (quantity, price)=>Math.max(0, quantity != null ? quantity : 0) * (price != null ? price : 0);
1716
- return (annual ? pricing.basePriceAnnualMonthlyUsd : pricing.basePriceMonthlyUsd) + seats(addons.managers, pricing.extraSeatMonthlyUsd) + seats(addons.members, pricing.extraCollaboratorMonthlyUsd) + seats(addons.datasets, pricing.extraDatasetMonthlyUsd) + seats(addons.hosts, pricing.extraHostMonthlyUsd) + seats(addons.posRegisters, POS_REGISTER_ADDON_MONTHLY_USD) + seats(addons.eventCalendar, EVENT_CALENDAR_ADDON_MONTHLY_USD) + seats(siteCareUnits(addons), SITE_CARE_ADDON_MONTHLY_USD) + // A toggle, not a quantity: one purchase covers the org, so a stored
1717
- // quantity above one bills once, at its tier's price (AGL-3965).
1718
- aiTierMonthlyUsd(aiTierOfPurchase(org));
1719
- }
1720
- /** A tier's monthly price, or 0 for no tier. */ function aiTierMonthlyUsd(tier) {
1721
- return tier ? AI_TIERS[tier].monthlyUsd : 0;
1692
+ return (annual ? pricing.basePriceAnnualMonthlyUsd : pricing.basePriceMonthlyUsd) + seats(addons.managers, pricing.extraSeatMonthlyUsd) + seats(addons.members, pricing.extraCollaboratorMonthlyUsd) + seats(addons.datasets, pricing.extraDatasetMonthlyUsd) + seats(addons.hosts, pricing.extraHostMonthlyUsd) + seats(addons.posRegisters, POS_REGISTER_ADDON_MONTHLY_USD) + seats(addons.eventCalendar, EVENT_CALENDAR_ADDON_MONTHLY_USD) + seats(siteCareUnits(addons), SITE_CARE_ADDON_MONTHLY_USD) + // Aglyn AI credit blocks (AGL-4144), $10 each on a plan that sells them.
1693
+ seats(planSellsAiCredits(org == null ? void 0 : org.plan) ? aiAddonUnits(addons) : 0, AI_CREDIT_BLOCK_MONTHLY_USD);
1722
1694
  }
1723
1695
  /**
1724
- * How many Aglyn AI add-ons a purchase map counts as: 0 or 1 (AGL-2896).
1725
- * The add-on is org-wide like Event Calendar, so a quantity above one — a
1726
- * hand edit, a doubled webhook item — is one purchase, and a non-number,
1727
- * `NaN` or a negative is none.
1696
+ * How many Aglyn AI credit blocks a purchase map counts as (AGL-4144): a
1697
+ * whole number from 0 to 30 (`aiCreditBlockCount`). A non-number, `NaN` or a
1698
+ * negative is none, and a quantity above the ceiling is the ceiling.
1728
1699
  */ export function aiAddonUnits(addons) {
1729
- var _ref;
1730
- const quantity = Number((_ref = addons == null ? void 0 : addons.aiAddon) != null ? _ref : 0);
1731
- return Number.isFinite(quantity) && quantity >= 1 ? 1 : 0;
1700
+ return aiCreditBlockCount(addons == null ? void 0 : addons.aiAddon);
1732
1701
  }
1733
1702
  /**
1734
1703
  * How many Site Care add-ons a purchase map counts as: 0 or 1 (AGL-3954).
@@ -2536,73 +2505,60 @@ function resolvePlan(org) {
2536
2505
  return (_ref = org == null ? void 0 : org.seatAddons) != null ? _ref : {};
2537
2506
  }
2538
2507
  /**
2539
- * Whether the org's Aglyn AI add-on currently applies (AGL-2896): bought,
2540
- * and on a subscription that is still paying for it. The ONE reading of
2541
- * `seatAddons.aiAddon` — the entitlement fold and the assist overage rate
2542
- * both ask this, so a dead subscription drops the band and the rate
2543
- * together rather than leaving a rate on a band that has gone.
2508
+ * Whether the org holds Aglyn AI credit blocks that currently apply
2509
+ * (AGL-2896, AGL-4144): bought, and on a subscription that is still paying
2510
+ * for them. The ONE reading of `seatAddons.aiAddon` — the entitlement fold
2511
+ * and the assist overage rate both ask this, so a dead subscription drops
2512
+ * the credits and the rate together rather than leaving a rate on a band
2513
+ * that has gone.
2544
2514
  */ export function hasAiAddon(org) {
2545
- return aiAddonUnits(resolvePurchasedAddons(org)) === 1;
2546
- }
2547
- /**
2548
- * Which Aglyn AI tier the org's purchase map holds (AGL-3965), whether or
2549
- * not the subscription is still paying for it — `resolveAiTier` is the
2550
- * reading that drops a dead one. `org.aiTier` when it names a tier;
2551
- * otherwise, for an add-on bought before tiers existed, the tier with that
2552
- * plan's old price and band (`LEGACY_AI_ADDON_TIER_BY_PLAN`). Null when no
2553
- * add-on is held or the plan sells no tier (Free, Enterprise).
2554
- */ export function aiTierOfPurchase(org) {
2555
- var _LEGACY_AI_ADDON_TIER_BY_PLAN_;
2556
- if (aiAddonUnits(org == null ? void 0 : org.seatAddons) !== 1) return null;
2557
- if (!planSellsAiTiers(org == null ? void 0 : org.plan)) return null;
2558
- if (isAiTierId(org == null ? void 0 : org.aiTier)) return org.aiTier;
2559
- return (_LEGACY_AI_ADDON_TIER_BY_PLAN_ = LEGACY_AI_ADDON_TIER_BY_PLAN[org == null ? void 0 : org.plan]) != null ? _LEGACY_AI_ADDON_TIER_BY_PLAN_ : null;
2515
+ return aiAddonUnits(resolvePurchasedAddons(org)) > 0;
2560
2516
  }
2561
2517
  /**
2562
- * The Aglyn AI tier that currently applies (AGL-3965): bought, on a
2563
- * subscription still paying for it, on a plan that sells tiers. The ONE
2564
- * reading every surface that shows or counts a tier goes through.
2565
- */ export function resolveAiTier(org) {
2566
- return hasAiAddon(org) ? aiTierOfPurchase(org) : null;
2518
+ * How many Aglyn AI credit blocks currently apply (AGL-4144): bought, on a
2519
+ * subscription still paying for them, on a plan that sells blocks. 0 on a
2520
+ * dead subscription, on Free, and on Enterprise (whose add-on is the
2521
+ * agreement's figure, not blocks). The ONE reading every surface that shows
2522
+ * or counts blocks goes through.
2523
+ */ export function resolveAiCreditBlocks(org) {
2524
+ if (!planSellsAiCredits(resolveEffectivePlan(org))) return 0;
2525
+ return aiAddonUnits(resolvePurchasedAddons(org));
2567
2526
  }
2568
2527
  /**
2569
- * What `seatAddons.aiAddon` adds on an Enterprise org (AGL-2896, kept by
2570
- * AGL-3965): twice Studio's band, the figure the per-plan table carried as
2571
- * twice Agency's (the rule every Enterprise fallback follows since AGL-2654),
2572
- * and still what a contract that names the add-on starts from before its own
2573
- * number is written. Enterprise buys no tier — its AI is in the agreement —
2574
- * so this is the contract figure kept, not a price; finite, never
2575
- * `UNLIMITED`, for the reason `ENTERPRISE_ASSIST_CREDITS_PER_MONTH` gives.
2576
- */ export const ENTERPRISE_AI_ADDON_CREDITS_PER_MONTH = AI_TIERS.studio.credits * 2;
2528
+ * What one unit of `seatAddons.aiAddon` adds on an Enterprise org (AGL-2896,
2529
+ * kept through AGL-3965 and AGL-4144): 298,000 credits, the figure the
2530
+ * per-plan table carried as twice the top plan's band, and still what a
2531
+ * contract that names the add-on starts from before its own number is
2532
+ * written. Enterprise buys no blocks — its AI is in the agreement — so this
2533
+ * is the contract figure kept, not a price; finite, never `UNLIMITED`, for
2534
+ * the reason `ENTERPRISE_ASSIST_CREDITS_PER_MONTH` gives.
2535
+ */ export const ENTERPRISE_AI_ADDON_CREDITS_PER_MONTH = 298000;
2577
2536
  /**
2578
2537
  * The Aglyn AI add-on's per-unit quota as `resolveOrgEntitlements` folds it
2579
- * (AGL-3965): the purchased tier's credits, on a plan that sells tiers;
2580
- * Enterprise's contract figure (`ENTERPRISE_AI_ADDON_CREDITS_PER_MONTH`);
2581
- * else 0 (Free). The AI plugin declares its seat add-on with this as
2582
- * `quota.perUnit`.
2583
- */ export function aiTierQuotaPerUnit(org, plan) {
2538
+ * (AGL-4144): 5,000 credits a block on a plan that sells blocks; Enterprise's
2539
+ * contract figure (`ENTERPRISE_AI_ADDON_CREDITS_PER_MONTH`); else 0 (Free).
2540
+ * The AI plugin declares its seat add-on with this as `quota.perUnit`.
2541
+ */ export function aiCreditsQuotaPerUnit(_org, plan) {
2584
2542
  if (plan === 'enterprise') return ENTERPRISE_AI_ADDON_CREDITS_PER_MONTH;
2585
- if (!planSellsAiTiers(plan)) return 0;
2586
- const tier = aiTierOfPurchase(org);
2587
- return tier ? AI_TIERS[tier].credits : 0;
2543
+ return planSellsAiCredits(plan) ? AI_CREDITS_PER_BLOCK : 0;
2588
2544
  }
2589
2545
  /**
2590
2546
  * The credits a month the org's Aglyn AI add-on adds to its plan's included
2591
- * band (AGL-3965) — 0 with none held. The SAME figure `resolveOrgEntitlements`
2592
- * folds into `assistCreditsPerMonth` (`aiTierQuotaPerUnit`), so a surface
2593
- * quoting "your tier adds" and the meter agree.
2594
- */ export function aiTierCreditsPerMonth(org) {
2547
+ * band (AGL-4144) — 0 with none held. The SAME figure `resolveOrgEntitlements`
2548
+ * folds into `assistCreditsPerMonth` (units × `aiCreditsQuotaPerUnit`), so a
2549
+ * surface quoting "your blocks add" and the meter agree.
2550
+ */ export function aiCreditBlocksCreditsPerMonth(org) {
2595
2551
  if (!hasAiAddon(org)) return 0;
2596
- return aiTierQuotaPerUnit(org, resolveEffectivePlan(org));
2552
+ const plan = resolveEffectivePlan(org);
2553
+ return aiAddonUnits(resolvePurchasedAddons(org)) * aiCreditsQuotaPerUnit(org, plan);
2597
2554
  }
2598
2555
  /**
2599
- * Whether this org can buy or change an Aglyn AI tier itself (AGL-3965): a
2600
- * plan that sells tiers, and not one a staff comp grants — a comp has no
2601
- * subscription to put the tier on (`compPricing`).
2602
- */ export function orgCanBuyAiTier(org) {
2603
- return !resolvePlanComp(org) && planSellsAiTiers(resolveEffectivePlan(org));
2556
+ * Whether this org can buy or change Aglyn AI credit blocks itself
2557
+ * (AGL-4144): a plan that sells them, and not one a staff comp grants — a
2558
+ * comp has no subscription to put the blocks on (`compPricing`).
2559
+ */ export function orgCanBuyAiCredits(org) {
2560
+ return !resolvePlanComp(org) && planSellsAiCredits(resolveEffectivePlan(org));
2604
2561
  }
2605
- /** "Aglyn AI Boost": the product name, then the tier's. */ export const aiTierName = (tier, brand = PLATFORM_BRAND_NAME)=>`${aiAddonName(brand)} ${AI_TIERS[tier].label}`;
2606
2562
  /**
2607
2563
  * Whether the org's Site Care add-on currently applies (AGL-3954): bought,
2608
2564
  * and on a subscription that is still paying for it, so a dead subscription
@@ -3798,7 +3754,7 @@ export function checkQuota(org, quota, currentUsage) {
3798
3754
  }
3799
3755
  /**
3800
3756
  * Customer REST API request meter (AGL-634): the monthly request count for an
3801
- * org. Business and every tier above it carry `apiAccess` and an
3757
+ * org. Pro (since pricing v4) and every tier above it carry `apiAccess` and an
3802
3758
  * `extraApiRequestsUsdPer1k` rate, so requests past the included quota meter
3803
3759
  * onto the monthly invoice
3804
3760
  * (cost-plus, like storage overage — never a hard wall mid-integration); plans
@@ -3820,6 +3776,49 @@ export function checkQuota(org, quota, currentUsage) {
3820
3776
  overageRateUsd
3821
3777
  };
3822
3778
  }
3779
+ /** Both run bands, in the order the usage page meters them. */ export const RUN_BAND_KEYS = [
3780
+ 'workflowRunsPerMonth',
3781
+ 'actionRunsPerMonth'
3782
+ ];
3783
+ /**
3784
+ * Whether the org's plan sells runs past its run bands (pricing v4,
3785
+ * 2026-11-03, AGL-4126): a non-null `extraRunsUsdPer1k` on the row the org is
3786
+ * priced at (`resolvePlanPricing`, so a comp sells nothing). The run gates ask
3787
+ * this before refusing at the band: true and the run goes ahead and is billed
3788
+ * past the band; false — Free, Starter, a comp, Enterprise — and the band is
3789
+ * the wall it always was.
3790
+ */ export function runOverageSold(org) {
3791
+ return resolvePlanPricing(org).extraRunsUsdPer1k !== null;
3792
+ }
3793
+ /**
3794
+ * The month's run overage (pricing v4, AGL-4126): each band's excess on its
3795
+ * own — a workspace far under its action band does not lend headroom to its
3796
+ * workflow band — summed and priced at the plan's `extraRunsUsdPer1k`. The
3797
+ * counts are the WORKSPACE's (`run-meter.ts`), the figure each band is held
3798
+ * to. A plan with no rate prices nothing, whatever the counts say.
3799
+ *
3800
+ * `used` is keyed by the band each count is held to (`RUN_BAND_KEYS`), so a
3801
+ * caller outside the workflows plugin reads its counts off the declared bands
3802
+ * and never names the plugin's own meters.
3803
+ */ export function priceRunOverage(org, used) {
3804
+ const entitlements = resolveOrgEntitlements(org);
3805
+ const overageRateUsd = resolvePlanPricing(org).extraRunsUsdPer1k;
3806
+ const past = (count, band)=>{
3807
+ var _entitlements_band;
3808
+ const value = Number(count != null ? count : 0);
3809
+ const included = Number((_entitlements_band = entitlements[band]) != null ? _entitlements_band : 0);
3810
+ // A corrupt count bills nothing, and an UNLIMITED band has no excess.
3811
+ if (!Number.isFinite(value) || value <= 0) return 0;
3812
+ if (!Number.isFinite(included)) return 0;
3813
+ return Math.max(0, Math.floor(value) - Math.max(0, included));
3814
+ };
3815
+ const overageRuns = RUN_BAND_KEYS.reduce((sum, band)=>sum + past(used[band], band), 0);
3816
+ return {
3817
+ overageRuns,
3818
+ overageRateUsd,
3819
+ overageMonthlyUsd: overageRateUsd === null ? 0 : Math.round(overageRuns / 1000 * overageRateUsd * 100) / 100
3820
+ };
3821
+ }
3823
3822
  /**
3824
3823
  * CRM records band meter (AGL-890, widened in AGL-2611): contacts, companies
3825
3824
  * and deals, counted together across the org and measured against the ONE
@@ -3926,7 +3925,9 @@ export function checkQuota(org, quota, currentUsage) {
3926
3925
  /**
3927
3926
  * Volume above the plan's included band, in emails.
3928
3927
  *
3929
- * Transactional mail is never refused, so an org CAN and will finish a month
3928
+ * Transactional mail is never refused by a quota (only by the daily abuse
3929
+ * ceiling in `transactional-email-ceiling.ts`, which no real store reaches),
3930
+ * so an org CAN and will finish a month
3930
3931
  * over its included allowance. That is not an error and not a failed send —
3931
3932
  * it is the overage the cap chose not to enforce, and recording it is what
3932
3933
  * keeps it from being a surprise at invoicing. `UNLIMITED` (and any