@aglyn/plugins-ai 1.0.0-beta.232 → 1.0.0-beta.234
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/components/ai-job-links.d.ts +6 -0
- package/src/lib/components/ai-job-links.js +9 -0
- package/src/lib/components/ai-job-links.js.map +1 -1
- package/src/lib/components/ai-site-build-page.component.js +41 -3
- package/src/lib/components/ai-site-build-page.component.js.map +1 -1
- package/src/lib/components/ai-site-start-card.component.js +91 -8
- package/src/lib/components/ai-site-start-card.component.js.map +1 -1
- package/src/lib/declarations.server.js +7 -4
- package/src/lib/declarations.server.js.map +1 -1
- package/src/lib/jobs/ai-build-capabilities.js +8 -2
- package/src/lib/jobs/ai-build-capabilities.js.map +1 -1
- package/src/lib/jobs/ai-job-admission.d.ts +2 -1
- package/src/lib/jobs/ai-job-admission.js.map +1 -1
- package/src/lib/jobs/ai-job-email-step.d.ts +39 -0
- package/src/lib/jobs/ai-job-email-step.js +116 -5
- package/src/lib/jobs/ai-job-email-step.js.map +1 -1
- package/src/lib/jobs/ai-job-layout-language.d.ts +3 -0
- package/src/lib/jobs/ai-job-layout-language.js +3 -1
- package/src/lib/jobs/ai-job-layout-language.js.map +1 -1
- package/src/lib/jobs/ai-job-layout-site-pages.d.ts +2 -0
- package/src/lib/jobs/ai-job-layout-site-pages.js +23 -11
- package/src/lib/jobs/ai-job-layout-site-pages.js.map +1 -1
- package/src/lib/jobs/ai-job-layout-step.js +3 -2
- package/src/lib/jobs/ai-job-layout-step.js.map +1 -1
- package/src/lib/jobs/ai-job-page-language.d.ts +16 -0
- package/src/lib/jobs/ai-job-page-language.js +35 -6
- package/src/lib/jobs/ai-job-page-language.js.map +1 -1
- package/src/lib/jobs/ai-job-page-step.d.ts +3 -0
- package/src/lib/jobs/ai-job-page-step.js +18 -4
- package/src/lib/jobs/ai-job-page-step.js.map +1 -1
- package/src/lib/jobs/ai-job-plan-step.d.ts +40 -1
- package/src/lib/jobs/ai-job-plan-step.js +121 -16
- package/src/lib/jobs/ai-job-plan-step.js.map +1 -1
- package/src/lib/jobs/ai-job-site-content.d.ts +6 -6
- package/src/lib/jobs/ai-job-site-content.js +6 -12
- package/src/lib/jobs/ai-job-site-content.js.map +1 -1
- package/src/lib/jobs/ai-job-site-step.d.ts +11 -0
- package/src/lib/jobs/ai-job-site-step.js +96 -44
- package/src/lib/jobs/ai-job-site-step.js.map +1 -1
- package/src/lib/jobs/ai-jobs-notify.d.ts +14 -4
- package/src/lib/jobs/ai-jobs-notify.js +70 -4
- package/src/lib/jobs/ai-jobs-notify.js.map +1 -1
- package/src/lib/jobs/ai-jobs.d.ts +22 -4
- package/src/lib/jobs/ai-jobs.js +47 -12
- package/src/lib/jobs/ai-jobs.js.map +1 -1
- package/src/lib/jobs/ai-layout-stock-photos.d.ts +98 -0
- package/src/lib/jobs/ai-layout-stock-photos.js +248 -0
- package/src/lib/jobs/ai-layout-stock-photos.js.map +1 -0
- package/src/lib/jobs/ai-site-publish.d.ts +11 -0
- package/src/lib/jobs/ai-site-publish.js +31 -1
- package/src/lib/jobs/ai-site-publish.js.map +1 -1
- package/src/lib/jobs/fixtures/ai-juniper-portfolio-page-recording.d.ts +151 -0
- package/src/lib/jobs/fixtures/ai-juniper-portfolio-page-recording.js +183 -0
- package/src/lib/jobs/fixtures/ai-juniper-portfolio-page-recording.js.map +1 -0
- package/src/lib/jobs/fixtures/ai-slow-roads-site-plan-recording.d.ts +27 -0
- package/src/lib/jobs/fixtures/ai-slow-roads-site-plan-recording.js +192 -0
- package/src/lib/jobs/fixtures/ai-slow-roads-site-plan-recording.js.map +1 -0
- package/src/lib/jobs/fixtures/ai-yoga-site-plan-recording.d.ts +27 -0
- package/src/lib/jobs/fixtures/ai-yoga-site-plan-recording.js +222 -0
- package/src/lib/jobs/fixtures/ai-yoga-site-plan-recording.js.map +1 -0
- package/src/lib/layout-language/ai-layout-compiler.d.ts +29 -0
- package/src/lib/layout-language/ai-layout-compiler.js +698 -12
- package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
- package/src/lib/layout-language/ai-layout-design.d.ts +107 -0
- package/src/lib/layout-language/ai-layout-design.js +197 -0
- package/src/lib/layout-language/ai-layout-design.js.map +1 -0
- package/src/lib/layout-language/ai-layout-frame.d.ts +6 -0
- package/src/lib/layout-language/ai-layout-frame.js +22 -6
- package/src/lib/layout-language/ai-layout-frame.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 +15 -1
- package/src/lib/layout-language/ai-layout-language.js.map +1 -1
- package/src/lib/layout-language/ai-layout-links.d.ts +11 -0
- package/src/lib/layout-language/ai-layout-links.js +4 -0
- package/src/lib/layout-language/ai-layout-links.js.map +1 -1
- package/src/lib/layout-language/ai-layout-pictures.d.ts +11 -5
- package/src/lib/layout-language/ai-layout-pictures.js +80 -17
- package/src/lib/layout-language/ai-layout-pictures.js.map +1 -1
- package/src/lib/model/ai-job-notice.d.ts +9 -1
- package/src/lib/model/ai-job-notice.js +23 -0
- package/src/lib/model/ai-job-notice.js.map +1 -1
- package/src/lib/model/ai-plan-capabilities.d.ts +23 -0
- package/src/lib/model/ai-plan-capabilities.js +5 -0
- package/src/lib/model/ai-plan-capabilities.js.map +1 -1
- package/src/lib/model/ai-site-build-progress.d.ts +12 -2
- package/src/lib/model/ai-site-build-progress.js +78 -4
- package/src/lib/model/ai-site-build-progress.js.map +1 -1
- package/src/lib/model/ai-site-job.d.ts +209 -22
- package/src/lib/model/ai-site-job.js +247 -20
- package/src/lib/model/ai-site-job.js.map +1 -1
- package/src/lib/model/ai-site-kinds.js +6 -1
- package/src/lib/model/ai-site-kinds.js.map +1 -1
- package/src/lib/model/ai-site-look.d.ts +21 -0
- package/src/lib/model/ai-site-look.js +63 -14
- package/src/lib/model/ai-site-look.js.map +1 -1
- package/src/lib/operator-alerts.d.ts +18 -0
- package/src/lib/operator-alerts.js +42 -0
- package/src/lib/operator-alerts.js.map +1 -1
- package/src/lib/runtime/ai-doctrine-validators.d.ts +39 -1
- package/src/lib/runtime/ai-doctrine-validators.js +236 -6
- package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
- package/src/lib/runtime/ai-doctrine.js +5 -3
- package/src/lib/runtime/ai-doctrine.js.map +1 -1
- package/src/lib/runtime/ai-palette.generated.d.ts +2 -0
- package/src/lib/runtime/ai-palette.generated.js +18 -2
- package/src/lib/runtime/ai-palette.generated.js.map +1 -1
- package/src/lib/server/ai-jobs-resume.js.map +1 -1
- package/src/lib/server/ai-jobs-route.js +15 -3
- package/src/lib/server/ai-jobs-route.js.map +1 -1
- package/src/lib/server/assist-edit.js +5 -2
- package/src/lib/server/assist-edit.js.map +1 -1
- package/src/lib/usage/free-ai-credits-left.d.ts +54 -0
- package/src/lib/usage/free-ai-credits-left.js +62 -0
- package/src/lib/usage/free-ai-credits-left.js.map +1 -0
|
@@ -674,6 +674,16 @@ const ratio = (a, b)=>{
|
|
|
674
674
|
const ink = aiOklchHex(0.2, 0.04, h);
|
|
675
675
|
return ratio(white, fill) >= 4.5 ? white : ratio(ink, fill) >= 4.5 ? ink : ratio(white, fill) > ratio(ink, fill) ? white : '#000000';
|
|
676
676
|
}
|
|
677
|
+
/** How far apart two hues sit on the wheel, in degrees: 0 to 180. */ export function aiHueGap(a, b) {
|
|
678
|
+
const d = Math.abs(a - b) % 360;
|
|
679
|
+
return Math.min(d, 360 - d);
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* The widest gap an accent may keep from the brand hue and still color a
|
|
683
|
+
* button beside it (AGL-3660). Past it the accent clashes: a live portfolio of
|
|
684
|
+
* green (hue 131) and magenta (323) showed its outlined buttons as a pink wash
|
|
685
|
+
* and its footer button as purple under green words, on a Cupertino base.
|
|
686
|
+
*/ export const AI_SITE_ACCENT_CLASH_DEGREES = 60;
|
|
677
687
|
const CHROMA = {
|
|
678
688
|
neutral: 0.15,
|
|
679
689
|
muted: 0.085,
|
|
@@ -748,23 +758,31 @@ const START_L = {
|
|
|
748
758
|
primaryMain = aiOklchHex(primaryL, chroma, h);
|
|
749
759
|
}
|
|
750
760
|
const accentChroma = neutral ? 0.17 : Math.max(0.07, chroma * 0.95);
|
|
761
|
+
// A button's colors come from the brand hue where the accent clashes with
|
|
762
|
+
// it (AGL-3660); the accent keeps its tint and the tertiary.
|
|
763
|
+
const buttonHue = aiHueGap(style.accent, h) > AI_SITE_ACCENT_CLASH_DEGREES ? h : style.accent;
|
|
751
764
|
// The secondary color fills a button ON a brand band, so it stands apart from the brand color.
|
|
752
|
-
const secondary = neutral ? {
|
|
753
|
-
|
|
754
|
-
h
|
|
755
|
-
|
|
765
|
+
const secondary = neutral ? (()=>{
|
|
766
|
+
// Ink or paper, whichever stands further from the brand color (AGL-3660).
|
|
767
|
+
const ink = aiOklchHex(0.24, 0.012, h);
|
|
768
|
+
const paper = aiOklchHex(0.97, 0.008, h);
|
|
769
|
+
return {
|
|
770
|
+
main: ratio(ink, primaryMain) >= ratio(paper, primaryMain) ? ink : paper,
|
|
771
|
+
h
|
|
772
|
+
};
|
|
773
|
+
})() : (()=>{
|
|
756
774
|
// A light wash of the accent rather than the accent at full strength:
|
|
757
775
|
// it reads on the brand color without fighting it.
|
|
758
776
|
const washChroma = Math.min(accentChroma, 0.08);
|
|
759
777
|
let L = 0.9;
|
|
760
|
-
let main = aiOklchHex(L, washChroma,
|
|
778
|
+
let main = aiOklchHex(L, washChroma, buttonHue);
|
|
761
779
|
while(ratio(main, primaryMain) < 3 && L < 0.96){
|
|
762
780
|
L += 0.02;
|
|
763
|
-
main = aiOklchHex(L, washChroma,
|
|
781
|
+
main = aiOklchHex(L, washChroma, buttonHue);
|
|
764
782
|
}
|
|
765
783
|
return {
|
|
766
784
|
main,
|
|
767
|
-
h:
|
|
785
|
+
h: buttonHue
|
|
768
786
|
};
|
|
769
787
|
})();
|
|
770
788
|
const tertiaryHue = (style.accent + 60) % 360;
|
|
@@ -803,9 +821,11 @@ const START_L = {
|
|
|
803
821
|
secondary: aiOklchHex(0.45, textChroma + 0.005, h),
|
|
804
822
|
disabled: aiOklchHex(0.68, 0.01, h)
|
|
805
823
|
},
|
|
824
|
+
// The primary's tint is the brand's own wash (AGL-3660): a base fills an
|
|
825
|
+
// outlined or tinted button with it, under the primary's dark words.
|
|
806
826
|
tint: {
|
|
807
|
-
primary: aiOklchHex(0.955, neutral ? 0.03 : 0.035,
|
|
808
|
-
secondary: aiOklchHex(0.955, 0.035,
|
|
827
|
+
primary: aiOklchHex(0.955, neutral ? 0.03 : 0.035, h),
|
|
828
|
+
secondary: aiOklchHex(0.955, 0.035, buttonHue),
|
|
809
829
|
tertiary: aiOklchHex(0.955, 0.03, tertiaryHue)
|
|
810
830
|
},
|
|
811
831
|
divider: aiOklchHex(0.9, 0.012 * groundChroma, h)
|
|
@@ -816,7 +836,7 @@ const START_L = {
|
|
|
816
836
|
const darkChroma = Math.min(chroma, 0.14);
|
|
817
837
|
const darkPrimaryL = untilContrast(0.78, darkChroma, h, darkBackground, 4.5, 1);
|
|
818
838
|
const darkPrimary = aiOklchHex(darkPrimaryL, darkChroma, h);
|
|
819
|
-
const darkSecondary = neutral ? aiOklchHex(0.93, 0.01, h) : aiOklchHex(0.45, accentChroma * 0.85,
|
|
839
|
+
const darkSecondary = neutral ? aiOklchHex(0.93, 0.01, h) : aiOklchHex(0.45, accentChroma * 0.85, buttonHue);
|
|
820
840
|
const darkTertiary = aiOklchHex(0.8, 0.1, tertiaryHue);
|
|
821
841
|
const dark = {
|
|
822
842
|
primary: {
|
|
@@ -851,8 +871,8 @@ const START_L = {
|
|
|
851
871
|
disabled: aiOklchHex(0.52, 0.01, h)
|
|
852
872
|
},
|
|
853
873
|
tint: {
|
|
854
|
-
primary: aiOklchHex(0.27, 0.05,
|
|
855
|
-
secondary: aiOklchHex(0.27, 0.05,
|
|
874
|
+
primary: aiOklchHex(0.27, 0.05, h),
|
|
875
|
+
secondary: aiOklchHex(0.27, 0.05, buttonHue),
|
|
856
876
|
tertiary: aiOklchHex(0.27, 0.04, tertiaryHue)
|
|
857
877
|
},
|
|
858
878
|
divider: aiOklchHex(0.32, 0.015 * groundChroma, h)
|
|
@@ -905,17 +925,46 @@ const SPACING = {
|
|
|
905
925
|
}
|
|
906
926
|
};
|
|
907
927
|
const rem = (value)=>`${Math.round(value * 1000) / 1000}rem`;
|
|
928
|
+
/**
|
|
929
|
+
* The kinds whose titles are their design (AGL-3660): a portfolio's or a
|
|
930
|
+
* studio's statement, a photographer's name over a cover, a publication's
|
|
931
|
+
* masthead are set larger than a business site's, the way the designer
|
|
932
|
+
* templates set them. The display line grows most, the page title a little,
|
|
933
|
+
* and nothing under it; a phone still steps every size down
|
|
934
|
+
* (`responsiveFontSizes`).
|
|
935
|
+
*/ export const AI_SITE_DISPLAY_BOOST = {
|
|
936
|
+
portfolio: {
|
|
937
|
+
display: 1.25,
|
|
938
|
+
title: 1.1
|
|
939
|
+
},
|
|
940
|
+
studio: {
|
|
941
|
+
display: 1.3,
|
|
942
|
+
title: 1.1
|
|
943
|
+
},
|
|
944
|
+
photography: {
|
|
945
|
+
display: 1.2,
|
|
946
|
+
title: 1.08
|
|
947
|
+
},
|
|
948
|
+
blog: {
|
|
949
|
+
display: 1.25,
|
|
950
|
+
title: 1.1
|
|
951
|
+
}
|
|
952
|
+
};
|
|
908
953
|
/** The type a style sets: headings at its scale, weight and tracking, and the eyebrow and button styles. */ function typographyFor(style) {
|
|
909
954
|
var _aiSiteFontPairing, _ref;
|
|
910
955
|
var _DEFAULT_SITE_THEME_typography;
|
|
911
956
|
const pairing = (_aiSiteFontPairing = aiSiteFontPairing(style.fonts)) != null ? _aiSiteFontPairing : AI_SITE_FONT_PAIRINGS[0];
|
|
912
957
|
const variants = _extends({}, (_ref = (_DEFAULT_SITE_THEME_typography = DEFAULT_SITE_THEME.typography) == null ? void 0 : _DEFAULT_SITE_THEME_typography.variants) != null ? _ref : {});
|
|
958
|
+
const boost = AI_SITE_DISPLAY_BOOST[style.kind];
|
|
913
959
|
for (const [key, { size, share }] of Object.entries(SCALE_SHARE)){
|
|
960
|
+
var _ref1, _ref2;
|
|
914
961
|
const big = key === 'displayXl' || key === 'h1' || key === 'h2';
|
|
962
|
+
const boosted = key === 'displayXl' ? (_ref1 = boost == null ? void 0 : boost.display) != null ? _ref1 : 1 : key === 'h1' ? (_ref2 = boost == null ? void 0 : boost.title) != null ? _ref2 : 1 : 1;
|
|
915
963
|
const variant = {
|
|
916
|
-
fontSize: rem(size * (1 + (style.headingScale - 1) * share) * (pairing.caps && big ? 0.92 : 1)),
|
|
964
|
+
fontSize: rem(size * (1 + (style.headingScale - 1) * share) * (pairing.caps && big ? 0.92 : 1) * boosted),
|
|
917
965
|
fontWeight: big ? pairing.heading.weight : pairing.heading.sub,
|
|
918
|
-
|
|
966
|
+
// A display line set larger sets tighter.
|
|
967
|
+
lineHeight: big ? pairing.caps ? 1.05 : key === 'displayXl' && boost ? 1.02 : 1.1 : 1.25
|
|
919
968
|
};
|
|
920
969
|
if (pairing.tracking !== undefined && (big || key === 'h3')) variant.letterSpacing = `${pairing.tracking}em`;
|
|
921
970
|
if (pairing.caps && (big || key === 'h3')) variant.textTransform = 'uppercase';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-site-look.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n contrastRatio,\n validateThemeForPublish,\n} from '@aglyn/aglyn/app-utils/site-theme'\nimport { DEFAULT_SITE_THEME } from '@aglyn/aglyn/app-utils/default-site'\nimport type {\n HostTheme,\n HostThemeComponentOverride,\n HostThemeSchemeColors,\n HostThemeTypographyVariant,\n HostThemeTypographyVariantKey,\n} from '@aglyn/shared-data-types'\nimport { writeThemeFonts } from '@aglyn/shared-ui-theme/util/theme-editor-fields'\nimport type { AiTool } from '../runtime/ai-runtime'\nimport {\n AI_SITE_BASES,\n AI_SITE_CORNERS,\n AI_SITE_FONT_PAIRINGS,\n AI_SITE_GROUNDS,\n AI_SITE_RHYTHMS,\n aiSiteFontPairing,\n type AiSiteBase,\n type AiSiteButtons,\n type AiSiteChroma,\n type AiSiteCorners,\n type AiSiteDensity,\n type AiSiteGround,\n type AiSiteKind,\n type AiSiteRhythm,\n} from './ai-site-kinds'\n\n/**\n * A site's look (AGL-3660): one of the platform's base themes, and this\n * site's own customizations layered over it as the site theme's override —\n * the same base-and-edits shape a person's pick on Setup → Theme is stored\n * as, so the Theme page names the base it came from and every edit there\n * starts from what the AI chose.\n *\n * Everything the look decides lives in the THEME, never on a node: palette,\n * fonts, type scale, corners, spacing, and the component defaults and styles\n * of buttons, cards, fields, eyebrows, the header bar and the FAQ. So a Card\n * or a Button a person drags in later looks like the rest of the site, and\n * the layout compiler emits plain components.\n *\n * Three inputs decide it:\n * - the KIND (`ai-site-kinds.ts`): the family of looks that suit the site;\n * - the MODEL's choices for this business (`submit_site_look`), any of\n * which may be missing;\n * - the per-job SEED, which fills what the model left out from the kind's\n * options and nudges every hue, chroma and size, so two jobs with the same\n * brief and the same answers still produce two different themes.\n *\n * Colors are built in OKLCH and held to WCAG: body text 4.5:1 on its ground\n * and on paper, every button label 4.5:1 on its fill, the brand color 3:1 on\n * the page — then the whole theme passes `validateThemeForPublish`, or its\n * colors fall back to the starter theme's.\n */\n\n// ── The tokens ───────────────────────────────────────────────────────────\n\n/** How cards are drawn. */\nexport const AI_SITE_CARDS = ['flat', 'outlined', 'elevated', 'tinted', 'rule'] as const\nexport type AiSiteCards = (typeof AI_SITE_CARDS)[number]\n/** The form field style. */\nexport const AI_SITE_FIELDS = ['outlined', 'filled', 'standard'] as const\nexport type AiSiteFields = (typeof AI_SITE_FIELDS)[number]\n/** How an eyebrow above a heading is set. */\nexport const AI_SITE_EYEBROWS = ['caps', 'small', 'rule'] as const\nexport type AiSiteEyebrow = (typeof AI_SITE_EYEBROWS)[number]\n/** What sets a plain header bar off the page. */\nexport const AI_SITE_HEADERS = ['line', 'shadow', 'flat'] as const\nexport type AiSiteHeader = (typeof AI_SITE_HEADERS)[number]\n/** Button shapes and casing; `link` draws quiet buttons as underlined links. */\nexport const AI_SITE_BUTTONS: readonly AiSiteButtons[] = ['rounded', 'pill', 'square', 'caps', 'link']\nconst DENSITIES: readonly AiSiteDensity[] = ['compact', 'regular', 'airy']\n\n/**\n * A site's style tokens: everything its theme was built from. Stored with the\n * site (`hosts/{id}.siteStyle`) so a later AI edit keeps the look.\n */\nexport interface AiSiteStyle {\n v: 1\n kind: string\n base: AiSiteBase\n seed: number\n hue: number\n accent: number\n chroma: AiSiteChroma\n ground: AiSiteGround\n fonts: string\n corners: AiSiteCorners\n buttons: AiSiteButtons\n cards: AiSiteCards\n fields: AiSiteFields\n eyebrow: AiSiteEyebrow\n header: AiSiteHeader\n /** The header's arrangement: brand at the start and links after it, or both centered. */\n headerAlign: 'start' | 'center'\n /** How the pages alternate their bands. */\n rhythm: AiSiteRhythm\n headingScale: number\n density: AiSiteDensity\n /** A brand color the brief gave, used as the primary color. */\n brand: string | null\n}\n\n/** What the model may choose, every field optional. */\nexport type AiSiteLookAnswer = Partial<\n Pick<\n AiSiteStyle,\n 'base' | 'hue' | 'accent' | 'ground' | 'fonts' | 'corners' | 'buttons' | 'cards' | 'fields' | 'eyebrow' | 'header' | 'brand'\n >\n>\n\n// ── The seed ─────────────────────────────────────────────────────────────\n\n/** A job's seed: FNV-1a over its id. */\nexport function aiSiteSeed(jobId: string): number {\n let hash = 0x811c9dc5\n for (let index = 0; index < jobId.length; index += 1) {\n hash ^= jobId.charCodeAt(index)\n hash = Math.imul(hash, 0x01000193)\n }\n return hash >>> 0\n}\n\n/** A small deterministic generator over a seed (mulberry32). */\nfunction random(seed: number): () => number {\n let state = seed >>> 0\n return () => {\n state = (state + 0x6d2b79f5) >>> 0\n let t = state\n t = Math.imul(t ^ (t >>> 15), t | 1)\n t ^= t + Math.imul(t ^ (t >>> 7), t | 61)\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296\n }\n}\n\nconst pick = <T,>(next: () => number, list: readonly T[]): T => list[Math.floor(next() * list.length) % list.length] as T\n\n// ── The model's answer ───────────────────────────────────────────────────\n\nexport const AI_SITE_LOOK_TOOL_NAME = 'submit_site_look'\n\nconst enumOf = (values: readonly string[], description: string) => ({ type: 'string', enum: [...values], description })\n\n/** The strict tool the look is answered with; every field is required and the reader is lenient. */\nexport const AI_SITE_LOOK_TOOL: AiTool = {\n name: AI_SITE_LOOK_TOOL_NAME,\n description: \"Submit this website's look: the base theme it starts from and the choices that make it this business's own.\",\n strict: true,\n inputSchema: {\n type: 'object',\n additionalProperties: false,\n required: ['base', 'hue', 'accent', 'ground', 'fonts', 'corners', 'buttons', 'cards', 'fields', 'eyebrow', 'header', 'brand'],\n properties: {\n base: enumOf(AI_SITE_BASES, 'The base theme to start from, from the list in the request.'),\n hue: { type: 'integer', description: 'The brand color as a hue from 0 to 359 (0 red, 30 orange, 55 gold, 140 green, 190 teal, 220 blue, 270 violet, 330 pink).' },\n accent: { type: 'integer', description: 'The accent color as a hue from 0 to 359, chosen to sit well beside the brand hue.' },\n ground: enumOf(AI_SITE_GROUNDS, 'The page background: white, warm (cream), cool (gray-blue) or tinted (a whisper of the brand color).'),\n fonts: enumOf(AI_SITE_FONT_PAIRINGS.map((pairing) => pairing.id), 'A font pairing from the list in the request.'),\n corners: enumOf(AI_SITE_CORNERS, 'Corner rounding for cards and fields.'),\n buttons: enumOf(AI_SITE_BUTTONS, 'Buttons: rounded, pill, square, caps (capitals) or link (quiet buttons drawn as underlined links).'),\n cards: enumOf(AI_SITE_CARDS, 'Cards: flat, outlined, elevated (a soft shadow), tinted (a wash of the brand color) or rule (a colored line on top).'),\n fields: enumOf(AI_SITE_FIELDS, 'Form fields: outlined, filled or standard (underlined).'),\n eyebrow: enumOf(AI_SITE_EYEBROWS, 'The small label above headings: caps (spaced capitals), small (quiet small text) or rule (capitals after a short line).'),\n header: enumOf(AI_SITE_HEADERS, 'What sets the header bar off the page: a line, a shadow, or flat.'),\n brand: { anyOf: [{ type: 'string' }, { type: 'null' }], description: 'A hex brand color the brief gives, exactly as written, or null.' },\n },\n },\n}\n\nconst oneOf = <T extends string>(value: unknown, values: readonly T[]): T | undefined =>\n typeof value === 'string' && (values as readonly string[]).includes(value) ? (value as T) : undefined\n\nconst hueOf = (value: unknown): number | undefined =>\n typeof value === 'number' && Number.isFinite(value) ? ((Math.round(value) % 360) + 360) % 360 : undefined\n\n/** A brand color as a six-digit hex, or `null`. */\nexport function aiSiteBrandHex(value: unknown): string | null {\n if (typeof value !== 'string') return null\n const match = /#?([0-9a-f]{6}|[0-9a-f]{3})\\b/i.exec(value.trim())\n if (!match) return null\n const hex = match[1] as string\n const full = hex.length === 3 ? [...hex].map((digit) => digit + digit).join('') : hex\n return `#${full.toLowerCase()}`\n}\n\n/** The model's answer, read leniently: a value outside its vocabulary is left for the seed. */\nexport function aiReadSiteLook(answer: unknown): AiSiteLookAnswer {\n const raw = (answer && typeof answer === 'object' ? answer : {}) as Record<string, unknown>\n const look: AiSiteLookAnswer = {}\n const base = oneOf(raw['base'], AI_SITE_BASES)\n if (base) look.base = base\n const hue = hueOf(raw['hue'])\n if (hue !== undefined) look.hue = hue\n const accent = hueOf(raw['accent'])\n if (accent !== undefined) look.accent = accent\n const ground = oneOf(raw['ground'], AI_SITE_GROUNDS)\n if (ground) look.ground = ground\n if (aiSiteFontPairing(raw['fonts'])) look.fonts = raw['fonts'] as string\n const corners = oneOf(raw['corners'], AI_SITE_CORNERS)\n if (corners) look.corners = corners\n const buttons = oneOf(raw['buttons'], AI_SITE_BUTTONS)\n if (buttons) look.buttons = buttons\n const cards = oneOf(raw['cards'], AI_SITE_CARDS)\n if (cards) look.cards = cards\n const fields = oneOf(raw['fields'], AI_SITE_FIELDS)\n if (fields) look.fields = fields\n const eyebrow = oneOf(raw['eyebrow'], AI_SITE_EYEBROWS)\n if (eyebrow) look.eyebrow = eyebrow\n const header = oneOf(raw['header'], AI_SITE_HEADERS)\n if (header) look.header = header\n const brand = aiSiteBrandHex(raw['brand'])\n if (brand) look.brand = brand\n return look\n}\n\n// ── Kind, model and seed into tokens ─────────────────────────────────────\n\n/** The building-block styles a kind leans to, before the model or the seed choose. */\nconst BLOCK_BIAS: Partial<\n Record<string, { cards: readonly AiSiteCards[]; eyebrow: readonly AiSiteEyebrow[]; header: readonly AiSiteHeader[]; fields: readonly AiSiteFields[] }>\n> = {\n portfolio: { cards: ['rule', 'flat', 'outlined'], eyebrow: ['small', 'rule', 'caps'], header: ['flat', 'line', 'shadow'], fields: ['standard', 'outlined', 'filled'] },\n studio: { cards: ['flat', 'rule', 'outlined'], eyebrow: ['rule', 'small', 'caps'], header: ['flat', 'line', 'shadow'], fields: ['standard', 'outlined', 'filled'] },\n photography: { cards: ['flat', 'rule', 'outlined'], eyebrow: ['small', 'rule', 'caps'], header: ['flat', 'line', 'shadow'], fields: ['standard', 'outlined', 'filled'] },\n blog: { cards: ['rule', 'outlined', 'flat', 'tinted'], eyebrow: ['small', 'caps', 'rule'], header: ['line', 'flat', 'shadow'], fields: ['outlined', 'standard', 'filled'] },\n trades: { cards: ['elevated', 'outlined', 'rule', 'flat', 'tinted'], eyebrow: ['caps', 'rule', 'small'], header: ['shadow', 'line', 'flat'], fields: ['outlined', 'filled', 'standard'] },\n fitness: { cards: ['elevated', 'flat', 'rule', 'outlined'], eyebrow: ['caps', 'rule', 'small'], header: ['shadow', 'flat', 'line'], fields: ['filled', 'outlined', 'standard'] },\n professional: { cards: ['outlined', 'rule', 'flat', 'elevated'], eyebrow: ['caps', 'rule', 'small'], header: ['line', 'flat', 'shadow'], fields: ['outlined', 'standard', 'filled'] },\n wellness: { cards: ['tinted', 'flat', 'elevated', 'outlined'], eyebrow: ['small', 'caps', 'rule'], header: ['flat', 'line', 'shadow'], fields: ['filled', 'outlined', 'standard'] },\n yoga: { cards: ['tinted', 'flat', 'outlined'], eyebrow: ['small', 'rule', 'caps'], header: ['flat', 'line', 'shadow'], fields: ['filled', 'standard', 'outlined'] },\n restaurant: { cards: ['flat', 'elevated', 'tinted', 'rule'], eyebrow: ['caps', 'rule', 'small'], header: ['flat', 'shadow', 'line'], fields: ['outlined', 'filled', 'standard'] },\n beauty: { cards: ['tinted', 'flat', 'outlined', 'rule'], eyebrow: ['rule', 'small', 'caps'], header: ['flat', 'line', 'shadow'], fields: ['standard', 'filled', 'outlined'] },\n music: { cards: ['flat', 'rule', 'elevated'], eyebrow: ['caps', 'rule', 'small'], header: ['flat', 'shadow', 'line'], fields: ['filled', 'standard', 'outlined'] },\n}\nconst ANY_BLOCKS = { cards: AI_SITE_CARDS, eyebrow: AI_SITE_EYEBROWS, header: AI_SITE_HEADERS, fields: AI_SITE_FIELDS }\n\n/** The hue family a hue is in: twelve families of thirty degrees, 0 the reds. */\nexport function aiSiteHueFamily(hue: number): number {\n return Math.floor((((hue + 15) % 360) + 360) % 360 / 30)\n}\n\n/** Which of a kind's hue ranges a hue falls in, or -1. */\nfunction rangeOf(hue: number, kind: AiSiteKind): number {\n return kind.look.hues.findIndex(([from, to]) => (from <= to ? hue >= from && hue <= to : hue >= from || hue <= to))\n}\n\n/** The look dimensions two sites are compared by (`ai-site-look.spec.ts`). */\nexport const AI_SITE_LOOK_DIMENSIONS = [\n 'base',\n 'hueFamily',\n 'fonts',\n 'buttons',\n 'cards',\n 'corners',\n 'ground',\n 'eyebrow',\n 'header',\n 'fields',\n 'headerAlign',\n 'rhythm',\n] as const\n\n/** A style's value on each tracked dimension. */\nexport function aiSiteLookSignature(style: AiSiteStyle): Record<(typeof AI_SITE_LOOK_DIMENSIONS)[number], string> {\n return {\n base: style.base,\n hueFamily: String(aiSiteHueFamily(style.hue)),\n fonts: style.fonts,\n buttons: style.buttons,\n cards: style.cards,\n corners: style.corners,\n ground: style.ground,\n eyebrow: style.eyebrow,\n header: style.header,\n fields: style.fields,\n headerAlign: style.headerAlign,\n rhythm: style.rhythm,\n }\n}\n\n/**\n * The style tokens for a site of this kind (AGL-3660). Every dimension is\n * the SEED's choice among what suits the kind, with the model's choice for\n * this business as a favored candidate — kept at a given chance, not always\n * — so the brief steers the look and two jobs with the same brief and the\n * same answer still come out as two sites: another base, another hue family,\n * another pairing, other buttons. A brand color the brief gives is always\n * kept.\n */\nexport function aiSiteStyleFor(input: {\n kind: AiSiteKind\n answer: AiSiteLookAnswer\n seed: number\n brand?: string | null\n /**\n * The looks of the workspace's other sites (AGL-3660): a look that shares\n * one's base, hue family, heading font and buttons, or differs from one in\n * fewer than three tracked dimensions, is drawn again from the next seed.\n */\n avoid?: readonly AiSiteStyle[]\n}): AiSiteStyle {\n const avoid = input.avoid ?? []\n if (!avoid.length) return styleOnce(input, input.seed)\n const signatures = avoid.map(aiSiteLookSignature)\n let best: { style: AiSiteStyle; least: number } | null = null\n for (let attempt = 0; attempt < AI_SITE_LOOK_DRAWS; attempt += 1) {\n const style = styleOnce(input, attempt === 0 ? input.seed : (Math.imul(input.seed ^ 0x5bd1e995, attempt + 1) >>> 0))\n const own = aiSiteLookSignature(style)\n const least = Math.min(\n ...signatures.map((other) =>\n TUPLE.every((dimension) => own[dimension] === other[dimension])\n ? -1\n : AI_SITE_LOOK_DIMENSIONS.filter((dimension) => own[dimension] !== other[dimension]).length,\n ),\n )\n if (least >= AI_SITE_LOOK_LEAST_DIFFERENCES) return style\n if (!best || least > best.least) best = { style, least }\n }\n return (best as { style: AiSiteStyle }).style\n}\n\n/** How many seeds a look draws before it settles for the most different. */\nexport const AI_SITE_LOOK_DRAWS = 32\n/** The fewest tracked dimensions in which two of a workspace's sites differ. */\nexport const AI_SITE_LOOK_LEAST_DIFFERENCES = 3\n/** The dimensions no two of a workspace's sites share all of. */\nconst TUPLE = ['base', 'hueFamily', 'fonts', 'buttons'] as const\n\nfunction styleOnce(\n input: { kind: AiSiteKind; answer: AiSiteLookAnswer; brand?: string | null },\n seed: number,\n): AiSiteStyle {\n const { kind, answer } = input\n const next = random(seed)\n const family = kind.look\n const blocks = BLOCK_BIAS[kind.id] ?? ANY_BLOCKS\n /** The model's choice at a chance of `keep`, else the seed's among `options`. */\n const choose = <T,>(model: T | undefined, options: readonly T[], keep: number): T =>\n model !== undefined && next() < keep ? model : pick(next, options)\n\n // The hue: a family among the kind's (the brief's industry), the model's\n // own family favored, and a hue within it.\n const modelRange = answer.hue === undefined ? -1 : rangeOf(answer.hue, kind)\n const keepHue = modelRange !== -1 && next() < 0.3\n const range = keepHue ? modelRange : Math.floor(next() * family.hues.length) % family.hues.length\n const [from, to] = family.hues[range] as readonly [number, number]\n const span = from <= to ? to - from : 360 - from + to\n const hue = keepHue\n ? ((answer.hue as number) + (next() < 0.5 ? -1 : 1) * Math.round(4 + next() * 8) + 360) % 360\n : Math.round(from + next() * span) % 360\n const accentFrom = answer.accent !== undefined && next() < 0.4 ? answer.accent : (hue + pick(next, [30, 150, 180, 210, 330])) % 360\n const accent = (accentFrom + (next() < 0.5 ? -1 : 1) * Math.round(8 + next() * 16) + 360) % 360\n\n const bases = [...new Set([...(answer.base ? [answer.base] : []), ...family.bases])]\n return {\n v: 1,\n kind: kind.id,\n base: choose(answer.base, bases, 0.3),\n seed,\n hue,\n accent,\n chroma: family.chroma,\n ground: choose(answer.ground, family.grounds, 0.35),\n fonts: choose(answer.fonts, family.fonts, 0.3),\n corners: choose(answer.corners, family.corners, 0.35),\n buttons: choose(answer.buttons, [family.buttons, ...AI_SITE_BUTTONS], 0.3),\n cards: choose(answer.cards, blocks.cards, 0.35),\n fields: choose(answer.fields, blocks.fields, 0.35),\n eyebrow: choose(answer.eyebrow, blocks.eyebrow, 0.35),\n header: choose(answer.header, blocks.header, 0.35),\n headerAlign: pick(next, family.headerAligns ?? ['start', 'start', 'center']),\n rhythm: pick(next, family.rhythms ?? AI_SITE_RHYTHMS),\n headingScale: Math.round(family.headingScale * (0.94 + next() * 0.12) * 100) / 100,\n density: family.density === 'regular' && next() < 0.25 ? pick(next, DENSITIES) : family.density,\n brand: aiSiteBrandHex(input.brand) ?? answer.brand ?? null,\n }\n}\n\n// ── Color ────────────────────────────────────────────────────────────────\n\ntype Rgb = [number, number, number]\n\nfunction oklabToLinear(L: number, a: number, b: number): Rgb {\n const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3\n const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3\n const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3\n return [\n 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,\n -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,\n -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s,\n ]\n}\n\nconst toSrgb = (channel: number) =>\n channel <= 0.0031308 ? 12.92 * channel : 1.055 * channel ** (1 / 2.4) - 0.055\nconst fromSrgb = (channel: number) =>\n channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4\n\n/** An OKLCH color as hex, its chroma reduced until it fits sRGB. */\nexport function aiOklchHex(L: number, C: number, h: number): string {\n const lightness = Math.min(1, Math.max(0, L))\n let chroma = Math.max(0, C)\n for (;;) {\n const radians = (h * Math.PI) / 180\n const linear = oklabToLinear(lightness, chroma * Math.cos(radians), chroma * Math.sin(radians))\n const fits = linear.every((channel) => channel >= -0.0005 && channel <= 1.0005)\n if (fits || chroma <= 0) {\n return `#${linear\n .map((channel) => Math.round(Math.min(1, Math.max(0, toSrgb(Math.min(1, Math.max(0, channel))))) * 255))\n .map((value) => value.toString(16).padStart(2, '0'))\n .join('')}`\n }\n chroma = Math.max(0, chroma - 0.004)\n }\n}\n\n/** A hex color in OKLCH. */\nexport function aiHexOklch(hex: string): { L: number; C: number; h: number } {\n const value = hex.replace('#', '')\n const [r, g, b] = [0, 2, 4].map((at) => fromSrgb(parseInt(value.slice(at, at + 2), 16) / 255)) as Rgb\n const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b)\n const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b)\n const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b)\n const L = 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s\n const A = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s\n const B = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s\n return { L, C: Math.hypot(A, B), h: ((Math.atan2(B, A) * 180) / Math.PI + 360) % 360 }\n}\n\nconst ratio = (a: string, b: string) => contrastRatio(a, b) ?? 1\n\n/** The lightness, stepped from `L` toward `toward`, at which `hex(L)` first reaches `min` against `against`. */\nfunction untilContrast(L: number, C: number, h: number, against: string, min: number, toward: 0 | 1): number {\n let lightness = L\n for (let step = 0; step < 60; step += 1) {\n if (ratio(aiOklchHex(lightness, C, h), against) >= min) return lightness\n lightness += toward ? 0.012 : -0.012\n if (lightness <= 0.05 || lightness >= 0.98) break\n }\n return lightness\n}\n\n/** The label color of a fill: white or a deep ink of its hue, whichever reads at 4.5:1, or better. */\nfunction labelOn(fill: string, h: number): string {\n const white = '#ffffff'\n const ink = aiOklchHex(0.2, 0.04, h)\n return ratio(white, fill) >= 4.5 ? white : ratio(ink, fill) >= 4.5 ? ink : ratio(white, fill) > ratio(ink, fill) ? white : '#000000'\n}\n\nconst CHROMA: Record<AiSiteChroma, number> = { neutral: 0.15, muted: 0.085, balanced: 0.135, vivid: 0.185 }\nconst START_L: Record<AiSiteChroma, number> = { neutral: 0.52, muted: 0.48, balanced: 0.52, vivid: 0.56 }\n\n/** Both schemes' colors for a style. */\nexport function aiSiteColors(style: AiSiteStyle): { light: HostThemeSchemeColors; dark: HostThemeSchemeColors } {\n const next = random(style.seed ^ 0x9e3779b9)\n const neutral = style.chroma === 'neutral'\n const brand = style.brand ? aiHexOklch(style.brand) : null\n const h = brand?.h ?? style.hue\n const chroma = brand?.C ?? CHROMA[style.chroma] * (0.9 + next() * 0.2)\n const groundChroma = neutral ? 0.3 : 1\n const white = '#ffffff'\n\n // The page grounds.\n const grounds: Record<AiSiteGround, { L: number; C: number; h: number; paper: [number, number] }> = {\n white: { L: 0.985, C: 0.004, h, paper: [1, 0] },\n warm: { L: 0.972, C: 0.016, h: 78, paper: [0.993, 0.007] },\n cool: { L: 0.974, C: 0.009, h: 250, paper: [1, 0] },\n tinted: { L: 0.968, C: 0.02, h, paper: [0.994, 0.006] },\n }\n const ground = grounds[style.ground]\n const background = aiOklchHex(ground.L, ground.C * groundChroma, ground.h)\n const paper = aiOklchHex(ground.paper[0], ground.paper[1] * groundChroma, ground.h)\n\n // The brand color: a button label reads on it, so it reads on the page too.\n let primaryMain: string\n let primaryL: number\n if (brand && ratio(white, style.brand as string) >= 4.5) {\n primaryMain = style.brand as string\n primaryL = brand.L\n } else {\n primaryL = untilContrast(brand ? Math.min(brand.L, START_L[style.chroma]) : START_L[style.chroma] + (next() - 0.5) * 0.06, chroma, h, white, 4.6, 0)\n primaryMain = aiOklchHex(primaryL, chroma, h)\n }\n const accentChroma = neutral ? 0.17 : Math.max(0.07, chroma * 0.95)\n\n // The secondary color fills a button ON a brand band, so it stands apart from the brand color.\n const secondary = neutral\n ? { main: aiOklchHex(0.24, 0.012, h), h }\n : (() => {\n // A light wash of the accent rather than the accent at full strength:\n // it reads on the brand color without fighting it.\n const washChroma = Math.min(accentChroma, 0.08)\n let L = 0.9\n let main = aiOklchHex(L, washChroma, style.accent)\n while (ratio(main, primaryMain) < 3 && L < 0.96) {\n L += 0.02\n main = aiOklchHex(L, washChroma, style.accent)\n }\n return { main, h: style.accent }\n })()\n const tertiaryHue = (style.accent + 60) % 360\n const tertiaryL = untilContrast(0.52, 0.12, tertiaryHue, white, 4.6, 0)\n const tertiary = aiOklchHex(tertiaryL, 0.12, tertiaryHue)\n const textChroma = neutral ? 0.006 : 0.02\n\n const light: HostThemeSchemeColors = {\n primary: {\n main: primaryMain,\n light: aiOklchHex(Math.min(0.92, primaryL + 0.12), chroma, h),\n dark: aiOklchHex(Math.max(0.15, primaryL - 0.1), chroma, h),\n contrastText: labelOn(primaryMain, h),\n },\n secondary: {\n main: secondary.main,\n light: aiOklchHex(0.93, accentChroma * 0.6, secondary.h),\n dark: aiOklchHex(0.42, accentChroma, secondary.h),\n contrastText: labelOn(secondary.main, secondary.h),\n },\n tertiary: {\n main: tertiary,\n light: aiOklchHex(Math.min(0.9, tertiaryL + 0.14), 0.12, tertiaryHue),\n dark: aiOklchHex(Math.max(0.15, tertiaryL - 0.1), 0.12, tertiaryHue),\n contrastText: labelOn(tertiary, tertiaryHue),\n },\n surface: { main: aiOklchHex(0.955, 0.012 * groundChroma, h), contrastText: aiOklchHex(0.22, textChroma, h) },\n background: { default: background, paper },\n text: {\n primary: aiOklchHex(0.22, textChroma, h),\n secondary: aiOklchHex(0.45, textChroma + 0.005, h),\n disabled: aiOklchHex(0.68, 0.01, h),\n },\n tint: {\n primary: aiOklchHex(0.955, neutral ? 0.03 : 0.035, neutral ? style.accent : h),\n secondary: aiOklchHex(0.955, 0.035, style.accent),\n tertiary: aiOklchHex(0.955, 0.03, tertiaryHue),\n },\n divider: aiOklchHex(0.9, 0.012 * groundChroma, h),\n }\n\n const darkGround = style.ground === 'tinted' ? 0.024 : style.ground === 'warm' ? 0.014 : 0.012\n const darkBackground = aiOklchHex(0.17, darkGround * groundChroma, style.ground === 'warm' ? 60 : h)\n const darkPaper = aiOklchHex(0.215, darkGround * groundChroma, style.ground === 'warm' ? 60 : h)\n const darkChroma = Math.min(chroma, 0.14)\n const darkPrimaryL = untilContrast(0.78, darkChroma, h, darkBackground, 4.5, 1)\n const darkPrimary = aiOklchHex(darkPrimaryL, darkChroma, h)\n const darkSecondary = neutral ? aiOklchHex(0.93, 0.01, h) : aiOklchHex(0.45, accentChroma * 0.85, style.accent)\n const darkTertiary = aiOklchHex(0.8, 0.1, tertiaryHue)\n const dark: HostThemeSchemeColors = {\n primary: {\n main: darkPrimary,\n light: aiOklchHex(Math.min(0.94, darkPrimaryL + 0.08), darkChroma, h),\n dark: aiOklchHex(darkPrimaryL - 0.1, darkChroma, h),\n contrastText: labelOn(darkPrimary, h),\n },\n secondary: {\n main: darkSecondary,\n light: aiOklchHex(0.6, accentChroma * 0.7, secondary.h),\n dark: aiOklchHex(0.35, accentChroma * 0.7, secondary.h),\n contrastText: labelOn(darkSecondary, secondary.h),\n },\n tertiary: {\n main: darkTertiary,\n light: aiOklchHex(0.88, 0.08, tertiaryHue),\n dark: aiOklchHex(0.7, 0.1, tertiaryHue),\n contrastText: labelOn(darkTertiary, tertiaryHue),\n },\n surface: { main: aiOklchHex(0.25, 0.014 * groundChroma, h), contrastText: aiOklchHex(0.95, 0.01, h) },\n background: { default: darkBackground, paper: darkPaper },\n text: {\n primary: aiOklchHex(0.95, 0.008, h),\n secondary: aiOklchHex(0.77, 0.014, h),\n disabled: aiOklchHex(0.52, 0.01, h),\n },\n tint: {\n primary: aiOklchHex(0.27, 0.05, neutral ? style.accent : h),\n secondary: aiOklchHex(0.27, 0.05, style.accent),\n tertiary: aiOklchHex(0.27, 0.04, tertiaryHue),\n },\n divider: aiOklchHex(0.32, 0.015 * groundChroma, h),\n }\n return { light, dark }\n}\n\n// ── The theme ────────────────────────────────────────────────────────────\n\nconst RADIUS: Record<AiSiteCorners, number> = { sharp: 2, soft: 6, round: 12, pill: 18 }\nconst SPACING: Record<AiSiteDensity, number> = { compact: 7, regular: 8, airy: 9 }\n\n/** How much of the heading scale each style takes: a display line grows most, small headings not at all. */\nconst SCALE_SHARE: Partial<Record<HostThemeTypographyVariantKey, { size: number; share: number }>> = {\n displayXl: { size: 4, share: 1.2 },\n h1: { size: 3.25, share: 1 },\n h2: { size: 2.25, share: 0.8 },\n h3: { size: 1.75, share: 0.5 },\n h4: { size: 1.5, share: 0.3 },\n h5: { size: 1.25, share: 0 },\n h6: { size: 1.125, share: 0 },\n}\n\nconst rem = (value: number) => `${Math.round(value * 1000) / 1000}rem`\n\n/** The type a style sets: headings at its scale, weight and tracking, and the eyebrow and button styles. */\nfunction typographyFor(style: AiSiteStyle): HostTheme['typography'] {\n const pairing = aiSiteFontPairing(style.fonts) ?? (AI_SITE_FONT_PAIRINGS[0] as NonNullable<ReturnType<typeof aiSiteFontPairing>>)\n const variants: Partial<Record<HostThemeTypographyVariantKey, HostThemeTypographyVariant>> = {\n ...(DEFAULT_SITE_THEME.typography?.variants ?? {}),\n }\n for (const [key, { size, share }] of Object.entries(SCALE_SHARE) as Array<[HostThemeTypographyVariantKey, { size: number; share: number }]>) {\n const big = key === 'displayXl' || key === 'h1' || key === 'h2'\n const variant: HostThemeTypographyVariant = {\n fontSize: rem(size * (1 + (style.headingScale - 1) * share) * (pairing.caps && big ? 0.92 : 1)),\n fontWeight: big ? pairing.heading.weight : pairing.heading.sub,\n lineHeight: big ? (pairing.caps ? 1.05 : 1.1) : 1.25,\n }\n if (pairing.tracking !== undefined && (big || key === 'h3')) variant.letterSpacing = `${pairing.tracking}em`\n if (pairing.caps && (big || key === 'h3')) variant.textTransform = 'uppercase'\n variants[key] = variant\n }\n const bodyBold = pairing.body.weights.includes(600) ? 600 : 700\n variants.overline =\n style.eyebrow === 'small'\n ? { fontSize: '0.875rem', fontWeight: bodyBold, letterSpacing: '0.01em', textTransform: 'none' }\n : { fontSize: '0.78rem', fontWeight: 700, letterSpacing: style.eyebrow === 'rule' ? '0.16em' : '0.12em', textTransform: 'uppercase' }\n variants.button = {\n fontWeight: style.buttons === 'caps' ? 700 : bodyBold,\n textTransform: style.buttons === 'caps' ? 'uppercase' : 'none',\n ...(style.buttons === 'caps' ? { letterSpacing: '0.06em' } : {}),\n }\n return { variants }\n}\n\n/** The card's look, in theme terms only: palette paths, shadow indexes and border widths. */\nfunction cardSx(cards: AiSiteCards): Record<string, unknown> {\n switch (cards) {\n case 'flat':\n return { boxShadow: 0, border: 0, bgcolor: 'surface.main' }\n case 'outlined':\n return { boxShadow: 0, border: 1, borderColor: 'divider', bgcolor: 'background.paper' }\n case 'elevated':\n return { boxShadow: 3, border: 0, bgcolor: 'background.paper' }\n case 'tinted':\n return { boxShadow: 0, border: 0, bgcolor: 'tint.primary' }\n case 'rule':\n return { boxShadow: 0, border: 0, borderTop: 3, borderColor: 'primary.main', borderRadius: 0, bgcolor: 'background.paper' }\n }\n}\n\n/** The component defaults and styles a style sets: buttons, cards, fields, eyebrows, the header bar and the FAQ. */\nfunction componentsFor(style: AiSiteStyle): Record<string, HostThemeComponentOverride> {\n const radius = RADIUS[style.corners]\n const buttonRadius = style.buttons === 'pill' ? 999 : style.buttons === 'square' ? 2 : radius\n const card = cardSx(style.cards)\n return {\n MuiButton: {\n defaultProps: { disableElevation: true },\n // 44px: the touch target a visitor's thumb needs.\n styleOverrides: { root: { borderRadius: buttonRadius, minHeight: 44, boxShadow: 'none' } },\n ...(style.buttons === 'link'\n ? {\n variants: [\n {\n props: { variant: 'text' },\n style: { textDecoration: 'underline', textUnderlineOffset: '0.3em', textDecorationThickness: '2px' },\n },\n ],\n }\n : {}),\n },\n MuiCard: {\n defaultProps:\n style.cards === 'outlined'\n ? { variant: 'outlined' }\n : { variant: 'elevation', elevation: style.cards === 'elevated' ? 3 : 0 },\n styleOverrides: { root: { borderRadius: style.cards === 'rule' ? 0 : Math.max(radius, 4) } },\n sx: { root: card },\n },\n MuiAccordion: {\n defaultProps: { disableGutters: true, elevation: 0 },\n sx: {\n root: {\n ...card,\n borderTop: style.cards === 'rule' ? 1 : card['borderTop'] ?? card['border'],\n '&::before': { display: 'none' },\n '&:not(:last-of-type)': { mb: 1 },\n },\n },\n },\n MuiTextField: { defaultProps: { variant: style.fields } },\n MuiOutlinedInput: { styleOverrides: { root: { borderRadius: radius } } },\n MuiFilledInput: { styleOverrides: { root: { borderTopLeftRadius: radius, borderTopRightRadius: radius } } },\n MuiChip: { styleOverrides: { root: { borderRadius: style.corners === 'sharp' ? 2 : 999 } } },\n MuiAppBar: {\n defaultProps: { elevation: 0 },\n variants: [\n {\n props: { color: 'inherit' },\n sx:\n style.header === 'line'\n ? { boxShadow: 0, borderBottom: 1, borderColor: 'divider' }\n : style.header === 'shadow'\n ? { boxShadow: 2, borderBottom: 0 }\n : { boxShadow: 0, borderBottom: 0 },\n },\n ],\n },\n ...(style.eyebrow === 'rule'\n ? {\n MuiTypography: {\n variants: [\n {\n props: { variant: 'overline' },\n // A short line in the eyebrow's own color, so it reads on any band.\n style: {\n '&::before': {\n content: '\"\"',\n display: 'inline-block',\n width: '1.75em',\n height: '2px',\n marginRight: '0.75em',\n verticalAlign: 'middle',\n backgroundColor: 'currentColor',\n },\n },\n },\n ],\n },\n }\n : {}),\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\n/** `over` merged into `under`, objects key by key, anything else replaced. */\nfunction merged<T>(under: T, over: unknown): T {\n if (!isRecord(under) || !isRecord(over)) return (over === undefined ? under : over) as T\n const out: Record<string, unknown> = { ...under }\n for (const [key, value] of Object.entries(over)) out[key] = key in out ? merged(out[key], value) : value\n return out as T\n}\n\n/** Whether a theme passes the publish check and the brand-on-page contrast the doctrine asks. */\nfunction themeReads(theme: HostTheme): boolean {\n if (!validateThemeForPublish(theme).ok) return false\n for (const scheme of ['light', 'dark'] as const) {\n const colors = theme.colorSchemes?.[scheme]\n const main = colors?.primary?.main\n const page = colors?.background?.default\n if (!main || !page || ratio(main, page) < 3) return false\n for (const key of ['primary', 'secondary', 'tertiary'] as const) {\n const fill = colors?.[key]\n if (fill?.main && fill.contrastText && ratio(fill.contrastText, fill.main) < 4.5) return false\n }\n }\n return true\n}\n\n/**\n * The site's theme: the base theme with this style layered over it. Colors,\n * type, corners, spacing and the building blocks' component styles are the\n * site's own; whatever the base sets beyond them — its focus rings, its menu\n * and dialog styles, its control heights — stays the base's.\n */\nexport function aiSiteTheme(style: AiSiteStyle, base: HostTheme): HostTheme {\n const pairing = aiSiteFontPairing(style.fonts) ?? (AI_SITE_FONT_PAIRINGS[0] as NonNullable<ReturnType<typeof aiSiteFontPairing>>)\n const colors = aiSiteColors(style)\n const keep = (scheme: 'light' | 'dark') => {\n const own = base.colorSchemes?.[scheme] ?? {}\n // The status colors stay the base's: they mean the same thing on every site.\n return {\n ...(own.error ? { error: own.error } : {}),\n ...(own.warning ? { warning: own.warning } : {}),\n ...(own.info ? { info: own.info } : {}),\n ...(own.success ? { success: own.success } : {}),\n ...colors[scheme],\n }\n }\n let theme: HostTheme = {\n ...base,\n colorSchemes: { light: keep('light'), dark: keep('dark') },\n typography: merged(base.typography ?? {}, typographyFor(style)),\n shape: { ...(base.shape ?? {}), borderRadius: RADIUS[style.corners] },\n spacing: SPACING[style.density],\n components: merged(base.components ?? {}, componentsFor(style)),\n }\n delete theme.darkScheme\n const sameFamily = pairing.heading.family === pairing.body.family\n theme = writeThemeFonts(theme, {\n body: { family: pairing.body.family, category: pairing.body.category, weights: [...pairing.body.weights], source: 'google' },\n heading: sameFamily\n ? null\n : {\n family: pairing.heading.family,\n category: pairing.heading.category,\n weights: [...new Set([pairing.heading.weight, pairing.heading.sub])].sort((a, b) => a - b),\n source: 'google',\n },\n })\n // A pairing whose heading is the body family loads the heading weights too.\n if (sameFamily && theme.fonts?.[0]) {\n theme.fonts[0] = {\n ...theme.fonts[0],\n weights: [...new Set([...(theme.fonts[0].weights ?? []), pairing.heading.weight, pairing.heading.sub])].sort((a, b) => a - b),\n }\n }\n if (!themeReads(theme)) {\n // Never a theme that fails the reading checks: the starter's colors, with everything else kept.\n theme = { ...theme, colorSchemes: DEFAULT_SITE_THEME.colorSchemes }\n }\n return theme\n}\n"],"names":["contrastRatio","validateThemeForPublish","DEFAULT_SITE_THEME","writeThemeFonts","AI_SITE_BASES","AI_SITE_CORNERS","AI_SITE_FONT_PAIRINGS","AI_SITE_GROUNDS","AI_SITE_RHYTHMS","aiSiteFontPairing","AI_SITE_CARDS","AI_SITE_FIELDS","AI_SITE_EYEBROWS","AI_SITE_HEADERS","AI_SITE_BUTTONS","DENSITIES","aiSiteSeed","jobId","hash","index","length","charCodeAt","Math","imul","random","seed","state","t","pick","next","list","floor","AI_SITE_LOOK_TOOL_NAME","enumOf","values","description","type","enum","AI_SITE_LOOK_TOOL","name","strict","inputSchema","additionalProperties","required","properties","base","hue","accent","ground","fonts","map","pairing","id","corners","buttons","cards","fields","eyebrow","header","brand","anyOf","oneOf","value","includes","undefined","hueOf","Number","isFinite","round","aiSiteBrandHex","match","exec","trim","hex","full","digit","join","toLowerCase","aiReadSiteLook","answer","raw","look","BLOCK_BIAS","portfolio","studio","photography","blog","trades","fitness","professional","wellness","yoga","restaurant","beauty","music","ANY_BLOCKS","aiSiteHueFamily","rangeOf","kind","hues","findIndex","from","to","AI_SITE_LOOK_DIMENSIONS","aiSiteLookSignature","style","hueFamily","String","headerAlign","rhythm","aiSiteStyleFor","input","avoid","styleOnce","signatures","best","attempt","AI_SITE_LOOK_DRAWS","own","least","min","other","TUPLE","every","dimension","filter","AI_SITE_LOOK_LEAST_DIFFERENCES","family","blocks","choose","model","options","keep","modelRange","keepHue","range","span","accentFrom","bases","Set","v","chroma","grounds","headerAligns","rhythms","headingScale","density","oklabToLinear","L","a","b","l","m","s","toSrgb","channel","fromSrgb","aiOklchHex","C","h","lightness","max","radians","PI","linear","cos","sin","fits","toString","padStart","aiHexOklch","replace","r","g","at","parseInt","slice","cbrt","A","B","hypot","atan2","ratio","untilContrast","against","toward","step","labelOn","fill","white","ink","CHROMA","neutral","muted","balanced","vivid","START_L","aiSiteColors","groundChroma","paper","warm","cool","tinted","background","primaryMain","primaryL","accentChroma","secondary","main","washChroma","tertiaryHue","tertiaryL","tertiary","textChroma","light","primary","dark","contrastText","surface","default","text","disabled","tint","divider","darkGround","darkBackground","darkPaper","darkChroma","darkPrimaryL","darkPrimary","darkSecondary","darkTertiary","RADIUS","sharp","soft","pill","SPACING","compact","regular","airy","SCALE_SHARE","displayXl","size","share","h1","h2","h3","h4","h5","h6","rem","typographyFor","variants","typography","key","Object","entries","big","variant","fontSize","caps","fontWeight","heading","weight","sub","lineHeight","tracking","letterSpacing","textTransform","bodyBold","body","weights","overline","button","cardSx","boxShadow","border","bgcolor","borderColor","borderTop","borderRadius","componentsFor","card","radius","buttonRadius","MuiButton","defaultProps","disableElevation","styleOverrides","root","minHeight","props","textDecoration","textUnderlineOffset","textDecorationThickness","MuiCard","elevation","sx","MuiAccordion","disableGutters","display","mb","MuiTextField","MuiOutlinedInput","MuiFilledInput","borderTopLeftRadius","borderTopRightRadius","MuiChip","MuiAppBar","color","borderBottom","MuiTypography","content","width","height","marginRight","verticalAlign","backgroundColor","isRecord","Array","isArray","merged","under","over","out","themeReads","theme","ok","scheme","colors","colorSchemes","page","aiSiteTheme","error","warning","info","success","shape","spacing","components","darkScheme","sameFamily","category","source","sort"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,aAAa,EACbC,uBAAuB,QAClB,oCAAmC;AAC1C,SAASC,kBAAkB,QAAQ,sCAAqC;AAQxE,SAASC,eAAe,QAAQ,kDAAiD;AAEjF,SACEC,aAAa,EACbC,eAAe,EACfC,qBAAqB,EACrBC,eAAe,EACfC,eAAe,EACfC,iBAAiB,QASZ,qBAAiB;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;CAyBC,GAED,4EAA4E;AAE5E,yBAAyB,GACzB,OAAO,MAAMC,gBAAgB;IAAC;IAAQ;IAAY;IAAY;IAAU;CAAO,CAAS;AAExF,0BAA0B,GAC1B,OAAO,MAAMC,iBAAiB;IAAC;IAAY;IAAU;CAAW,CAAS;AAEzE,2CAA2C,GAC3C,OAAO,MAAMC,mBAAmB;IAAC;IAAQ;IAAS;CAAO,CAAS;AAElE,+CAA+C,GAC/C,OAAO,MAAMC,kBAAkB;IAAC;IAAQ;IAAU;CAAO,CAAS;AAElE,8EAA8E,GAC9E,OAA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N,OAAO,CAACvI,MAAM;YAC9BuN,UAAUnS,QAAQmN,OAAO,CAACgF,QAAQ;YAClCvE,SAAS;mBAAI,IAAIpI,IAAI;oBAACxF,QAAQmN,OAAO,CAACC,MAAM;oBAAEpN,QAAQmN,OAAO,CAACE,GAAG;iBAAC;aAAE,CAACgF,IAAI,CAAC,CAACnM,GAAGC,IAAMD,IAAIC;YACxFiM,QAAQ;QACV;IACN;IACA,4EAA4E;IAC5E,IAAIF,gBAAcf,eAAAA,MAAMrR,KAAK,qBAAXqR,YAAa,CAAC,EAAE,GAAE;YAGNA;QAF5BA,MAAMrR,KAAK,CAAC,EAAE,GAAG,aACZqR,MAAMrR,KAAK,CAAC,EAAE;YACjB8N,SAAS;mBAAI,IAAIpI,IAAI;wBAAK2L,wBAAAA,MAAMrR,KAAK,CAAC,EAAE,CAAC8N,OAAO,YAAtBuD,wBAA0B,EAAE;oBAAGnR,QAAQmN,OAAO,CAACC,MAAM;oBAAEpN,QAAQmN,OAAO,CAACE,GAAG;iBAAC;aAAE,CAACgF,IAAI,CAAC,CAACnM,GAAGC,IAAMD,IAAIC;;IAE/H;IACA,IAAI,CAAC+K,WAAWC,QAAQ;QACtB,gGAAgG;QAChGA,QAAQ,aAAKA;YAAOI,cAAcxU,mBAAmBwU,YAAY;;IACnE;IACA,OAAOJ;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/ai-site-look.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n contrastRatio,\n validateThemeForPublish,\n} from '@aglyn/aglyn/app-utils/site-theme'\nimport { DEFAULT_SITE_THEME } from '@aglyn/aglyn/app-utils/default-site'\nimport type {\n HostTheme,\n HostThemeComponentOverride,\n HostThemeSchemeColors,\n HostThemeTypographyVariant,\n HostThemeTypographyVariantKey,\n} from '@aglyn/shared-data-types'\nimport { writeThemeFonts } from '@aglyn/shared-ui-theme/util/theme-editor-fields'\nimport type { AiTool } from '../runtime/ai-runtime'\nimport {\n AI_SITE_BASES,\n AI_SITE_CORNERS,\n AI_SITE_FONT_PAIRINGS,\n AI_SITE_GROUNDS,\n AI_SITE_RHYTHMS,\n aiSiteFontPairing,\n type AiSiteBase,\n type AiSiteButtons,\n type AiSiteChroma,\n type AiSiteCorners,\n type AiSiteDensity,\n type AiSiteGround,\n type AiSiteKind,\n type AiSiteRhythm,\n} from './ai-site-kinds'\n\n/**\n * A site's look (AGL-3660): one of the platform's base themes, and this\n * site's own customizations layered over it as the site theme's override —\n * the same base-and-edits shape a person's pick on Setup → Theme is stored\n * as, so the Theme page names the base it came from and every edit there\n * starts from what the AI chose.\n *\n * Everything the look decides lives in the THEME, never on a node: palette,\n * fonts, type scale, corners, spacing, and the component defaults and styles\n * of buttons, cards, fields, eyebrows, the header bar and the FAQ. So a Card\n * or a Button a person drags in later looks like the rest of the site, and\n * the layout compiler emits plain components.\n *\n * Three inputs decide it:\n * - the KIND (`ai-site-kinds.ts`): the family of looks that suit the site;\n * - the MODEL's choices for this business (`submit_site_look`), any of\n * which may be missing;\n * - the per-job SEED, which fills what the model left out from the kind's\n * options and nudges every hue, chroma and size, so two jobs with the same\n * brief and the same answers still produce two different themes.\n *\n * Colors are built in OKLCH and held to WCAG: body text 4.5:1 on its ground\n * and on paper, every button label 4.5:1 on its fill, the brand color 3:1 on\n * the page — then the whole theme passes `validateThemeForPublish`, or its\n * colors fall back to the starter theme's.\n */\n\n// ── The tokens ───────────────────────────────────────────────────────────\n\n/** How cards are drawn. */\nexport const AI_SITE_CARDS = ['flat', 'outlined', 'elevated', 'tinted', 'rule'] as const\nexport type AiSiteCards = (typeof AI_SITE_CARDS)[number]\n/** The form field style. */\nexport const AI_SITE_FIELDS = ['outlined', 'filled', 'standard'] as const\nexport type AiSiteFields = (typeof AI_SITE_FIELDS)[number]\n/** How an eyebrow above a heading is set. */\nexport const AI_SITE_EYEBROWS = ['caps', 'small', 'rule'] as const\nexport type AiSiteEyebrow = (typeof AI_SITE_EYEBROWS)[number]\n/** What sets a plain header bar off the page. */\nexport const AI_SITE_HEADERS = ['line', 'shadow', 'flat'] as const\nexport type AiSiteHeader = (typeof AI_SITE_HEADERS)[number]\n/** Button shapes and casing; `link` draws quiet buttons as underlined links. */\nexport const AI_SITE_BUTTONS: readonly AiSiteButtons[] = ['rounded', 'pill', 'square', 'caps', 'link']\nconst DENSITIES: readonly AiSiteDensity[] = ['compact', 'regular', 'airy']\n\n/**\n * A site's style tokens: everything its theme was built from. Stored with the\n * site (`hosts/{id}.siteStyle`) so a later AI edit keeps the look.\n */\nexport interface AiSiteStyle {\n v: 1\n kind: string\n base: AiSiteBase\n seed: number\n hue: number\n accent: number\n chroma: AiSiteChroma\n ground: AiSiteGround\n fonts: string\n corners: AiSiteCorners\n buttons: AiSiteButtons\n cards: AiSiteCards\n fields: AiSiteFields\n eyebrow: AiSiteEyebrow\n header: AiSiteHeader\n /** The header's arrangement: brand at the start and links after it, or both centered. */\n headerAlign: 'start' | 'center'\n /** How the pages alternate their bands. */\n rhythm: AiSiteRhythm\n headingScale: number\n density: AiSiteDensity\n /** A brand color the brief gave, used as the primary color. */\n brand: string | null\n}\n\n/** What the model may choose, every field optional. */\nexport type AiSiteLookAnswer = Partial<\n Pick<\n AiSiteStyle,\n 'base' | 'hue' | 'accent' | 'ground' | 'fonts' | 'corners' | 'buttons' | 'cards' | 'fields' | 'eyebrow' | 'header' | 'brand'\n >\n>\n\n// ── The seed ─────────────────────────────────────────────────────────────\n\n/** A job's seed: FNV-1a over its id. */\nexport function aiSiteSeed(jobId: string): number {\n let hash = 0x811c9dc5\n for (let index = 0; index < jobId.length; index += 1) {\n hash ^= jobId.charCodeAt(index)\n hash = Math.imul(hash, 0x01000193)\n }\n return hash >>> 0\n}\n\n/** A small deterministic generator over a seed (mulberry32). */\nfunction random(seed: number): () => number {\n let state = seed >>> 0\n return () => {\n state = (state + 0x6d2b79f5) >>> 0\n let t = state\n t = Math.imul(t ^ (t >>> 15), t | 1)\n t ^= t + Math.imul(t ^ (t >>> 7), t | 61)\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296\n }\n}\n\nconst pick = <T,>(next: () => number, list: readonly T[]): T => list[Math.floor(next() * list.length) % list.length] as T\n\n// ── The model's answer ───────────────────────────────────────────────────\n\nexport const AI_SITE_LOOK_TOOL_NAME = 'submit_site_look'\n\nconst enumOf = (values: readonly string[], description: string) => ({ type: 'string', enum: [...values], description })\n\n/** The strict tool the look is answered with; every field is required and the reader is lenient. */\nexport const AI_SITE_LOOK_TOOL: AiTool = {\n name: AI_SITE_LOOK_TOOL_NAME,\n description: \"Submit this website's look: the base theme it starts from and the choices that make it this business's own.\",\n strict: true,\n inputSchema: {\n type: 'object',\n additionalProperties: false,\n required: ['base', 'hue', 'accent', 'ground', 'fonts', 'corners', 'buttons', 'cards', 'fields', 'eyebrow', 'header', 'brand'],\n properties: {\n base: enumOf(AI_SITE_BASES, 'The base theme to start from, from the list in the request.'),\n hue: { type: 'integer', description: 'The brand color as a hue from 0 to 359 (0 red, 30 orange, 55 gold, 140 green, 190 teal, 220 blue, 270 violet, 330 pink).' },\n accent: { type: 'integer', description: 'The accent color as a hue from 0 to 359, chosen to sit well beside the brand hue.' },\n ground: enumOf(AI_SITE_GROUNDS, 'The page background: white, warm (cream), cool (gray-blue) or tinted (a whisper of the brand color).'),\n fonts: enumOf(AI_SITE_FONT_PAIRINGS.map((pairing) => pairing.id), 'A font pairing from the list in the request.'),\n corners: enumOf(AI_SITE_CORNERS, 'Corner rounding for cards and fields.'),\n buttons: enumOf(AI_SITE_BUTTONS, 'Buttons: rounded, pill, square, caps (capitals) or link (quiet buttons drawn as underlined links).'),\n cards: enumOf(AI_SITE_CARDS, 'Cards: flat, outlined, elevated (a soft shadow), tinted (a wash of the brand color) or rule (a colored line on top).'),\n fields: enumOf(AI_SITE_FIELDS, 'Form fields: outlined, filled or standard (underlined).'),\n eyebrow: enumOf(AI_SITE_EYEBROWS, 'The small label above headings: caps (spaced capitals), small (quiet small text) or rule (capitals after a short line).'),\n header: enumOf(AI_SITE_HEADERS, 'What sets the header bar off the page: a line, a shadow, or flat.'),\n brand: { anyOf: [{ type: 'string' }, { type: 'null' }], description: 'A hex brand color the brief gives, exactly as written, or null.' },\n },\n },\n}\n\nconst oneOf = <T extends string>(value: unknown, values: readonly T[]): T | undefined =>\n typeof value === 'string' && (values as readonly string[]).includes(value) ? (value as T) : undefined\n\nconst hueOf = (value: unknown): number | undefined =>\n typeof value === 'number' && Number.isFinite(value) ? ((Math.round(value) % 360) + 360) % 360 : undefined\n\n/** A brand color as a six-digit hex, or `null`. */\nexport function aiSiteBrandHex(value: unknown): string | null {\n if (typeof value !== 'string') return null\n const match = /#?([0-9a-f]{6}|[0-9a-f]{3})\\b/i.exec(value.trim())\n if (!match) return null\n const hex = match[1] as string\n const full = hex.length === 3 ? [...hex].map((digit) => digit + digit).join('') : hex\n return `#${full.toLowerCase()}`\n}\n\n/** The model's answer, read leniently: a value outside its vocabulary is left for the seed. */\nexport function aiReadSiteLook(answer: unknown): AiSiteLookAnswer {\n const raw = (answer && typeof answer === 'object' ? answer : {}) as Record<string, unknown>\n const look: AiSiteLookAnswer = {}\n const base = oneOf(raw['base'], AI_SITE_BASES)\n if (base) look.base = base\n const hue = hueOf(raw['hue'])\n if (hue !== undefined) look.hue = hue\n const accent = hueOf(raw['accent'])\n if (accent !== undefined) look.accent = accent\n const ground = oneOf(raw['ground'], AI_SITE_GROUNDS)\n if (ground) look.ground = ground\n if (aiSiteFontPairing(raw['fonts'])) look.fonts = raw['fonts'] as string\n const corners = oneOf(raw['corners'], AI_SITE_CORNERS)\n if (corners) look.corners = corners\n const buttons = oneOf(raw['buttons'], AI_SITE_BUTTONS)\n if (buttons) look.buttons = buttons\n const cards = oneOf(raw['cards'], AI_SITE_CARDS)\n if (cards) look.cards = cards\n const fields = oneOf(raw['fields'], AI_SITE_FIELDS)\n if (fields) look.fields = fields\n const eyebrow = oneOf(raw['eyebrow'], AI_SITE_EYEBROWS)\n if (eyebrow) look.eyebrow = eyebrow\n const header = oneOf(raw['header'], AI_SITE_HEADERS)\n if (header) look.header = header\n const brand = aiSiteBrandHex(raw['brand'])\n if (brand) look.brand = brand\n return look\n}\n\n// ── Kind, model and seed into tokens ─────────────────────────────────────\n\n/** The building-block styles a kind leans to, before the model or the seed choose. */\nconst BLOCK_BIAS: Partial<\n Record<string, { cards: readonly AiSiteCards[]; eyebrow: readonly AiSiteEyebrow[]; header: readonly AiSiteHeader[]; fields: readonly AiSiteFields[] }>\n> = {\n portfolio: { cards: ['rule', 'flat', 'outlined'], eyebrow: ['small', 'rule', 'caps'], header: ['flat', 'line', 'shadow'], fields: ['standard', 'outlined', 'filled'] },\n studio: { cards: ['flat', 'rule', 'outlined'], eyebrow: ['rule', 'small', 'caps'], header: ['flat', 'line', 'shadow'], fields: ['standard', 'outlined', 'filled'] },\n photography: { cards: ['flat', 'rule', 'outlined'], eyebrow: ['small', 'rule', 'caps'], header: ['flat', 'line', 'shadow'], fields: ['standard', 'outlined', 'filled'] },\n blog: { cards: ['rule', 'outlined', 'flat', 'tinted'], eyebrow: ['small', 'caps', 'rule'], header: ['line', 'flat', 'shadow'], fields: ['outlined', 'standard', 'filled'] },\n trades: { cards: ['elevated', 'outlined', 'rule', 'flat', 'tinted'], eyebrow: ['caps', 'rule', 'small'], header: ['shadow', 'line', 'flat'], fields: ['outlined', 'filled', 'standard'] },\n fitness: { cards: ['elevated', 'flat', 'rule', 'outlined'], eyebrow: ['caps', 'rule', 'small'], header: ['shadow', 'flat', 'line'], fields: ['filled', 'outlined', 'standard'] },\n professional: { cards: ['outlined', 'rule', 'flat', 'elevated'], eyebrow: ['caps', 'rule', 'small'], header: ['line', 'flat', 'shadow'], fields: ['outlined', 'standard', 'filled'] },\n wellness: { cards: ['tinted', 'flat', 'elevated', 'outlined'], eyebrow: ['small', 'caps', 'rule'], header: ['flat', 'line', 'shadow'], fields: ['filled', 'outlined', 'standard'] },\n yoga: { cards: ['tinted', 'flat', 'outlined'], eyebrow: ['small', 'rule', 'caps'], header: ['flat', 'line', 'shadow'], fields: ['filled', 'standard', 'outlined'] },\n restaurant: { cards: ['flat', 'elevated', 'tinted', 'rule'], eyebrow: ['caps', 'rule', 'small'], header: ['flat', 'shadow', 'line'], fields: ['outlined', 'filled', 'standard'] },\n beauty: { cards: ['tinted', 'flat', 'outlined', 'rule'], eyebrow: ['rule', 'small', 'caps'], header: ['flat', 'line', 'shadow'], fields: ['standard', 'filled', 'outlined'] },\n music: { cards: ['flat', 'rule', 'elevated'], eyebrow: ['caps', 'rule', 'small'], header: ['flat', 'shadow', 'line'], fields: ['filled', 'standard', 'outlined'] },\n}\nconst ANY_BLOCKS = { cards: AI_SITE_CARDS, eyebrow: AI_SITE_EYEBROWS, header: AI_SITE_HEADERS, fields: AI_SITE_FIELDS }\n\n/** The hue family a hue is in: twelve families of thirty degrees, 0 the reds. */\nexport function aiSiteHueFamily(hue: number): number {\n return Math.floor((((hue + 15) % 360) + 360) % 360 / 30)\n}\n\n/** Which of a kind's hue ranges a hue falls in, or -1. */\nfunction rangeOf(hue: number, kind: AiSiteKind): number {\n return kind.look.hues.findIndex(([from, to]) => (from <= to ? hue >= from && hue <= to : hue >= from || hue <= to))\n}\n\n/** The look dimensions two sites are compared by (`ai-site-look.spec.ts`). */\nexport const AI_SITE_LOOK_DIMENSIONS = [\n 'base',\n 'hueFamily',\n 'fonts',\n 'buttons',\n 'cards',\n 'corners',\n 'ground',\n 'eyebrow',\n 'header',\n 'fields',\n 'headerAlign',\n 'rhythm',\n] as const\n\n/** A style's value on each tracked dimension. */\nexport function aiSiteLookSignature(style: AiSiteStyle): Record<(typeof AI_SITE_LOOK_DIMENSIONS)[number], string> {\n return {\n base: style.base,\n hueFamily: String(aiSiteHueFamily(style.hue)),\n fonts: style.fonts,\n buttons: style.buttons,\n cards: style.cards,\n corners: style.corners,\n ground: style.ground,\n eyebrow: style.eyebrow,\n header: style.header,\n fields: style.fields,\n headerAlign: style.headerAlign,\n rhythm: style.rhythm,\n }\n}\n\n/**\n * The style tokens for a site of this kind (AGL-3660). Every dimension is\n * the SEED's choice among what suits the kind, with the model's choice for\n * this business as a favored candidate — kept at a given chance, not always\n * — so the brief steers the look and two jobs with the same brief and the\n * same answer still come out as two sites: another base, another hue family,\n * another pairing, other buttons. A brand color the brief gives is always\n * kept.\n */\nexport function aiSiteStyleFor(input: {\n kind: AiSiteKind\n answer: AiSiteLookAnswer\n seed: number\n brand?: string | null\n /**\n * The looks of the workspace's other sites (AGL-3660): a look that shares\n * one's base, hue family, heading font and buttons, or differs from one in\n * fewer than three tracked dimensions, is drawn again from the next seed.\n */\n avoid?: readonly AiSiteStyle[]\n}): AiSiteStyle {\n const avoid = input.avoid ?? []\n if (!avoid.length) return styleOnce(input, input.seed)\n const signatures = avoid.map(aiSiteLookSignature)\n let best: { style: AiSiteStyle; least: number } | null = null\n for (let attempt = 0; attempt < AI_SITE_LOOK_DRAWS; attempt += 1) {\n const style = styleOnce(input, attempt === 0 ? input.seed : (Math.imul(input.seed ^ 0x5bd1e995, attempt + 1) >>> 0))\n const own = aiSiteLookSignature(style)\n const least = Math.min(\n ...signatures.map((other) =>\n TUPLE.every((dimension) => own[dimension] === other[dimension])\n ? -1\n : AI_SITE_LOOK_DIMENSIONS.filter((dimension) => own[dimension] !== other[dimension]).length,\n ),\n )\n if (least >= AI_SITE_LOOK_LEAST_DIFFERENCES) return style\n if (!best || least > best.least) best = { style, least }\n }\n return (best as { style: AiSiteStyle }).style\n}\n\n/** How many seeds a look draws before it settles for the most different. */\nexport const AI_SITE_LOOK_DRAWS = 32\n/** The fewest tracked dimensions in which two of a workspace's sites differ. */\nexport const AI_SITE_LOOK_LEAST_DIFFERENCES = 3\n/** The dimensions no two of a workspace's sites share all of. */\nconst TUPLE = ['base', 'hueFamily', 'fonts', 'buttons'] as const\n\nfunction styleOnce(\n input: { kind: AiSiteKind; answer: AiSiteLookAnswer; brand?: string | null },\n seed: number,\n): AiSiteStyle {\n const { kind, answer } = input\n const next = random(seed)\n const family = kind.look\n const blocks = BLOCK_BIAS[kind.id] ?? ANY_BLOCKS\n /** The model's choice at a chance of `keep`, else the seed's among `options`. */\n const choose = <T,>(model: T | undefined, options: readonly T[], keep: number): T =>\n model !== undefined && next() < keep ? model : pick(next, options)\n\n // The hue: a family among the kind's (the brief's industry), the model's\n // own family favored, and a hue within it.\n const modelRange = answer.hue === undefined ? -1 : rangeOf(answer.hue, kind)\n const keepHue = modelRange !== -1 && next() < 0.3\n const range = keepHue ? modelRange : Math.floor(next() * family.hues.length) % family.hues.length\n const [from, to] = family.hues[range] as readonly [number, number]\n const span = from <= to ? to - from : 360 - from + to\n const hue = keepHue\n ? ((answer.hue as number) + (next() < 0.5 ? -1 : 1) * Math.round(4 + next() * 8) + 360) % 360\n : Math.round(from + next() * span) % 360\n const accentFrom = answer.accent !== undefined && next() < 0.4 ? answer.accent : (hue + pick(next, [30, 150, 180, 210, 330])) % 360\n const accent = (accentFrom + (next() < 0.5 ? -1 : 1) * Math.round(8 + next() * 16) + 360) % 360\n\n const bases = [...new Set([...(answer.base ? [answer.base] : []), ...family.bases])]\n return {\n v: 1,\n kind: kind.id,\n base: choose(answer.base, bases, 0.3),\n seed,\n hue,\n accent,\n chroma: family.chroma,\n ground: choose(answer.ground, family.grounds, 0.35),\n fonts: choose(answer.fonts, family.fonts, 0.3),\n corners: choose(answer.corners, family.corners, 0.35),\n buttons: choose(answer.buttons, [family.buttons, ...AI_SITE_BUTTONS], 0.3),\n cards: choose(answer.cards, blocks.cards, 0.35),\n fields: choose(answer.fields, blocks.fields, 0.35),\n eyebrow: choose(answer.eyebrow, blocks.eyebrow, 0.35),\n header: choose(answer.header, blocks.header, 0.35),\n headerAlign: pick(next, family.headerAligns ?? ['start', 'start', 'center']),\n rhythm: pick(next, family.rhythms ?? AI_SITE_RHYTHMS),\n headingScale: Math.round(family.headingScale * (0.94 + next() * 0.12) * 100) / 100,\n density: family.density === 'regular' && next() < 0.25 ? pick(next, DENSITIES) : family.density,\n brand: aiSiteBrandHex(input.brand) ?? answer.brand ?? null,\n }\n}\n\n// ── Color ────────────────────────────────────────────────────────────────\n\ntype Rgb = [number, number, number]\n\nfunction oklabToLinear(L: number, a: number, b: number): Rgb {\n const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3\n const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3\n const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3\n return [\n 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,\n -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,\n -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s,\n ]\n}\n\nconst toSrgb = (channel: number) =>\n channel <= 0.0031308 ? 12.92 * channel : 1.055 * channel ** (1 / 2.4) - 0.055\nconst fromSrgb = (channel: number) =>\n channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4\n\n/** An OKLCH color as hex, its chroma reduced until it fits sRGB. */\nexport function aiOklchHex(L: number, C: number, h: number): string {\n const lightness = Math.min(1, Math.max(0, L))\n let chroma = Math.max(0, C)\n for (;;) {\n const radians = (h * Math.PI) / 180\n const linear = oklabToLinear(lightness, chroma * Math.cos(radians), chroma * Math.sin(radians))\n const fits = linear.every((channel) => channel >= -0.0005 && channel <= 1.0005)\n if (fits || chroma <= 0) {\n return `#${linear\n .map((channel) => Math.round(Math.min(1, Math.max(0, toSrgb(Math.min(1, Math.max(0, channel))))) * 255))\n .map((value) => value.toString(16).padStart(2, '0'))\n .join('')}`\n }\n chroma = Math.max(0, chroma - 0.004)\n }\n}\n\n/** A hex color in OKLCH. */\nexport function aiHexOklch(hex: string): { L: number; C: number; h: number } {\n const value = hex.replace('#', '')\n const [r, g, b] = [0, 2, 4].map((at) => fromSrgb(parseInt(value.slice(at, at + 2), 16) / 255)) as Rgb\n const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b)\n const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b)\n const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b)\n const L = 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s\n const A = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s\n const B = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s\n return { L, C: Math.hypot(A, B), h: ((Math.atan2(B, A) * 180) / Math.PI + 360) % 360 }\n}\n\nconst ratio = (a: string, b: string) => contrastRatio(a, b) ?? 1\n\n/** The lightness, stepped from `L` toward `toward`, at which `hex(L)` first reaches `min` against `against`. */\nfunction untilContrast(L: number, C: number, h: number, against: string, min: number, toward: 0 | 1): number {\n let lightness = L\n for (let step = 0; step < 60; step += 1) {\n if (ratio(aiOklchHex(lightness, C, h), against) >= min) return lightness\n lightness += toward ? 0.012 : -0.012\n if (lightness <= 0.05 || lightness >= 0.98) break\n }\n return lightness\n}\n\n/** The label color of a fill: white or a deep ink of its hue, whichever reads at 4.5:1, or better. */\nfunction labelOn(fill: string, h: number): string {\n const white = '#ffffff'\n const ink = aiOklchHex(0.2, 0.04, h)\n return ratio(white, fill) >= 4.5 ? white : ratio(ink, fill) >= 4.5 ? ink : ratio(white, fill) > ratio(ink, fill) ? white : '#000000'\n}\n\n/** How far apart two hues sit on the wheel, in degrees: 0 to 180. */\nexport function aiHueGap(a: number, b: number): number {\n const d = Math.abs(a - b) % 360\n return Math.min(d, 360 - d)\n}\n\n/**\n * The widest gap an accent may keep from the brand hue and still color a\n * button beside it (AGL-3660). Past it the accent clashes: a live portfolio of\n * green (hue 131) and magenta (323) showed its outlined buttons as a pink wash\n * and its footer button as purple under green words, on a Cupertino base.\n */\nexport const AI_SITE_ACCENT_CLASH_DEGREES = 60\n\nconst CHROMA: Record<AiSiteChroma, number> = { neutral: 0.15, muted: 0.085, balanced: 0.135, vivid: 0.185 }\nconst START_L: Record<AiSiteChroma, number> = { neutral: 0.52, muted: 0.48, balanced: 0.52, vivid: 0.56 }\n\n/** Both schemes' colors for a style. */\nexport function aiSiteColors(style: AiSiteStyle): { light: HostThemeSchemeColors; dark: HostThemeSchemeColors } {\n const next = random(style.seed ^ 0x9e3779b9)\n const neutral = style.chroma === 'neutral'\n const brand = style.brand ? aiHexOklch(style.brand) : null\n const h = brand?.h ?? style.hue\n const chroma = brand?.C ?? CHROMA[style.chroma] * (0.9 + next() * 0.2)\n const groundChroma = neutral ? 0.3 : 1\n const white = '#ffffff'\n\n // The page grounds.\n const grounds: Record<AiSiteGround, { L: number; C: number; h: number; paper: [number, number] }> = {\n white: { L: 0.985, C: 0.004, h, paper: [1, 0] },\n warm: { L: 0.972, C: 0.016, h: 78, paper: [0.993, 0.007] },\n cool: { L: 0.974, C: 0.009, h: 250, paper: [1, 0] },\n tinted: { L: 0.968, C: 0.02, h, paper: [0.994, 0.006] },\n }\n const ground = grounds[style.ground]\n const background = aiOklchHex(ground.L, ground.C * groundChroma, ground.h)\n const paper = aiOklchHex(ground.paper[0], ground.paper[1] * groundChroma, ground.h)\n\n // The brand color: a button label reads on it, so it reads on the page too.\n let primaryMain: string\n let primaryL: number\n if (brand && ratio(white, style.brand as string) >= 4.5) {\n primaryMain = style.brand as string\n primaryL = brand.L\n } else {\n primaryL = untilContrast(brand ? Math.min(brand.L, START_L[style.chroma]) : START_L[style.chroma] + (next() - 0.5) * 0.06, chroma, h, white, 4.6, 0)\n primaryMain = aiOklchHex(primaryL, chroma, h)\n }\n const accentChroma = neutral ? 0.17 : Math.max(0.07, chroma * 0.95)\n // A button's colors come from the brand hue where the accent clashes with\n // it (AGL-3660); the accent keeps its tint and the tertiary.\n const buttonHue = aiHueGap(style.accent, h) > AI_SITE_ACCENT_CLASH_DEGREES ? h : style.accent\n\n // The secondary color fills a button ON a brand band, so it stands apart from the brand color.\n const secondary = neutral\n ? (() => {\n // Ink or paper, whichever stands further from the brand color (AGL-3660).\n const ink = aiOklchHex(0.24, 0.012, h)\n const paper = aiOklchHex(0.97, 0.008, h)\n return { main: ratio(ink, primaryMain) >= ratio(paper, primaryMain) ? ink : paper, h }\n })()\n : (() => {\n // A light wash of the accent rather than the accent at full strength:\n // it reads on the brand color without fighting it.\n const washChroma = Math.min(accentChroma, 0.08)\n let L = 0.9\n let main = aiOklchHex(L, washChroma, buttonHue)\n while (ratio(main, primaryMain) < 3 && L < 0.96) {\n L += 0.02\n main = aiOklchHex(L, washChroma, buttonHue)\n }\n return { main, h: buttonHue }\n })()\n const tertiaryHue = (style.accent + 60) % 360\n const tertiaryL = untilContrast(0.52, 0.12, tertiaryHue, white, 4.6, 0)\n const tertiary = aiOklchHex(tertiaryL, 0.12, tertiaryHue)\n const textChroma = neutral ? 0.006 : 0.02\n\n const light: HostThemeSchemeColors = {\n primary: {\n main: primaryMain,\n light: aiOklchHex(Math.min(0.92, primaryL + 0.12), chroma, h),\n dark: aiOklchHex(Math.max(0.15, primaryL - 0.1), chroma, h),\n contrastText: labelOn(primaryMain, h),\n },\n secondary: {\n main: secondary.main,\n light: aiOklchHex(0.93, accentChroma * 0.6, secondary.h),\n dark: aiOklchHex(0.42, accentChroma, secondary.h),\n contrastText: labelOn(secondary.main, secondary.h),\n },\n tertiary: {\n main: tertiary,\n light: aiOklchHex(Math.min(0.9, tertiaryL + 0.14), 0.12, tertiaryHue),\n dark: aiOklchHex(Math.max(0.15, tertiaryL - 0.1), 0.12, tertiaryHue),\n contrastText: labelOn(tertiary, tertiaryHue),\n },\n surface: { main: aiOklchHex(0.955, 0.012 * groundChroma, h), contrastText: aiOklchHex(0.22, textChroma, h) },\n background: { default: background, paper },\n text: {\n primary: aiOklchHex(0.22, textChroma, h),\n secondary: aiOklchHex(0.45, textChroma + 0.005, h),\n disabled: aiOklchHex(0.68, 0.01, h),\n },\n // The primary's tint is the brand's own wash (AGL-3660): a base fills an\n // outlined or tinted button with it, under the primary's dark words.\n tint: {\n primary: aiOklchHex(0.955, neutral ? 0.03 : 0.035, h),\n secondary: aiOklchHex(0.955, 0.035, buttonHue),\n tertiary: aiOklchHex(0.955, 0.03, tertiaryHue),\n },\n divider: aiOklchHex(0.9, 0.012 * groundChroma, h),\n }\n\n const darkGround = style.ground === 'tinted' ? 0.024 : style.ground === 'warm' ? 0.014 : 0.012\n const darkBackground = aiOklchHex(0.17, darkGround * groundChroma, style.ground === 'warm' ? 60 : h)\n const darkPaper = aiOklchHex(0.215, darkGround * groundChroma, style.ground === 'warm' ? 60 : h)\n const darkChroma = Math.min(chroma, 0.14)\n const darkPrimaryL = untilContrast(0.78, darkChroma, h, darkBackground, 4.5, 1)\n const darkPrimary = aiOklchHex(darkPrimaryL, darkChroma, h)\n const darkSecondary = neutral ? aiOklchHex(0.93, 0.01, h) : aiOklchHex(0.45, accentChroma * 0.85, buttonHue)\n const darkTertiary = aiOklchHex(0.8, 0.1, tertiaryHue)\n const dark: HostThemeSchemeColors = {\n primary: {\n main: darkPrimary,\n light: aiOklchHex(Math.min(0.94, darkPrimaryL + 0.08), darkChroma, h),\n dark: aiOklchHex(darkPrimaryL - 0.1, darkChroma, h),\n contrastText: labelOn(darkPrimary, h),\n },\n secondary: {\n main: darkSecondary,\n light: aiOklchHex(0.6, accentChroma * 0.7, secondary.h),\n dark: aiOklchHex(0.35, accentChroma * 0.7, secondary.h),\n contrastText: labelOn(darkSecondary, secondary.h),\n },\n tertiary: {\n main: darkTertiary,\n light: aiOklchHex(0.88, 0.08, tertiaryHue),\n dark: aiOklchHex(0.7, 0.1, tertiaryHue),\n contrastText: labelOn(darkTertiary, tertiaryHue),\n },\n surface: { main: aiOklchHex(0.25, 0.014 * groundChroma, h), contrastText: aiOklchHex(0.95, 0.01, h) },\n background: { default: darkBackground, paper: darkPaper },\n text: {\n primary: aiOklchHex(0.95, 0.008, h),\n secondary: aiOklchHex(0.77, 0.014, h),\n disabled: aiOklchHex(0.52, 0.01, h),\n },\n tint: {\n primary: aiOklchHex(0.27, 0.05, h),\n secondary: aiOklchHex(0.27, 0.05, buttonHue),\n tertiary: aiOklchHex(0.27, 0.04, tertiaryHue),\n },\n divider: aiOklchHex(0.32, 0.015 * groundChroma, h),\n }\n return { light, dark }\n}\n\n// ── The theme ────────────────────────────────────────────────────────────\n\nconst RADIUS: Record<AiSiteCorners, number> = { sharp: 2, soft: 6, round: 12, pill: 18 }\nconst SPACING: Record<AiSiteDensity, number> = { compact: 7, regular: 8, airy: 9 }\n\n/** How much of the heading scale each style takes: a display line grows most, small headings not at all. */\nconst SCALE_SHARE: Partial<Record<HostThemeTypographyVariantKey, { size: number; share: number }>> = {\n displayXl: { size: 4, share: 1.2 },\n h1: { size: 3.25, share: 1 },\n h2: { size: 2.25, share: 0.8 },\n h3: { size: 1.75, share: 0.5 },\n h4: { size: 1.5, share: 0.3 },\n h5: { size: 1.25, share: 0 },\n h6: { size: 1.125, share: 0 },\n}\n\nconst rem = (value: number) => `${Math.round(value * 1000) / 1000}rem`\n\n/**\n * The kinds whose titles are their design (AGL-3660): a portfolio's or a\n * studio's statement, a photographer's name over a cover, a publication's\n * masthead are set larger than a business site's, the way the designer\n * templates set them. The display line grows most, the page title a little,\n * and nothing under it; a phone still steps every size down\n * (`responsiveFontSizes`).\n */\nexport const AI_SITE_DISPLAY_BOOST: Readonly<Record<string, { display: number; title: number }>> = {\n portfolio: { display: 1.25, title: 1.1 },\n studio: { display: 1.3, title: 1.1 },\n photography: { display: 1.2, title: 1.08 },\n blog: { display: 1.25, title: 1.1 },\n}\n\n/** The type a style sets: headings at its scale, weight and tracking, and the eyebrow and button styles. */\nfunction typographyFor(style: AiSiteStyle): HostTheme['typography'] {\n const pairing = aiSiteFontPairing(style.fonts) ?? (AI_SITE_FONT_PAIRINGS[0] as NonNullable<ReturnType<typeof aiSiteFontPairing>>)\n const variants: Partial<Record<HostThemeTypographyVariantKey, HostThemeTypographyVariant>> = {\n ...(DEFAULT_SITE_THEME.typography?.variants ?? {}),\n }\n const boost = AI_SITE_DISPLAY_BOOST[style.kind]\n for (const [key, { size, share }] of Object.entries(SCALE_SHARE) as Array<[HostThemeTypographyVariantKey, { size: number; share: number }]>) {\n const big = key === 'displayXl' || key === 'h1' || key === 'h2'\n const boosted = key === 'displayXl' ? (boost?.display ?? 1) : key === 'h1' ? (boost?.title ?? 1) : 1\n const variant: HostThemeTypographyVariant = {\n fontSize: rem(size * (1 + (style.headingScale - 1) * share) * (pairing.caps && big ? 0.92 : 1) * boosted),\n fontWeight: big ? pairing.heading.weight : pairing.heading.sub,\n // A display line set larger sets tighter.\n lineHeight: big ? (pairing.caps ? 1.05 : key === 'displayXl' && boost ? 1.02 : 1.1) : 1.25,\n }\n if (pairing.tracking !== undefined && (big || key === 'h3')) variant.letterSpacing = `${pairing.tracking}em`\n if (pairing.caps && (big || key === 'h3')) variant.textTransform = 'uppercase'\n variants[key] = variant\n }\n const bodyBold = pairing.body.weights.includes(600) ? 600 : 700\n variants.overline =\n style.eyebrow === 'small'\n ? { fontSize: '0.875rem', fontWeight: bodyBold, letterSpacing: '0.01em', textTransform: 'none' }\n : { fontSize: '0.78rem', fontWeight: 700, letterSpacing: style.eyebrow === 'rule' ? '0.16em' : '0.12em', textTransform: 'uppercase' }\n variants.button = {\n fontWeight: style.buttons === 'caps' ? 700 : bodyBold,\n textTransform: style.buttons === 'caps' ? 'uppercase' : 'none',\n ...(style.buttons === 'caps' ? { letterSpacing: '0.06em' } : {}),\n }\n return { variants }\n}\n\n/** The card's look, in theme terms only: palette paths, shadow indexes and border widths. */\nfunction cardSx(cards: AiSiteCards): Record<string, unknown> {\n switch (cards) {\n case 'flat':\n return { boxShadow: 0, border: 0, bgcolor: 'surface.main' }\n case 'outlined':\n return { boxShadow: 0, border: 1, borderColor: 'divider', bgcolor: 'background.paper' }\n case 'elevated':\n return { boxShadow: 3, border: 0, bgcolor: 'background.paper' }\n case 'tinted':\n return { boxShadow: 0, border: 0, bgcolor: 'tint.primary' }\n case 'rule':\n return { boxShadow: 0, border: 0, borderTop: 3, borderColor: 'primary.main', borderRadius: 0, bgcolor: 'background.paper' }\n }\n}\n\n/** The component defaults and styles a style sets: buttons, cards, fields, eyebrows, the header bar and the FAQ. */\nfunction componentsFor(style: AiSiteStyle): Record<string, HostThemeComponentOverride> {\n const radius = RADIUS[style.corners]\n const buttonRadius = style.buttons === 'pill' ? 999 : style.buttons === 'square' ? 2 : radius\n const card = cardSx(style.cards)\n return {\n MuiButton: {\n defaultProps: { disableElevation: true },\n // 44px: the touch target a visitor's thumb needs.\n styleOverrides: { root: { borderRadius: buttonRadius, minHeight: 44, boxShadow: 'none' } },\n ...(style.buttons === 'link'\n ? {\n variants: [\n {\n props: { variant: 'text' },\n style: { textDecoration: 'underline', textUnderlineOffset: '0.3em', textDecorationThickness: '2px' },\n },\n ],\n }\n : {}),\n },\n MuiCard: {\n defaultProps:\n style.cards === 'outlined'\n ? { variant: 'outlined' }\n : { variant: 'elevation', elevation: style.cards === 'elevated' ? 3 : 0 },\n styleOverrides: { root: { borderRadius: style.cards === 'rule' ? 0 : Math.max(radius, 4) } },\n sx: { root: card },\n },\n MuiAccordion: {\n defaultProps: { disableGutters: true, elevation: 0 },\n sx: {\n root: {\n ...card,\n borderTop: style.cards === 'rule' ? 1 : card['borderTop'] ?? card['border'],\n '&::before': { display: 'none' },\n '&:not(:last-of-type)': { mb: 1 },\n },\n },\n },\n MuiTextField: { defaultProps: { variant: style.fields } },\n MuiOutlinedInput: { styleOverrides: { root: { borderRadius: radius } } },\n MuiFilledInput: { styleOverrides: { root: { borderTopLeftRadius: radius, borderTopRightRadius: radius } } },\n MuiChip: { styleOverrides: { root: { borderRadius: style.corners === 'sharp' ? 2 : 999 } } },\n MuiAppBar: {\n defaultProps: { elevation: 0 },\n variants: [\n {\n props: { color: 'inherit' },\n sx:\n style.header === 'line'\n ? { boxShadow: 0, borderBottom: 1, borderColor: 'divider' }\n : style.header === 'shadow'\n ? { boxShadow: 2, borderBottom: 0 }\n : { boxShadow: 0, borderBottom: 0 },\n },\n ],\n },\n ...(style.eyebrow === 'rule'\n ? {\n MuiTypography: {\n variants: [\n {\n props: { variant: 'overline' },\n // A short line in the eyebrow's own color, so it reads on any band.\n style: {\n '&::before': {\n content: '\"\"',\n display: 'inline-block',\n width: '1.75em',\n height: '2px',\n marginRight: '0.75em',\n verticalAlign: 'middle',\n backgroundColor: 'currentColor',\n },\n },\n },\n ],\n },\n }\n : {}),\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\n/** `over` merged into `under`, objects key by key, anything else replaced. */\nfunction merged<T>(under: T, over: unknown): T {\n if (!isRecord(under) || !isRecord(over)) return (over === undefined ? under : over) as T\n const out: Record<string, unknown> = { ...under }\n for (const [key, value] of Object.entries(over)) out[key] = key in out ? merged(out[key], value) : value\n return out as T\n}\n\n/** Whether a theme passes the publish check and the brand-on-page contrast the doctrine asks. */\nfunction themeReads(theme: HostTheme): boolean {\n if (!validateThemeForPublish(theme).ok) return false\n for (const scheme of ['light', 'dark'] as const) {\n const colors = theme.colorSchemes?.[scheme]\n const main = colors?.primary?.main\n const page = colors?.background?.default\n if (!main || !page || ratio(main, page) < 3) return false\n for (const key of ['primary', 'secondary', 'tertiary'] as const) {\n const fill = colors?.[key]\n if (fill?.main && fill.contrastText && ratio(fill.contrastText, fill.main) < 4.5) return false\n }\n }\n return true\n}\n\n/**\n * The site's theme: the base theme with this style layered over it. Colors,\n * type, corners, spacing and the building blocks' component styles are the\n * site's own; whatever the base sets beyond them — its focus rings, its menu\n * and dialog styles, its control heights — stays the base's.\n */\nexport function aiSiteTheme(style: AiSiteStyle, base: HostTheme): HostTheme {\n const pairing = aiSiteFontPairing(style.fonts) ?? (AI_SITE_FONT_PAIRINGS[0] as NonNullable<ReturnType<typeof aiSiteFontPairing>>)\n const colors = aiSiteColors(style)\n const keep = (scheme: 'light' | 'dark') => {\n const own = base.colorSchemes?.[scheme] ?? {}\n // The status colors stay the base's: they mean the same thing on every site.\n return {\n ...(own.error ? { error: own.error } : {}),\n ...(own.warning ? { warning: own.warning } : {}),\n ...(own.info ? { info: own.info } : {}),\n ...(own.success ? { success: own.success } : {}),\n ...colors[scheme],\n }\n }\n let theme: HostTheme = {\n ...base,\n colorSchemes: { light: keep('light'), dark: keep('dark') },\n typography: merged(base.typography ?? {}, typographyFor(style)),\n shape: { ...(base.shape ?? {}), borderRadius: RADIUS[style.corners] },\n spacing: SPACING[style.density],\n components: merged(base.components ?? {}, componentsFor(style)),\n }\n delete theme.darkScheme\n const sameFamily = pairing.heading.family === pairing.body.family\n theme = writeThemeFonts(theme, {\n body: { family: pairing.body.family, category: pairing.body.category, weights: [...pairing.body.weights], source: 'google' },\n heading: sameFamily\n ? null\n : {\n family: pairing.heading.family,\n category: pairing.heading.category,\n weights: [...new Set([pairing.heading.weight, pairing.heading.sub])].sort((a, b) => a - b),\n source: 'google',\n },\n })\n // A pairing whose heading is the body family loads the heading weights too.\n if (sameFamily && theme.fonts?.[0]) {\n theme.fonts[0] = {\n ...theme.fonts[0],\n weights: [...new Set([...(theme.fonts[0].weights ?? []), pairing.heading.weight, pairing.heading.sub])].sort((a, b) => a - b),\n }\n }\n if (!themeReads(theme)) {\n // Never a theme that fails the reading checks: the starter's colors, with everything else kept.\n theme = { ...theme, colorSchemes: DEFAULT_SITE_THEME.colorSchemes }\n }\n return theme\n}\n"],"names":["contrastRatio","validateThemeForPublish","DEFAULT_SITE_THEME","writeThemeFonts","AI_SITE_BASES","AI_SITE_CORNERS","AI_SITE_FONT_PAIRINGS","AI_SITE_GROUNDS","AI_SITE_RHYTHMS","aiSiteFontPairing","AI_SITE_CARDS","AI_SITE_FIELDS","AI_SITE_EYEBROWS","AI_SITE_HEADERS","AI_SITE_BUTTONS","DENSITIES","aiSiteSeed","jobId","hash","index","length","charCodeAt","Math","imul","random","seed","state","t","pick","next","list","floor","AI_SITE_LOOK_TOOL_NAME","enumOf","values","description","type","enum","AI_SITE_LOOK_TOOL","name","strict","inputSchema","additionalProperties","required","properties","base","hue","accent","ground","fonts","map","pairing","id","corners","buttons","cards","fields","eyebrow","header","brand","anyOf","oneOf","value","includes","undefined","hueOf","Number","isFinite","round","aiSiteBrandHex","match","exec","trim","hex","full","digit","join","toLowerCase","aiReadSiteLook","answer","raw","look","BLOCK_BIAS","portfolio","studio","photography","blog","trades","fitness","professional","wellness","yoga","restaurant","beauty","music","ANY_BLOCKS","aiSiteHueFamily","rangeOf","kind","hues","findIndex","from","to","AI_SITE_LOOK_DIMENSIONS","aiSiteLookSignature","style","hueFamily","String","headerAlign","rhythm","aiSiteStyleFor","input","avoid","styleOnce","signatures","best","attempt","AI_SITE_LOOK_DRAWS","own","least","min","other","TUPLE","every","dimension","filter","AI_SITE_LOOK_LEAST_DIFFERENCES","family","blocks","choose","model","options","keep","modelRange","keepHue","range","span","accentFrom","bases","Set","v","chroma","grounds","headerAligns","rhythms","headingScale","density","oklabToLinear","L","a","b","l","m","s","toSrgb","channel","fromSrgb","aiOklchHex","C","h","lightness","max","radians","PI","linear","cos","sin","fits","toString","padStart","aiHexOklch","replace","r","g","at","parseInt","slice","cbrt","A","B","hypot","atan2","ratio","untilContrast","against","toward","step","labelOn","fill","white","ink","aiHueGap","d","abs","AI_SITE_ACCENT_CLASH_DEGREES","CHROMA","neutral","muted","balanced","vivid","START_L","aiSiteColors","groundChroma","paper","warm","cool","tinted","background","primaryMain","primaryL","accentChroma","buttonHue","secondary","main","washChroma","tertiaryHue","tertiaryL","tertiary","textChroma","light","primary","dark","contrastText","surface","default","text","disabled","tint","divider","darkGround","darkBackground","darkPaper","darkChroma","darkPrimaryL","darkPrimary","darkSecondary","darkTertiary","RADIUS","sharp","soft","pill","SPACING","compact","regular","airy","SCALE_SHARE","displayXl","size","share","h1","h2","h3","h4","h5","h6","rem","AI_SITE_DISPLAY_BOOST","display","title","typographyFor","variants","typography","boost","key","Object","entries","big","boosted","variant","fontSize","caps","fontWeight","heading","weight","sub","lineHeight","tracking","letterSpacing","textTransform","bodyBold","body","weights","overline","button","cardSx","boxShadow","border","bgcolor","borderColor","borderTop","borderRadius","componentsFor","card","radius","buttonRadius","MuiButton","defaultProps","disableElevation","styleOverrides","root","minHeight","props","textDecoration","textUnderlineOffset","textDecorationThickness","MuiCard","elevation","sx","MuiAccordion","disableGutters","mb","MuiTextField","MuiOutlinedInput","MuiFilledInput","borderTopLeftRadius","borderTopRightRadius","MuiChip","MuiAppBar","color","borderBottom","MuiTypography","content","width","height","marginRight","verticalAlign","backgroundColor","isRecord","Array","isArray","merged","under","over","out","themeReads","theme","ok","scheme","colors","colorSchemes","page","aiSiteTheme","error","warning","info","success","shape","spacing","components","darkScheme","sameFamily","category","source","sort"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,aAAa,EACbC,uBAAuB,QAClB,oCAAmC;AAC1C,SAASC,kBAAkB,QAAQ,sCAAqC;AAQxE,SAASC,eAAe,QAAQ,kDAAiD;AAEjF,SACEC,aAAa,EACbC,eAAe,EACfC,qBAAqB,EACrBC,eAAe,EACfC,eAAe,EACfC,iBAAiB,QASZ,qBAAiB;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;CAyBC,GAED,4EAA4E;AAE5E,yBAAyB,GACzB,OAAO,MAAMC,gBAAgB;IAAC;IAAQ;IAAY;IAAY;IAAU;CAAO,CAAS;AAExF,0BAA0B,GAC1B,OAAO,MAAMC,iBAAiB;IAAC;IAAY;IAAU;CAAW,CAAS;AAEzE,2CAA2C,GAC3C,OAAO,MAAMC,mBAAmB;IAAC;IAAQ;IAAS;CAAO,CAAS;AAElE,+CAA+C,GAC/C,OAAO,MAAMC,kBAAkB;IAAC;IAAQ;IAAU;CAAO,CAAS;AAElE,8EAA8E,GAC9E,OAAO,MAA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AAE,GAAE;YAGNA;QAF5BA,MAAM9R,KAAK,CAAC,EAAE,GAAG,aACZ8R,MAAM9R,KAAK,CAAC,EAAE;YACjBwO,SAAS;mBAAI,IAAI9I,IAAI;wBAAKoM,wBAAAA,MAAM9R,KAAK,CAAC,EAAE,CAACwO,OAAO,YAAtBsD,wBAA0B,EAAE;oBAAG5R,QAAQ6N,OAAO,CAACC,MAAM;oBAAE9N,QAAQ6N,OAAO,CAACE,GAAG;iBAAC;aAAE,CAAC+E,IAAI,CAAC,CAAC5M,GAAGC,IAAMD,IAAIC;;IAE/H;IACA,IAAI,CAACwL,WAAWC,QAAQ;QACtB,gGAAgG;QAChGA,QAAQ,aAAKA;YAAOI,cAAcjV,mBAAmBiV,YAAY;;IACnE;IACA,OAAOJ;AACT"}
|
|
@@ -23,3 +23,21 @@ import type { OperatorAlertDefinition } from '@aglyn/aglyn/app-utils/operator-al
|
|
|
23
23
|
* label — so a self-hoster on any provider hears the same thing.
|
|
24
24
|
*/
|
|
25
25
|
export declare const AI_PROVIDER_UNAVAILABLE: OperatorAlertDefinition;
|
|
26
|
+
/**
|
|
27
|
+
* An AI job failed on our side: a provider error, a step that produced
|
|
28
|
+
* nothing usable, a build that delivered nothing. Not a model declining the
|
|
29
|
+
* brief, and not a site with AI switched off — those are the customer's, and
|
|
30
|
+
* the customer is told. Deduped per job kind, so an outage is one alert an
|
|
31
|
+
* hour for each kind it breaks rather than one per job; the runner's own
|
|
32
|
+
* words are in `{{error}}`, and every failure is in the log as `ai job failed`.
|
|
33
|
+
*/
|
|
34
|
+
export declare const AI_JOB_FAILED: OperatorAlertDefinition;
|
|
35
|
+
/**
|
|
36
|
+
* A build finished with part of it missing: it delivered something, so the
|
|
37
|
+
* job is `done`, but one or more of its items failed on our side (AGL-3683).
|
|
38
|
+
* The customer has a site or build with holes in it and no failed job to
|
|
39
|
+
* show for it, which is why it is its own alert. Items the model declined
|
|
40
|
+
* are the customer's and do not count. Deduped per job kind, like
|
|
41
|
+
* `ai.jobFailed`.
|
|
42
|
+
*/
|
|
43
|
+
export declare const AI_BUILD_PARTLY_FAILED: OperatorAlertDefinition;
|
|
@@ -33,5 +33,47 @@
|
|
|
33
33
|
dedupeWindowMinutes: 6 * 60,
|
|
34
34
|
defaultEnabled: true
|
|
35
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* An AI job failed on our side: a provider error, a step that produced
|
|
38
|
+
* nothing usable, a build that delivered nothing. Not a model declining the
|
|
39
|
+
* brief, and not a site with AI switched off — those are the customer's, and
|
|
40
|
+
* the customer is told. Deduped per job kind, so an outage is one alert an
|
|
41
|
+
* hour for each kind it breaks rather than one per job; the runner's own
|
|
42
|
+
* words are in `{{error}}`, and every failure is in the log as `ai job failed`.
|
|
43
|
+
*/ export const AI_JOB_FAILED = {
|
|
44
|
+
type: 'ai.jobFailed',
|
|
45
|
+
pluginId: AI_PLUGIN_ID,
|
|
46
|
+
label: 'An AI job failed',
|
|
47
|
+
description: 'An AI job (a site, page, build, theme…) failed on the platform’s side, so a customer got nothing for their request. Read the error, then search the logs for “ai job failed” to see whether it is one job or every job of that kind.',
|
|
48
|
+
tier: 'should',
|
|
49
|
+
category: 'ops',
|
|
50
|
+
title: 'An AI {{kind}} job failed',
|
|
51
|
+
body: 'AI job {{jobId}} ({{kind}}) in workspace {{orgId}} failed at step {{step}}: {{error}}. The customer was told and given back the credits. Further {{kind}} failures within the hour are counted into the next alert.',
|
|
52
|
+
link: '/admin/orgs/{{orgId}}',
|
|
53
|
+
delivery: 'immediate',
|
|
54
|
+
dedupeWindowMinutes: 60,
|
|
55
|
+
defaultEnabled: true
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* A build finished with part of it missing: it delivered something, so the
|
|
59
|
+
* job is `done`, but one or more of its items failed on our side (AGL-3683).
|
|
60
|
+
* The customer has a site or build with holes in it and no failed job to
|
|
61
|
+
* show for it, which is why it is its own alert. Items the model declined
|
|
62
|
+
* are the customer's and do not count. Deduped per job kind, like
|
|
63
|
+
* `ai.jobFailed`.
|
|
64
|
+
*/ export const AI_BUILD_PARTLY_FAILED = {
|
|
65
|
+
type: 'ai.buildPartlyFailed',
|
|
66
|
+
pluginId: AI_PLUGIN_ID,
|
|
67
|
+
label: 'An AI build finished with parts missing',
|
|
68
|
+
description: 'An AI build (a site, or a multi-part build) finished, but some of its parts failed on the platform’s side, so the customer got less than they asked for. Read which parts and why, then search the logs for the job id.',
|
|
69
|
+
tier: 'should',
|
|
70
|
+
category: 'ops',
|
|
71
|
+
title: 'An AI {{kind}} build finished with {{failed}} of {{total}} parts failed',
|
|
72
|
+
body: 'AI job {{jobId}} ({{kind}}) in workspace {{orgId}} finished, but {{failed}} of its {{total}} parts failed on our side: {{items}}. The customer was given back those parts’ credits. Further partial {{kind}} builds within the hour are counted into the next alert.',
|
|
73
|
+
link: '/admin/orgs/{{orgId}}',
|
|
74
|
+
delivery: 'immediate',
|
|
75
|
+
dedupeWindowMinutes: 60,
|
|
76
|
+
defaultEnabled: true
|
|
77
|
+
};
|
|
36
78
|
|
|
37
79
|
//# sourceMappingURL=operator-alerts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/plugins/ai/src/lib/operator-alerts.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { OperatorAlertDefinition } from '@aglyn/aglyn/app-utils/operator-alerts'\nimport { AI_PLUGIN_ID } from './constants'\n\n/**\n * The AI plugin's operator alert (AGL-3377): the platform's provider account\n * refused its key or ran out of credit, so every AI feature on the install\n * fails. Provider-generic — each adapter classifies its own vendor's answer\n * as an `accountProblem`, and the runtime raises this with the provider's\n * label — so a self-hoster on any provider hears the same thing.\n */\nexport const AI_PROVIDER_UNAVAILABLE: OperatorAlertDefinition = {\n type: 'ai.providerUnavailable',\n pluginId: AI_PLUGIN_ID,\n label: 'Platform AI provider unavailable',\n description:\n 'The platform’s AI provider refused its key or ran out of credit, so every AI feature on the install is failing until the key or the balance is fixed.',\n tier: 'should',\n category: 'ops',\n title: '{{provider}} is refusing requests',\n body:\n 'The platform’s {{provider}} account refused a request because {{reason}}. AI features fail until it is fixed ({{keyEnv}}).',\n delivery: 'immediate',\n dedupeWindowMinutes: 6 * 60,\n defaultEnabled: true,\n}\n"],"names":["AI_PLUGIN_ID","AI_PROVIDER_UNAVAILABLE","type","pluginId","label","description","tier","category","title","body","delivery","dedupeWindowMinutes","defaultEnabled"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAGD,SAASA,YAAY,QAAQ,iBAAa;AAE1C;;;;;;CAMC,GACD,OAAO,MAAMC,0BAAmD;IAC9DC,MAAM;IACNC,UAAUH;IACVI,OAAO;IACPC,aACE;IACFC,MAAM;IACNC,UAAU;IACVC,OAAO;IACPC,MACE;IACFC,UAAU;IACVC,qBAAqB,IAAI;IACzBC,gBAAgB;AAClB,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/plugins/ai/src/lib/operator-alerts.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { OperatorAlertDefinition } from '@aglyn/aglyn/app-utils/operator-alerts'\nimport { AI_PLUGIN_ID } from './constants'\n\n/**\n * The AI plugin's operator alert (AGL-3377): the platform's provider account\n * refused its key or ran out of credit, so every AI feature on the install\n * fails. Provider-generic — each adapter classifies its own vendor's answer\n * as an `accountProblem`, and the runtime raises this with the provider's\n * label — so a self-hoster on any provider hears the same thing.\n */\nexport const AI_PROVIDER_UNAVAILABLE: OperatorAlertDefinition = {\n type: 'ai.providerUnavailable',\n pluginId: AI_PLUGIN_ID,\n label: 'Platform AI provider unavailable',\n description:\n 'The platform’s AI provider refused its key or ran out of credit, so every AI feature on the install is failing until the key or the balance is fixed.',\n tier: 'should',\n category: 'ops',\n title: '{{provider}} is refusing requests',\n body:\n 'The platform’s {{provider}} account refused a request because {{reason}}. AI features fail until it is fixed ({{keyEnv}}).',\n delivery: 'immediate',\n dedupeWindowMinutes: 6 * 60,\n defaultEnabled: true,\n}\n\n/**\n * An AI job failed on our side: a provider error, a step that produced\n * nothing usable, a build that delivered nothing. Not a model declining the\n * brief, and not a site with AI switched off — those are the customer's, and\n * the customer is told. Deduped per job kind, so an outage is one alert an\n * hour for each kind it breaks rather than one per job; the runner's own\n * words are in `{{error}}`, and every failure is in the log as `ai job failed`.\n */\nexport const AI_JOB_FAILED: OperatorAlertDefinition = {\n type: 'ai.jobFailed',\n pluginId: AI_PLUGIN_ID,\n label: 'An AI job failed',\n description:\n 'An AI job (a site, page, build, theme…) failed on the platform’s side, so a customer got nothing for their request. Read the error, then search the logs for “ai job failed” to see whether it is one job or every job of that kind.',\n tier: 'should',\n category: 'ops',\n title: 'An AI {{kind}} job failed',\n body:\n 'AI job {{jobId}} ({{kind}}) in workspace {{orgId}} failed at step {{step}}: {{error}}. The customer was told and given back the credits. Further {{kind}} failures within the hour are counted into the next alert.',\n link: '/admin/orgs/{{orgId}}',\n delivery: 'immediate',\n dedupeWindowMinutes: 60,\n defaultEnabled: true,\n}\n\n/**\n * A build finished with part of it missing: it delivered something, so the\n * job is `done`, but one or more of its items failed on our side (AGL-3683).\n * The customer has a site or build with holes in it and no failed job to\n * show for it, which is why it is its own alert. Items the model declined\n * are the customer's and do not count. Deduped per job kind, like\n * `ai.jobFailed`.\n */\nexport const AI_BUILD_PARTLY_FAILED: OperatorAlertDefinition = {\n type: 'ai.buildPartlyFailed',\n pluginId: AI_PLUGIN_ID,\n label: 'An AI build finished with parts missing',\n description:\n 'An AI build (a site, or a multi-part build) finished, but some of its parts failed on the platform’s side, so the customer got less than they asked for. Read which parts and why, then search the logs for the job id.',\n tier: 'should',\n category: 'ops',\n title: 'An AI {{kind}} build finished with {{failed}} of {{total}} parts failed',\n body:\n 'AI job {{jobId}} ({{kind}}) in workspace {{orgId}} finished, but {{failed}} of its {{total}} parts failed on our side: {{items}}. The customer was given back those parts’ credits. Further partial {{kind}} builds within the hour are counted into the next alert.',\n link: '/admin/orgs/{{orgId}}',\n delivery: 'immediate',\n dedupeWindowMinutes: 60,\n defaultEnabled: true,\n}\n"],"names":["AI_PLUGIN_ID","AI_PROVIDER_UNAVAILABLE","type","pluginId","label","description","tier","category","title","body","delivery","dedupeWindowMinutes","defaultEnabled","AI_JOB_FAILED","link","AI_BUILD_PARTLY_FAILED"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAGD,SAASA,YAAY,QAAQ,iBAAa;AAE1C;;;;;;CAMC,GACD,OAAO,MAAMC,0BAAmD;IAC9DC,MAAM;IACNC,UAAUH;IACVI,OAAO;IACPC,aACE;IACFC,MAAM;IACNC,UAAU;IACVC,OAAO;IACPC,MACE;IACFC,UAAU;IACVC,qBAAqB,IAAI;IACzBC,gBAAgB;AAClB,EAAC;AAED;;;;;;;CAOC,GACD,OAAO,MAAMC,gBAAyC;IACpDX,MAAM;IACNC,UAAUH;IACVI,OAAO;IACPC,aACE;IACFC,MAAM;IACNC,UAAU;IACVC,OAAO;IACPC,MACE;IACFK,MAAM;IACNJ,UAAU;IACVC,qBAAqB;IACrBC,gBAAgB;AAClB,EAAC;AAED;;;;;;;CAOC,GACD,OAAO,MAAMG,yBAAkD;IAC7Db,MAAM;IACNC,UAAUH;IACVI,OAAO;IACPC,aACE;IACFC,MAAM;IACNC,UAAU;IACVC,OAAO;IACPC,MACE;IACFK,MAAM;IACNJ,UAAU;IACVC,qBAAqB;IACrBC,gBAAgB;AAClB,EAAC"}
|