Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

AI Influencer builder: option data from the research, pick rules, Shuffle and prompt compiler

Claude9df603332425
diff --git a/package.json b/package.json
index b6181572..ef3dc93a 100644
--- a/package.json
+++ b/package.json
@@ -16,7 +16,7 @@
"test:e2e:library": "node tests/e2e/library-flows.mjs",
"test:e2e:mobile": "node tests/e2e/no-horizontal-scroll.mjs",
"test:e2e:shell": "node tests/e2e/shell.mjs",
- "gen:catalog": "python3 scripts/gen-cloud-models.py && python3 scripts/gen-higgsfield-models.py && python3 scripts/gen-higgsfield-presets.py && python3 scripts/gen-oss-loras.py && node scripts/gen-icon-map.mjs",
+ "gen:catalog": "python3 scripts/gen-cloud-models.py && python3 scripts/gen-higgsfield-models.py && python3 scripts/gen-higgsfield-presets.py && python3 scripts/gen-oss-loras.py && python3 scripts/gen-influencer-options.py && node scripts/gen-icon-map.mjs",
"typecheck": "tsc --noEmit"
},
"dependencies": {
diff --git a/scripts/gen-influencer-options.py b/scripts/gen-influencer-options.py
new file mode 100644
index 00000000..0a160135
--- /dev/null
+++ b/scripts/gen-influencer-options.py
@@ -0,0 +1,109 @@
+#!/usr/bin/env python3
+"""
+Generate src/lib/catalog/influencer-options.generated.ts from docs/research/higgsfield-delta-4.json
+(aiInfluencerBuilder: Higgsfield's AI Influencer builder, read from its bundle).
+
+Outputs (data only; the rules and the prompt compiler are src/lib/influencer.ts):
+ INFLUENCER_CATEGORIES — the 19 categories in Higgsfield's order: id, label, kind (media / text / color),
+ max picks, and every option with its id, label, the tiers it shows in
+ (visibleIn), its swatch (color categories) and its slot (Features).
+ CREATURE_TYPES — the 6 creature types with their species ids and labels.
+ CREATURE_CATEGORIES — the categories a creature type shows.
+ DISPLAY_ORDER_FIRST — the categories the builder lists first.
+ SHUFFLE_RESEARCH — Shuffle's weights and the picks a reference photo keeps.
+ CONFLICT_MESSAGES — Higgsfield's two conflict messages, word for word.
+
+No preview images are copied: Fuobe draws its own tiles, so nothing is hot-linked from Higgsfield's CDN.
+
+Run: python3 scripts/gen-influencer-options.py
+"""
+import json
+import re
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parent.parent
+RESEARCH = json.loads((ROOT / "docs/research/higgsfield-delta-4.json").read_text())["aiInfluencerBuilder"]
+OUT = ROOT / "src/lib/catalog/influencer-options.generated.ts"
+
+# Species ids are snake_case; these read better with their proper capitals.
+SPECIES_LABELS = {"maine_coon": "Maine Coon", "british_shorthair": "British Shorthair"}
+
+
+def ts(v):
+ return json.dumps(v, ensure_ascii=False, indent=2)
+
+
+def species_label(sid):
+ return SPECIES_LABELS.get(sid) or sid.replace("_", " ").capitalize()
+
+
+categories = []
+for c in RESEARCH["categories"]:
+ options = []
+ for o in c["options"]:
+ opt = {"id": o["id"], "label": o["label"]}
+ if "visibleIn" in o:
+ opt["visibleIn"] = o["visibleIn"]
+ if "swatch" in o:
+ opt["swatch"] = o["swatch"].lower()
+ if "slot" in o:
+ opt["slot"] = o["slot"]
+ options.append(opt)
+ categories.append({"id": c["id"], "label": c["label"], "kind": c["kind"], "max": c["max"], "options": options})
+
+tier_labels = {o["id"]: o["label"] for o in next(c for c in RESEARCH["categories"] if c["id"] == "tier")["options"]}
+creatures = [
+ {"id": cid, "label": tier_labels.get(cid, cid), "species": [{"id": s, "label": species_label(s)} for s in species]}
+ for cid, species in RESEARCH["creatureTypes"].items()
+]
+
+shuffle = RESEARCH["shuffle"]
+
+
+def weights(d):
+ """{"hs_lampshade (Bob) when visible": 0.2, "otherUniform": 0.8} → {"hs_lampshade": 0.2} (the rest is uniform)."""
+ return {k.split(" ")[0]: v for k, v in d.items() if not k.startswith("other")}
+
+
+shuffle_out = {
+ "keepsWithReference": shuffle["keepsWithReference"],
+ "weights": {"gender": weights(shuffle["gender"]), "aesthetic": weights(shuffle["aesthetic"]), "hair": weights(shuffle["hair"])},
+}
+
+conflicts = [re.sub(r"\s*\(.*\)\s*$", "", r).strip() for r in RESEARCH["rules"] if "cannot be combined" in r]
+heavy = next(m for m in conflicts if m.startswith("Heavy"))
+legs = next(m for m in conflicts if "Short legs" in m)
+
+errors = []
+if len(categories) != 19:
+ errors.append(f"expected 19 categories, got {len(categories)}")
+if len(creatures) != 6:
+ errors.append(f"expected 6 creature types, got {len(creatures)}")
+if errors:
+ raise SystemExit("; ".join(errors))
+
+OUT.write_text(
+ "// GENERATED by scripts/gen-influencer-options.py from docs/research/higgsfield-delta-4.json (aiInfluencerBuilder) — do not edit.\n"
+ "// Higgsfield's AI Influencer builder: its option ids (the API's `selection`), labels, tiers, swatches and Shuffle weights.\n\n"
+ "/** Human tiers: Average (normal), Bold (freak), Extreme (total). */\n"
+ "export type HumanTier = \"normal\" | \"freak\" | \"total\";\n"
+ f"export type CreatureType = {' | '.join(json.dumps(c['id']) for c in creatures)};\n"
+ "export type InfluencerTier = HumanTier | CreatureType;\n\n"
+ "export interface InfluencerOption {\n id: string;\n label: string;\n"
+ " /** The tiers that show it (human tiers or creature types; creature types also get every option of their categories but Centaur). */\n"
+ " visibleIn?: InfluencerTier[];\n /** Colour categories: the tile's swatch. */\n swatch?: string;\n"
+ " /** Features: one option per slot (marks, cheeks, eyes, lips, brows, nose, ears, teeth, chin, forehead). */\n slot?: string;\n}\n\n"
+ "export interface InfluencerCategory {\n id: string;\n label: string;\n kind: \"media\" | \"text\" | \"color\";\n"
+ " /** How many options can be picked (Features: one per slot, up to this many). */\n max: number;\n options: InfluencerOption[];\n}\n\n"
+ "export interface CreatureDef {\n id: CreatureType;\n label: string;\n species: { id: string; label: string }[];\n}\n\n"
+ f"export const INFLUENCER_CATEGORIES: InfluencerCategory[] = {ts(categories)};\n\n"
+ f"export const CREATURE_TYPES: CreatureDef[] = {ts(creatures)};\n\n"
+ f"/** The categories a creature type shows (plus its species and body colour). */\nexport const CREATURE_CATEGORIES: string[] = {ts(RESEARCH['creatureCategories'])};\n\n"
+ f"/** The builder lists these first, then the rest in Higgsfield's order. */\nexport const DISPLAY_ORDER_FIRST: string[] = {ts(RESEARCH['displayOrderFirst'])};\n\n"
+ "/** Shuffle (function `ae` in the bundle): weighted picks (the rest of each category is uniform) and what a reference photo keeps. */\n"
+ f"export const SHUFFLE_RESEARCH = {ts(shuffle_out)} as const;\n\n"
+ "/** Higgsfield's conflict messages, word for word. */\n"
+ f"export const CONFLICT_MESSAGES = {ts({'heavyTall': heavy, 'buildLegs': legs})} as const;\n"
+)
+n = sum(len(c["options"]) for c in categories)
+print(f"wrote {OUT.relative_to(ROOT)}: {len(categories)} categories, {n} options, {len(creatures)} creature types")
diff --git a/src/lib/catalog/influencer-options.generated.ts b/src/lib/catalog/influencer-options.generated.ts
new file mode 100644
index 00000000..d687ee9d
--- /dev/null
+++ b/src/lib/catalog/influencer-options.generated.ts
@@ -0,0 +1,2009 @@
+// GENERATED by scripts/gen-influencer-options.py from docs/research/higgsfield-delta-4.json (aiInfluencerBuilder) — do not edit.
+// Higgsfield's AI Influencer builder: its option ids (the API's `selection`), labels, tiers, swatches and Shuffle weights.
+
+/** Human tiers: Average (normal), Bold (freak), Extreme (total). */
+export type HumanTier = "normal" | "freak" | "total";
+export type CreatureType = "insects" | "frogs" | "cats" | "dogs" | "capybaras" | "birds";
+export type InfluencerTier = HumanTier | CreatureType;
+
+export interface InfluencerOption {
+ id: string;
+ label: string;
+ /** The tiers that show it (human tiers or creature types; creature types also get every option of their categories but Centaur). */
+ visibleIn?: InfluencerTier[];
+ /** Colour categories: the tile's swatch. */
+ swatch?: string;
+ /** Features: one option per slot (marks, cheeks, eyes, lips, brows, nose, ears, teeth, chin, forehead). */
+ slot?: string;
+}
+
+export interface InfluencerCategory {
+ id: string;
+ label: string;
+ kind: "media" | "text" | "color";
+ /** How many options can be picked (Features: one per slot, up to this many). */
+ max: number;
+ options: InfluencerOption[];
+}
+
+export interface CreatureDef {
+ id: CreatureType;
+ label: string;
+ species: { id: string; label: string }[];
+}
+
+export const INFLUENCER_CATEGORIES: InfluencerCategory[] = [
+ {
+ "id": "tier",
+ "label": "Character type",
+ "kind": "media",
+ "max": 1,
+ "options": [
+ {
+ "id": "normal",
+ "label": "Average"
+ },
+ {
+ "id": "freak",
+ "label": "Bold"
+ },
+ {
+ "id": "total",
+ "label": "Extreme"
+ },
+ {
+ "id": "insects",
+ "label": "Insect"
+ },
+ {
+ "id": "frogs",
+ "label": "Frog"
+ },
+ {
+ "id": "cats",
+ "label": "Cat"
+ },
+ {
+ "id": "dogs",
+ "label": "Dog"
+ },
+ {
+ "id": "capybaras",
+ "label": "Rodent"
+ },
+ {
+ "id": "birds",
+ "label": "Bird"
+ }
+ ]
+ },
+ {
+ "id": "gender",
+ "label": "Gender",
+ "kind": "media",
+ "max": 1,
+ "options": [
+ {
+ "id": "female",
+ "label": "Female",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "male",
+ "label": "Male",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "trans_man",
+ "label": "Trans man",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "trans_woman",
+ "label": "Trans woman",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "non_binary",
+ "label": "Non-binary",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ }
+ ]
+ },
+ {
+ "id": "ethnicity_origin_base",
+ "label": "Ethnicity",
+ "kind": "media",
+ "max": 1,
+ "options": [
+ {
+ "id": "african",
+ "label": "African",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "east_asian",
+ "label": "Asian",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "european",
+ "label": "European",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "indian",
+ "label": "Indian",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "middle_eastern",
+ "label": "Middle Eastern",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "latin_american",
+ "label": "Mixed",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ }
+ ]
+ },
+ {
+ "id": "age",
+ "label": "Age",
+ "kind": "text",
+ "max": 1,
+ "options": [
+ {
+ "id": "adult",
+ "label": "Adult",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "mature",
+ "label": "Mature",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "senior",
+ "label": "Senior",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ }
+ ]
+ },
+ {
+ "id": "skin_tone",
+ "label": "Skin color",
+ "kind": "color",
+ "max": 1,
+ "options": [
+ {
+ "id": "st_porcelain",
+ "label": "Porcelain",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#f1e2d5"
+ },
+ {
+ "id": "st_fair",
+ "label": "Fair",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#e8c9b5"
+ },
+ {
+ "id": "st_light",
+ "label": "Light",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#dab49a"
+ },
+ {
+ "id": "st_olive",
+ "label": "Olive",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#b6976e"
+ },
+ {
+ "id": "st_tan",
+ "label": "Tan",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#bc8e67"
+ },
+ {
+ "id": "st_brown",
+ "label": "Brown",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#805135"
+ },
+ {
+ "id": "st_deep",
+ "label": "Deep brown",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#543621"
+ },
+ {
+ "id": "st_ebony",
+ "label": "Ebony",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#2d211b"
+ }
+ ]
+ },
+ {
+ "id": "height",
+ "label": "Height",
+ "kind": "media",
+ "max": 1,
+ "options": [
+ {
+ "id": "h_short",
+ "label": "Short",
+ "visibleIn": [
+ "insects",
+ "frogs",
+ "cats",
+ "dogs",
+ "capybaras",
+ "birds"
+ ]
+ },
+ {
+ "id": "h_average",
+ "label": "Average",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "h_tall",
+ "label": "Tall",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "h_very_tall",
+ "label": "Very tall",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ }
+ ]
+ },
+ {
+ "id": "body_type",
+ "label": "Build",
+ "kind": "media",
+ "max": 1,
+ "options": [
+ {
+ "id": "body_slim",
+ "label": "Slim",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "body_athletic",
+ "label": "Athletic",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "body_muscular",
+ "label": "Muscular",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "body_curvy",
+ "label": "Curvy",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "body_heavy",
+ "label": "Heavy",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "body_ultra",
+ "label": "Ultra Muscular",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "pr_centaur",
+ "label": "Centaur",
+ "visibleIn": [
+ "total"
+ ]
+ }
+ ]
+ },
+ {
+ "id": "proportions",
+ "label": "Proportions",
+ "kind": "media",
+ "max": 2,
+ "options": [
+ {
+ "id": "pr_longlimbs",
+ "label": "Long limbs",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "pr_shortlegs",
+ "label": "Short legs",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "pr_shoulders",
+ "label": "Broad shoulders",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "pr_waist",
+ "label": "Tiny waist",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "pr_egg",
+ "label": "Egg body",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ }
+ ]
+ },
+ {
+ "id": "freak_head",
+ "label": "Head shape",
+ "kind": "media",
+ "max": 1,
+ "options": [
+ {
+ "id": "head_oval",
+ "label": "Standard",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "head_long",
+ "label": "Long",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "head_tiny",
+ "label": "Tiny",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "head_forehead",
+ "label": "High forehead",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "head_ancient",
+ "label": "Caveman",
+ "visibleIn": [
+ "total"
+ ]
+ },
+ {
+ "id": "head_herojaw",
+ "label": "Gigachad",
+ "visibleIn": [
+ "total"
+ ]
+ },
+ {
+ "id": "head_megachin",
+ "label": "Mega jaw",
+ "visibleIn": [
+ "total"
+ ]
+ },
+ {
+ "id": "head_round",
+ "label": "Round",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "head_square",
+ "label": "Square",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "head_heart",
+ "label": "Heart",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ }
+ ]
+ },
+ {
+ "id": "freak_neck",
+ "label": "Neck",
+ "kind": "media",
+ "max": 1,
+ "options": [
+ {
+ "id": "neck_normal",
+ "label": "Standard",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "neck_column",
+ "label": "Column",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "neck_long",
+ "label": "Long",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "neck_short",
+ "label": "Short",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ }
+ ]
+ },
+ {
+ "id": "eye_shape",
+ "label": "Eye shape",
+ "kind": "media",
+ "max": 1,
+ "options": [
+ {
+ "id": "es_almond",
+ "label": "Almond",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "es_round",
+ "label": "Round",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "es_monolid",
+ "label": "Monolid",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "es_close",
+ "label": "Close-set",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "es_wide",
+ "label": "Wide-set",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "es_uneven",
+ "label": "Uneven",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "es_large",
+ "label": "Large",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "es_huge",
+ "label": "Huge",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "es_hooded",
+ "label": "Hooded",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "es_upturned",
+ "label": "Upturned",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "es_downturned",
+ "label": "Downturned",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ }
+ ]
+ },
+ {
+ "id": "eye_color",
+ "label": "Eye color",
+ "kind": "color",
+ "max": 1,
+ "options": [
+ {
+ "id": "eye_black",
+ "label": "Black",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#191615"
+ },
+ {
+ "id": "eye_brown",
+ "label": "Brown",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#67432c"
+ },
+ {
+ "id": "eye_hazel",
+ "label": "Hazel",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#887546"
+ },
+ {
+ "id": "eye_green",
+ "label": "Green",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#648254"
+ },
+ {
+ "id": "eye_blue",
+ "label": "Blue",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#5182a1"
+ },
+ {
+ "id": "eye_ice_blue",
+ "label": "Ice blue",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#a5cbd6"
+ },
+ {
+ "id": "eye_amber",
+ "label": "Amber",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#bd8c45"
+ },
+ {
+ "id": "eye_grey",
+ "label": "Grey",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#939b9d"
+ }
+ ]
+ },
+ {
+ "id": "freak_face",
+ "label": "Features",
+ "kind": "media",
+ "max": 4,
+ "options": [
+ {
+ "id": "fn_freckles",
+ "label": "Freckles",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "slot": "marks"
+ },
+ {
+ "id": "fn_dimples",
+ "label": "Dimples",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "slot": "cheeks"
+ },
+ {
+ "id": "fn_eyebags",
+ "label": "Heavy eye bags",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "slot": "eyes"
+ },
+ {
+ "id": "ff_marks_12",
+ "label": "Blush",
+ "visibleIn": [
+ "freak",
+ "total"
+ ],
+ "slot": "marks"
+ },
+ {
+ "id": "fn_cheekbones",
+ "label": "High cheekbones",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "slot": "cheeks"
+ },
+ {
+ "id": "fn_fulllips",
+ "label": "Full lips",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "slot": "lips"
+ },
+ {
+ "id": "fn_thickbrows",
+ "label": "Thick brows",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "slot": "brows"
+ },
+ {
+ "id": "fn_mole",
+ "label": "Beauty mark",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "slot": "marks"
+ },
+ {
+ "id": "ff_nose_0",
+ "label": "Potato nose",
+ "visibleIn": [
+ "freak",
+ "total"
+ ],
+ "slot": "nose"
+ },
+ {
+ "id": "ff_nose_1",
+ "label": "Button nose",
+ "visibleIn": [
+ "freak",
+ "total"
+ ],
+ "slot": "nose"
+ },
+ {
+ "id": "ff_nose_2",
+ "label": "Pointy nose",
+ "visibleIn": [
+ "freak",
+ "total"
+ ],
+ "slot": "nose"
+ },
+ {
+ "id": "fn_tinynose",
+ "label": "Tiny nose",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "slot": "nose"
+ },
+ {
+ "id": "ff_lips_3",
+ "label": "Pouty lips",
+ "visibleIn": [
+ "freak",
+ "total"
+ ],
+ "slot": "lips"
+ },
+ {
+ "id": "ff_lips_4",
+ "label": "Tiny pursed mouth",
+ "visibleIn": [
+ "freak",
+ "total"
+ ],
+ "slot": "lips"
+ },
+ {
+ "id": "fn_widemouth",
+ "label": "Wide mouth",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "slot": "lips"
+ },
+ {
+ "id": "ff_brows_5",
+ "label": "Unibrow",
+ "visibleIn": [
+ "freak",
+ "total"
+ ],
+ "slot": "brows"
+ },
+ {
+ "id": "ff_brows_6",
+ "label": "Thin high brows",
+ "visibleIn": [
+ "freak",
+ "total"
+ ],
+ "slot": "brows"
+ },
+ {
+ "id": "ff_brows_7",
+ "label": "Brush brows",
+ "visibleIn": [
+ "freak",
+ "total"
+ ],
+ "slot": "brows"
+ },
+ {
+ "id": "ff_ears_8",
+ "label": "Jug ears",
+ "visibleIn": [
+ "freak",
+ "total"
+ ],
+ "slot": "ears"
+ },
+ {
+ "id": "ff_ears_9",
+ "label": "Uneven ears",
+ "visibleIn": [
+ "freak",
+ "total"
+ ],
+ "slot": "ears"
+ },
+ {
+ "id": "ff_teeth_10",
+ "label": "Gap teeth",
+ "visibleIn": [
+ "freak",
+ "total"
+ ],
+ "slot": "teeth"
+ },
+ {
+ "id": "ff_teeth_11",
+ "label": "Buck teeth",
+ "visibleIn": [
+ "freak",
+ "total"
+ ],
+ "slot": "teeth"
+ },
+ {
+ "id": "fn_pointychin",
+ "label": "Pointy chin",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "slot": "chin"
+ },
+ {
+ "id": "ff_chin_13",
+ "label": "Weak chin",
+ "visibleIn": [
+ "freak",
+ "total"
+ ],
+ "slot": "chin"
+ },
+ {
+ "id": "ff_forehead_14",
+ "label": "Big forehead",
+ "visibleIn": [
+ "freak",
+ "total"
+ ],
+ "slot": "forehead"
+ }
+ ]
+ },
+ {
+ "id": "facial_hair",
+ "label": "Facial hair",
+ "kind": "media",
+ "max": 1,
+ "options": [
+ {
+ "id": "fh_none",
+ "label": "Clean",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "fh_stubble",
+ "label": "Stubble",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "fh_beard",
+ "label": "Full beard",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "fh_goatee",
+ "label": "Goatee",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "fh_moustache",
+ "label": "Moustache",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "fh_pencil",
+ "label": "Pencil",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "fh_pushbroom",
+ "label": "Push-broom",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "fh_braid",
+ "label": "Braided",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ }
+ ]
+ },
+ {
+ "id": "hair",
+ "label": "Hairstyle",
+ "kind": "media",
+ "max": 1,
+ "options": [
+ {
+ "id": "hs_lampshade",
+ "label": "Bob",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "hair_bald",
+ "label": "Bald",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "hair_buzz",
+ "label": "Buzz cut",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "hair_bowl",
+ "label": "Bowl cut",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "hair_mullet",
+ "label": "Mullet",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "hair_braids",
+ "label": "Braids",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "hair_pigtails",
+ "label": "Pigtails",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "hair_afro",
+ "label": "Afro",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "hair_punk",
+ "label": "Mohawk",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "hs_pompadour",
+ "label": "Volume waves",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "hs_beehive",
+ "label": "Beehive",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "hs_dome",
+ "label": "Perm",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "hair_long",
+ "label": "Long hair",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "hair_short",
+ "label": "Short hair",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "hs_horns",
+ "label": "Hair horns",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "hs_softserve",
+ "label": "Soft-serve swirl",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "hs_sphere",
+ "label": "Curl sphere",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "hs_mouse",
+ "label": "Mouse-ear puffs",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "hs_wings",
+ "label": "Hair wings",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "hs_hedgehog",
+ "label": "Hedgehog spikes",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "hs_tufts",
+ "label": "Side tufts",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "hs_stairs",
+ "label": "Stair steps",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "hs_shelf",
+ "label": "Shelf bob",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "hs_corkscrews",
+ "label": "Corkscrews",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "hs_sidecoil",
+ "label": "Side coil",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "hs_mushroom",
+ "label": "Mushroom",
+ "visibleIn": [
+ "freak",
+ "total"
+ ]
+ }
+ ]
+ },
+ {
+ "id": "hair_colour",
+ "label": "Hair Color",
+ "kind": "color",
+ "max": 1,
+ "options": [
+ {
+ "id": "hc_black",
+ "label": "Jet black",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#151515"
+ },
+ {
+ "id": "hc_darkbrown",
+ "label": "Dark brown",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#39281f"
+ },
+ {
+ "id": "hc_chestnut",
+ "label": "Chestnut",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#794a33"
+ },
+ {
+ "id": "hc_ginger",
+ "label": "Ginger",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#b56131"
+ },
+ {
+ "id": "hc_red",
+ "label": "Red",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#b43636"
+ },
+ {
+ "id": "hc_blonde",
+ "label": "Blonde",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#d9b774"
+ },
+ {
+ "id": "hc_platinum",
+ "label": "Platinum",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#e4d9bc"
+ },
+ {
+ "id": "hc_grey",
+ "label": "Grey",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#8c8c8c"
+ },
+ {
+ "id": "hc_white",
+ "label": "White",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#eee9dd"
+ },
+ {
+ "id": "hc_pink",
+ "label": "Pastel pink",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#dd9ab7"
+ },
+ {
+ "id": "hc_lilac",
+ "label": "Lilac",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#b0a0ce"
+ },
+ {
+ "id": "hc_blue",
+ "label": "Blue",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#4080bb"
+ },
+ {
+ "id": "hc_green",
+ "label": "Green",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ],
+ "swatch": "#548060"
+ }
+ ]
+ },
+ {
+ "id": "distinctive",
+ "label": "Distinctive features",
+ "kind": "media",
+ "max": 2,
+ "options": [
+ {
+ "id": "df_hetero",
+ "label": "Odd eyes",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "df_facetattoo",
+ "label": "Face tattoo",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "df_septum",
+ "label": "Piercing",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "df_ears",
+ "label": "Ear piercing",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "df_slits",
+ "label": "Brow slits",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "df_bleached",
+ "label": "Bleached",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "df_nobrows",
+ "label": "No brows",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "df_grill",
+ "label": "Gold grill",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "df_braces",
+ "label": "Braces",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "df_scar",
+ "label": "Brow scar",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "df_gems",
+ "label": "Face gems",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "df_elf",
+ "label": "Elf ears",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "df_lashes",
+ "label": "Big lashes",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "df_bandage",
+ "label": "Nose tape",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ }
+ ]
+ },
+ {
+ "id": "aesthetic",
+ "label": "Style",
+ "kind": "media",
+ "max": 1,
+ "options": [
+ {
+ "id": "retro",
+ "label": "Retro",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "sporty",
+ "label": "Sporty",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "y2k",
+ "label": "Y2K",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "theatrical",
+ "label": "Theatre",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "goth",
+ "label": "Goth",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "suits",
+ "label": "Suits",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "streetstyle",
+ "label": "Streetstyle",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "casual",
+ "label": "Casual",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ }
+ ]
+ },
+ {
+ "id": "accessory",
+ "label": "Accessories",
+ "kind": "media",
+ "max": 3,
+ "options": [
+ {
+ "id": "acc_none",
+ "label": "None",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "acc_glasses",
+ "label": "Glasses",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "acc_headphones",
+ "label": "Headphones",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "acc_jewelry",
+ "label": "Jewelry",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "acc_hat",
+ "label": "Hat",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ },
+ {
+ "id": "acc_bag",
+ "label": "Bag",
+ "visibleIn": [
+ "normal",
+ "freak",
+ "total"
+ ]
+ }
+ ]
+ }
+];
+
+export const CREATURE_TYPES: CreatureDef[] = [
+ {
+ "id": "insects",
+ "label": "Insect",
+ "species": [
+ {
+ "id": "ant",
+ "label": "Ant"
+ },
+ {
+ "id": "mantis",
+ "label": "Mantis"
+ },
+ {
+ "id": "grasshopper",
+ "label": "Grasshopper"
+ },
+ {
+ "id": "honeybee",
+ "label": "Honeybee"
+ },
+ {
+ "id": "bumblebee",
+ "label": "Bumblebee"
+ },
+ {
+ "id": "butterfly",
+ "label": "Butterfly"
+ },
+ {
+ "id": "moth",
+ "label": "Moth"
+ },
+ {
+ "id": "dragonfly",
+ "label": "Dragonfly"
+ },
+ {
+ "id": "ladybird",
+ "label": "Ladybird"
+ },
+ {
+ "id": "fluffy_tarantula",
+ "label": "Fluffy tarantula"
+ }
+ ]
+ },
+ {
+ "id": "frogs",
+ "label": "Frog",
+ "species": [
+ {
+ "id": "tree_frog",
+ "label": "Tree frog"
+ },
+ {
+ "id": "bullfrog",
+ "label": "Bullfrog"
+ },
+ {
+ "id": "horned_frog",
+ "label": "Horned frog"
+ },
+ {
+ "id": "tomato_frog",
+ "label": "Tomato frog"
+ },
+ {
+ "id": "rain_frog",
+ "label": "Rain frog"
+ }
+ ]
+ },
+ {
+ "id": "cats",
+ "label": "Cat",
+ "species": [
+ {
+ "id": "sphynx",
+ "label": "Sphynx"
+ },
+ {
+ "id": "maine_coon",
+ "label": "Maine Coon"
+ },
+ {
+ "id": "british_shorthair",
+ "label": "British Shorthair"
+ },
+ {
+ "id": "siamese",
+ "label": "Siamese"
+ },
+ {
+ "id": "persian",
+ "label": "Persian"
+ }
+ ]
+ },
+ {
+ "id": "dogs",
+ "label": "Dog",
+ "species": [
+ {
+ "id": "pug",
+ "label": "Pug"
+ },
+ {
+ "id": "borzoi",
+ "label": "Borzoi"
+ },
+ {
+ "id": "dachshund",
+ "label": "Dachshund"
+ },
+ {
+ "id": "poodle",
+ "label": "Poodle"
+ },
+ {
+ "id": "corgi",
+ "label": "Corgi"
+ }
+ ]
+ },
+ {
+ "id": "capybaras",
+ "label": "Rodent",
+ "species": [
+ {
+ "id": "cylindrical",
+ "label": "Cylindrical"
+ },
+ {
+ "id": "barrel",
+ "label": "Barrel"
+ },
+ {
+ "id": "slender",
+ "label": "Slender"
+ },
+ {
+ "id": "pear",
+ "label": "Pear"
+ },
+ {
+ "id": "broad_shoulders",
+ "label": "Broad shoulders"
+ }
+ ]
+ },
+ {
+ "id": "birds",
+ "label": "Bird",
+ "species": [
+ {
+ "id": "goose",
+ "label": "Goose"
+ },
+ {
+ "id": "duck",
+ "label": "Duck"
+ },
+ {
+ "id": "platypus",
+ "label": "Platypus"
+ },
+ {
+ "id": "puffin",
+ "label": "Puffin"
+ },
+ {
+ "id": "pigeon",
+ "label": "Pigeon"
+ }
+ ]
+ }
+];
+
+/** The categories a creature type shows (plus its species and body colour). */
+export const CREATURE_CATEGORIES: string[] = [
+ "gender",
+ "body_type",
+ "height",
+ "proportions",
+ "facial_hair",
+ "distinctive",
+ "accessory",
+ "hair",
+ "hair_colour",
+ "aesthetic"
+];
+
+/** The builder lists these first, then the rest in Higgsfield's order. */
+export const DISPLAY_ORDER_FIRST: string[] = [
+ "gender",
+ "body_type",
+ "hair",
+ "hair_colour",
+ "aesthetic"
+];
+
+/** Shuffle (function `ae` in the bundle): weighted picks (the rest of each category is uniform) and what a reference photo keeps. */
+export const SHUFFLE_RESEARCH = {
+ "keepsWithReference": {
+ "normal": [
+ "gender",
+ "ethnicity_origin_base",
+ "skin_tone",
+ "age",
+ "eye_color"
+ ],
+ "other": [
+ "gender",
+ "ethnicity_origin_base",
+ "age"
+ ]
+ },
+ "weights": {
+ "gender": {
+ "male": 0.67,
+ "female": 0.33
+ },
+ "aesthetic": {
+ "suits": 0.4,
+ "retro": 0.2
+ },
+ "hair": {
+ "hs_lampshade": 0.2
+ }
+ }
+} as const;
+
+/** Higgsfield's conflict messages, word for word. */
+export const CONFLICT_MESSAGES = {
+ "heavyTall": "Heavy build cannot be combined with Tall or Very tall.",
+ "buildLegs": "This build cannot be combined with Short legs or Long limbs in this mode."
+} as const;
diff --git a/src/lib/catalog/models.ts b/src/lib/catalog/models.ts
index 0f7de344..706081d0 100644
--- a/src/lib/catalog/models.ts
+++ b/src/lib/catalog/models.ts
@@ -1406,9 +1406,17 @@ const AI_INFLUENCER: ModelDef = {
kind: "image",
tagline: "An original character sheet from a short brief — human or creature",
badges: ["new"],
- routes: [{ op: "t2i", provider: "higgsfield", endpoint: "higgsfield/ai-influencer", map: { prompt: "brief", seed: "seed", seedRange: [1, 1000000] } }],
+ // The builder (/influencer) sends Higgsfield's own fields as params.extra: tier, selection (category →
+ // option ids), pinned_species and body_color. A photo (Add your face, a reference) goes to image_url,
+ // clothing references to item_image_urls (up to 3).
+ routes: [
+ { op: "t2i", provider: "higgsfield", endpoint: "higgsfield/ai-influencer", map: { prompt: "brief", images: "item_image_urls", maxImages: 3, seed: "seed", seedRange: [1, 1000000] } },
+ { op: "edit", provider: "higgsfield", endpoint: "higgsfield/ai-influencer", map: { prompt: "brief", image: "image_url", moreImages: "item_image_urls", seed: "seed", seedRange: [1, 1000000] } },
+ ],
options: {
seed: true,
+ maxImages: 4,
+ promptOptional: true,
controls: [{ param: "tier", label: "Look", values: ["normal", "freak", "total", "insects", "frogs", "cats", "dogs", "capybaras", "birds"], default: "normal" }],
},
pricing: { unit: "image", usd: 0.05 },
diff --git a/src/lib/catalog/payload.ts b/src/lib/catalog/payload.ts
index a0e05dc8..c58298cc 100644
--- a/src/lib/catalog/payload.ts
+++ b/src/lib/catalog/payload.ts
@@ -228,6 +228,7 @@ export function buildPayload(map: FieldMap, input: GenInput): Record<string, unk
if (map.images && images.length) out[map.images] = images;
if (map.image && images.length) out[map.image] = images[0];
if (map.image2 && images.length > 1) out[map.image2] = images[1];
+ if (map.moreImages && images.length > 1) out[map.moreImages] = images.slice(1);
if (map.endImage && input.endImage) out[map.endImage] = input.endImage;
if (map.mask && input.mask) out[map.mask] = input.mask;
if (map.video && input.video) out[map.video] = input.video;
diff --git a/src/lib/catalog/types.ts b/src/lib/catalog/types.ts
index a4ca85b1..2fcd7fc5 100644
--- a/src/lib/catalog/types.ts
+++ b/src/lib/catalog/types.ts
@@ -279,6 +279,8 @@ export interface FieldMap {
image?: string;
/** Array of images field, e.g. "image_urls" (receives every reference image). */
images?: string;
+ /** Array field that receives every image after the first, which goes to `image` (AI Influencer: image_url + item_image_urls). */
+ moreImages?: string;
endImage?: string;
mask?: string;
/** What the mask's paint means to this API: white (default), black or transparent = change. */
diff --git a/src/lib/influencer.ts b/src/lib/influencer.ts
new file mode 100644
index 00000000..6d6f64a7
--- /dev/null
+++ b/src/lib/influencer.ts
@@ -0,0 +1,908 @@
+/**
+ * The AI Influencer builder (Higgsfield's game-style character builder, docs/research/higgsfield-delta-4.md
+ * §4.5): which options each tier shows, the pick rules and the two conflict messages, Shuffle with the
+ * researched weights, and the prompt compiler (every option → a short English phrase, the tier → a
+ * style clause) plus the plan per engine. Pure: shared by the page and the server.
+ *
+ * The option lists themselves are generated from the research JSON (scripts/gen-influencer-options.py).
+ */
+import {
+ CONFLICT_MESSAGES,
+ CREATURE_CATEGORIES,
+ CREATURE_TYPES,
+ DISPLAY_ORDER_FIRST,
+ INFLUENCER_CATEGORIES,
+ SHUFFLE_RESEARCH,
+ type CreatureType,
+ type HumanTier,
+ type InfluencerCategory,
+ type InfluencerOption,
+ type InfluencerTier,
+} from "@/lib/catalog/influencer-options.generated";
+import type { PlanCaps } from "@/lib/catalog/packs";
+import type { ChainSlot, Engine, GenerationRequest } from "@/lib/catalog/types";
+
+export { CONFLICT_MESSAGES, CREATURE_TYPES, INFLUENCER_CATEGORIES };
+export type { CreatureType, HumanTier, InfluencerCategory, InfluencerOption, InfluencerTier };
+
+export const HUMAN_TIERS: { id: HumanTier; label: string; hint: string }[] = [
+ { id: "normal", label: "Average", hint: "Realistic" },
+ { id: "freak", label: "Bold", hint: "Bold caricature" },
+ { id: "total", label: "Extreme", hint: "Extreme caricature" },
+];
+
+/** Higgsfield's limits: "You can add up to three clothing references"; Direction up to 4,000 characters. */
+export const MAX_CLOTHING = 3;
+export const MAX_DIRECTION = 4000;
+
+export interface InfluencerState {
+ tier: InfluencerTier;
+ /** Picks per category id, in the order they were made. */
+ picks: Record<string, string[]>;
+ /** Creature types: the pinned species (none = any of the type). */
+ species?: string;
+ /** Creature types: body colour as #rrggbb (none = natural). */
+ bodyColor?: string;
+ /** Categories Shuffle leaves as they are. */
+ locked: string[];
+}
+
+export const INFLUENCER_START: InfluencerState = { tier: "normal", picks: {}, locked: [] };
+
+export const isCreature = (tier: InfluencerTier): tier is CreatureType => CREATURE_TYPES.some((c) => c.id === tier);
+export const isTier = (v: unknown): v is InfluencerTier => typeof v === "string" && (HUMAN_TIERS.some((t) => t.id === v) || CREATURE_TYPES.some((c) => c.id === v));
+export const creatureOf = (tier: InfluencerTier) => CREATURE_TYPES.find((c) => c.id === tier);
+
+const CATEGORY = new Map(INFLUENCER_CATEGORIES.map((c) => [c.id, c]));
+export const getCategory = (id: string) => CATEGORY.get(id);
+export const getOption = (category: string, id: string) => CATEGORY.get(category)?.options.find((o) => o.id === id);
+
+/** The rail's order: Character type, then gender, build, hairstyle, hair colour and style, then the rest. */
+export const RAIL_ORDER: string[] = ["tier", ...DISPLAY_ORDER_FIRST, ...INFLUENCER_CATEGORIES.map((c) => c.id).filter((id) => id !== "tier" && !DISPLAY_ORDER_FIRST.includes(id))];
+
+/** Whether a tier shows an option: human tiers read its visibleIn; creature types get every option of their categories but Centaur. */
+export function optionVisible(option: InfluencerOption, tier: InfluencerTier, category: string): boolean {
+ if (isCreature(tier)) return CREATURE_CATEGORIES.includes(category) && option.id !== "pr_centaur";
+ return !option.visibleIn || option.visibleIn.includes(tier);
+}
+
+/** The categories a tier shows (in rail order, without Character type), each with only its visible options. */
+export function categoriesFor(tier: InfluencerTier): InfluencerCategory[] {
+ return RAIL_ORDER.flatMap((id) => {
+ const c = CATEGORY.get(id);
+ if (!c || id === "tier" || (isCreature(tier) && !CREATURE_CATEGORIES.includes(id))) return [];
+ const options = c.options.filter((o) => optionVisible(o, tier, id));
+ return options.length ? [{ ...c, options }] : [];
+ });
+}
+
+// ---------------------------------------------------------------------------
+// Pick rules and conflicts
+
+const TALL = ["h_tall", "h_very_tall"];
+const BIG_BUILDS = ["body_heavy", "body_muscular", "body_ultra"];
+const LEG_PROPORTIONS = ["pr_shortlegs", "pr_longlimbs"];
+const has = (picks: Record<string, string[]>, category: string, ids: string[]) => (picks[category] ?? []).some((x) => ids.includes(x));
+
+/** The conflict in a set of picks, in Higgsfield's words (null when they go together). */
+export function conflictIn(tier: InfluencerTier, picks: Record<string, string[]>): string | null {
+ if (has(picks, "body_type", ["body_heavy"]) && has(picks, "height", TALL)) return CONFLICT_MESSAGES.heavyTall;
+ // "in this mode": Bold, Extreme and the creature types; Average allows it.
+ if (tier !== "normal" && has(picks, "body_type", BIG_BUILDS) && has(picks, "proportions", LEG_PROPORTIONS)) return CONFLICT_MESSAGES.buildLegs;
+ return null;
+}
+
+/** A category's picks after choosing `id`, before conflicts: max 1 replaces, None clears the others, Features keep one per slot. */
+function picked(category: InfluencerCategory, current: string[], id: string): { next: string[]; replaced?: string } {
+ if (current.includes(id)) return { next: current.filter((x) => x !== id) };
+ if (category.max === 1) return { next: [id] };
+ if (id === "acc_none") return { next: [id] };
+ let next = current.filter((x) => x !== "acc_none");
+ const slot = category.options.find((o) => o.id === id)?.slot;
+ if (slot) next = next.filter((x) => category.options.find((o) => o.id === x)?.slot !== slot);
+ next = [...next, id];
+ // Over the limit: the oldest pick makes room.
+ return next.length > category.max ? { next: next.slice(1), replaced: next[0] } : { next };
+}
+
+/** Why `id` can't be picked right now (a conflict message), or null. Unpicking never conflicts. */
+export function conflictFor(state: InfluencerState, category: string, id: string): string | null {
+ const c = CATEGORY.get(category);
+ if (!c || (state.picks[category] ?? []).includes(id)) return null;
+ return conflictIn(state.tier, { ...state.picks, [category]: picked(c, state.picks[category] ?? [], id).next });
+}
+
+export interface PickResult {
+ state: InfluencerState;
+ /** The pick was refused: Higgsfield's conflict message. */
+ conflict?: string;
+ /** Said when an older pick made room ("Up to 2 — Long limbs was replaced"). */
+ note?: string;
+}
+
+/** Pick or unpick an option, following Higgsfield's rules. */
+export function togglePick(state: InfluencerState, category: string, id: string): PickResult {
+ const c = CATEGORY.get(category);
+ const option = c?.options.find((o) => o.id === id);
+ if (!c || !option || !optionVisible(option, state.tier, category)) return { state };
+ const conflict = conflictFor(state, category, id);
+ if (conflict) return { state, conflict };
+ const { next, replaced } = picked(c, state.picks[category] ?? [], id);
+ const picks = { ...state.picks };
+ if (next.length) picks[category] = next;
+ else delete picks[category];
+ const was = replaced ? c.options.find((o) => o.id === replaced)?.label : undefined;
+ return { state: { ...state, picks }, ...(was && { note: `${c.label}: up to ${c.max} — ${was} was replaced` }) };
+}
+
+/** Switch the character type: picks the new tier doesn't show are dropped (named in `dropped`), and so are new conflicts. */
+export function setTier(state: InfluencerState, tier: InfluencerTier): { state: InfluencerState; dropped: string[] } {
+ if (tier === state.tier) return { state, dropped: [] };
+ const dropped: string[] = [];
+ const picks: Record<string, string[]> = {};
+ for (const [cat, ids] of Object.entries(state.picks)) {
+ const c = CATEGORY.get(cat);
+ if (!c) continue;
+ const keep = ids.filter((id) => {
+ const o = c.options.find((x) => x.id === id);
+ const ok = !!o && optionVisible(o, tier, cat);
+ if (!ok && o) dropped.push(o.label);
+ return ok;
+ });
+ if (keep.length) picks[cat] = keep;
+ }
+ // Average allowed a big build with Short legs; Bold doesn't: the proportions give way (and a height to Heavy).
+ for (const [cat, ids] of [["height", TALL], ["proportions", LEG_PROPORTIONS]] as const) {
+ if (!conflictIn(tier, picks)) break;
+ const gone = (picks[cat] ?? []).filter((x) => ids.includes(x));
+ if (!gone.length) continue;
+ dropped.push(...gone.map((x) => getOption(cat, x)?.label ?? x));
+ picks[cat] = (picks[cat] ?? []).filter((x) => !ids.includes(x));
+ if (!picks[cat].length) delete picks[cat];
+ }
+ const creature = isCreature(tier);
+ const sameType = creature && state.tier === tier;
+ return {
+ state: { tier, picks, locked: state.locked, ...(sameType && state.species && { species: state.species }), ...(creature && state.bodyColor && { bodyColor: state.bodyColor }) },
+ dropped,
+ };
+}
+
+/** Reset all: no picks and nothing locked; the character type stays. */
+export const resetPicks = (state: InfluencerState): InfluencerState => ({ tier: state.tier, picks: {}, locked: [] });
+
+export function toggleLock(state: InfluencerState, category: string): InfluencerState {
+ return { ...state, locked: state.locked.includes(category) ? state.locked.filter((x) => x !== category) : [...state.locked, category] };
+}
+
+// ---------------------------------------------------------------------------
+// Shuffle
+
+/** A small seeded generator (mulberry32): the same seed shuffles the same character. */
+export function seededRandom(seed: number): () => number {
+ let a = seed >>> 0;
+ return () => {
+ a = (a + 0x6d2b79f5) >>> 0;
+ let t = a;
+ t = Math.imul(t ^ (t >>> 15), t | 1);
+ t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
+ };
+}
+
+const uniform = <T>(xs: T[], rand: () => number): T | undefined => (xs.length ? xs[Math.min(xs.length - 1, Math.floor(rand() * xs.length))] : undefined);
+
+/** A weighted pick: the listed ids get their weight, every other option shares what is left equally. */
+function weighted(options: string[], weights: Record<string, number>, rand: () => number): string | undefined {
+ const listed = options.filter((o) => o in weights);
+ const rest = options.filter((o) => !(o in weights));
+ const listedTotal = listed.reduce((n, o) => n + weights[o], 0);
+ const restWeight = rest.length ? Math.max(0, 1 - listedTotal) / rest.length : 0;
+ const total = listedTotal + restWeight * rest.length;
+ if (!total) return uniform(options, rand);
+ let r = rand() * total;
+ for (const o of options) {
+ r -= o in weights ? weights[o] : restWeight;
+ if (r < 0) return o;
+ }
+ return options[options.length - 1];
+}
+
+/** Several picks from different Features slots (or just different options), without repeats. */
+function several(c: InfluencerCategory, count: number, rand: () => number): string[] {
+ const out: string[] = [];
+ let pool = c.options;
+ while (out.length < count && pool.length) {
+ const o = uniform(pool, rand)!;
+ out.push(o.id);
+ pool = pool.filter((x) => x.id !== o.id && (!o.slot || x.slot !== o.slot));
+ }
+ return out;
+}
+
+/** Categories Shuffle fills before others: build reads height, proportions and neck; facial hair reads gender. */
+const SHUFFLE_ORDER = ["gender", "height", "proportions", "freak_neck"];
+const LATE = ["body_type", "facial_hair"];
+
+export interface ShuffleOptions {
+ /** A reference or face photo is in: it keeps gender, ethnicity and age (and skin and eye colour in Average). */
+ reference?: boolean;
+}
+
+/**
+ * Higgsfield's Shuffle: keeps locked picks (and, with a photo, what the photo decides); gender is male 67%,
+ * female 33%; style Suits 40%, Retro 20%, else any other; hairstyle Bob 20% where Bob shows; build is never
+ * Curvy, never Ultra Muscular in Average, never Heavy with Tall heights or a Tiny waist, never Centaur with
+ * an Egg body or Ultra Muscular with a Long neck (nor any pick that would conflict); facial hair is Clean
+ * unless the gender is male or trans man. How many multi-pick options it adds is Fuobe's choice (up to 1
+ * proportion, 1–2 features, up to 1 distinctive feature, 1 accessory).
+ */
+export function shuffleInfluencer(state: InfluencerState, rand: () => number, opts: ShuffleOptions = {}): InfluencerState {
+ const keep = new Set(state.locked);
+ if (opts.reference) for (const k of SHUFFLE_RESEARCH.keepsWithReference[state.tier === "normal" ? "normal" : "other"]) keep.add(k);
+ const picks: Record<string, string[]> = {};
+ for (const k of keep) if (state.picks[k]?.length) picks[k] = state.picks[k];
+ const cats = categoriesFor(state.tier);
+ const rank = (id: string) => (SHUFFLE_ORDER.includes(id) ? SHUFFLE_ORDER.indexOf(id) - 10 : LATE.includes(id) ? 10 + LATE.indexOf(id) : 0);
+ const ordered = [...cats].sort((a, b) => rank(a.id) - rank(b.id));
+ const W = SHUFFLE_RESEARCH.weights;
+ for (const c of ordered) {
+ if (keep.has(c.id)) continue;
+ const ids = c.options.map((o) => o.id);
+ let pick: string[] = [];
+ switch (c.id) {
+ case "gender":
+ pick = [weighted(ids.filter((id) => id in W.gender), W.gender, rand) ?? uniform(ids, rand)!];
+ break;
+ case "aesthetic":
+ pick = [weighted(ids, W.aesthetic, rand)!];
+ break;
+ case "hair":
+ pick = [weighted(ids, W.hair, rand)!];
+ break;
+ case "body_type": {
+ const neck = picks.freak_neck?.[0];
+ const allowed = ids.filter(
+ (id) =>
+ id !== "body_curvy" &&
+ !(id === "body_ultra" && state.tier === "normal") &&
+ !(id === "body_heavy" && (has(picks, "height", TALL) || has(picks, "proportions", ["pr_waist"]))) &&
+ !(id === "pr_centaur" && has(picks, "proportions", ["pr_egg"])) &&
+ !(id === "body_ultra" && neck === "neck_long") &&
+ !conflictIn(state.tier, { ...picks, body_type: [id] }),
+ );
+ const one = uniform(allowed, rand);
+ pick = one ? [one] : [];
+ break;
+ }
+ case "facial_hair": {
+ const g = picks.gender?.[0];
+ pick = g === "male" || g === "trans_man" ? [uniform(ids, rand)!] : ids.includes("fh_none") ? ["fh_none"] : [];
+ break;
+ }
+ case "proportions":
+ pick = rand() < 0.5 ? several(c, 1, rand) : [];
+ break;
+ case "freak_face":
+ pick = several(c, 1 + Math.floor(rand() * 2), rand);
+ break;
+ case "distinctive":
+ pick = rand() < 0.4 ? several(c, 1, rand) : [];
+ break;
+ default:
+ pick = [uniform(ids, rand)!];
+ }
+ if (pick.length) picks[c.id] = pick;
+ }
+ return { ...state, picks };
+}
+
+// ---------------------------------------------------------------------------
+// The prompt compiler
+
+/**
+ * Every option as a short English phrase. Hairstyles take the hair colour where "{color}" is
+ * (an empty string when none is picked); eye shapes and hair colours are adjectives.
+ */
+export const PHRASES: Record<string, string> = {
+ // gender (people; creatures read CREATURE_GENDER)
+ female: "woman",
+ male: "man",
+ trans_man: "trans man",
+ trans_woman: "trans woman",
+ non_binary: "non-binary person",
+ // ethnicity
+ african: "African",
+ east_asian: "East Asian",
+ european: "European",
+ indian: "Indian",
+ middle_eastern: "Middle Eastern",
+ latin_american: "mixed-heritage Latin American",
+ // age
+ adult: "young adult",
+ mature: "middle-aged",
+ senior: "elderly",
+ // skin
+ st_porcelain: "porcelain skin",
+ st_fair: "fair skin",
+ st_light: "light skin",
+ st_olive: "olive skin",
+ st_tan: "tan skin",
+ st_brown: "brown skin",
+ st_deep: "deep brown skin",
+ st_ebony: "very dark ebony skin",
+ // height
+ h_short: "short and small",
+ h_average: "average height",
+ h_tall: "tall",
+ h_very_tall: "very tall",
+ // build
+ body_slim: "a slim build",
+ body_athletic: "an athletic build",
+ body_muscular: "a muscular build",
+ body_curvy: "a curvy figure",
+ body_heavy: "a heavy, large build",
+ body_ultra: "an ultra-muscular bodybuilder physique",
+ pr_centaur: "a centaur body: a human torso on a horse's body",
+ // proportions
+ pr_longlimbs: "long limbs",
+ pr_shortlegs: "short legs",
+ pr_shoulders: "broad shoulders",
+ pr_waist: "a tiny waist",
+ pr_egg: "an egg-shaped body",
+ // head
+ head_oval: "an oval head",
+ head_long: "a long head",
+ head_tiny: "a tiny head",
+ head_forehead: "a high forehead",
+ head_ancient: "a caveman-like heavy brow and skull",
+ head_herojaw: "a chiseled gigachad jaw",
+ head_megachin: "a giant mega jaw",
+ head_round: "a round face",
+ head_square: "a square face",
+ head_heart: "a heart-shaped face",
+ // neck
+ neck_normal: "a normal neck",
+ neck_column: "a thick column neck",
+ neck_long: "a long neck",
+ neck_short: "a short neck",
+ // eye shape (adjectives)
+ es_almond: "almond-shaped",
+ es_round: "round",
+ es_monolid: "monolid",
+ es_close: "close-set",
+ es_wide: "wide-set",
+ es_uneven: "slightly uneven",
+ es_large: "large",
+ es_huge: "huge cartoonish",
+ es_hooded: "hooded",
+ es_upturned: "upturned",
+ es_downturned: "downturned",
+ // eye colour (adjectives)
+ eye_black: "black",
+ eye_brown: "brown",
+ eye_hazel: "hazel",
+ eye_green: "green",
+ eye_blue: "blue",
+ eye_ice_blue: "ice-blue",
+ eye_amber: "amber",
+ eye_grey: "grey",
+ // features
+ fn_freckles: "freckles",
+ fn_dimples: "dimples",
+ fn_eyebags: "heavy eye bags",
+ ff_marks_12: "rosy blushing cheeks",
+ fn_cheekbones: "high cheekbones",
+ fn_fulllips: "full lips",
+ fn_thickbrows: "thick brows",
+ fn_mole: "a beauty mark",
+ ff_nose_0: "a big potato nose",
+ ff_nose_1: "a button nose",
+ ff_nose_2: "a pointy nose",
+ fn_tinynose: "a tiny nose",
+ ff_lips_3: "pouty lips",
+ ff_lips_4: "a tiny pursed mouth",
+ fn_widemouth: "a wide mouth",
+ ff_brows_5: "a unibrow",
+ ff_brows_6: "thin, high-arched brows",
+ ff_brows_7: "bushy brush brows",
+ ff_ears_8: "jug ears",
+ ff_ears_9: "uneven ears",
+ ff_teeth_10: "a gap between the front teeth",
+ ff_teeth_11: "buck teeth",
+ fn_pointychin: "a pointy chin",
+ ff_chin_13: "a weak, receding chin",
+ ff_forehead_14: "a big forehead",
+ // facial hair
+ fh_none: "clean-shaven",
+ fh_stubble: "stubble",
+ fh_beard: "a full beard",
+ fh_goatee: "a goatee",
+ fh_moustache: "a moustache",
+ fh_pencil: "a pencil moustache",
+ fh_pushbroom: "a push-broom moustache",
+ fh_braid: "a braided beard",
+ // hairstyles ({color} = the hair colour and a space, or nothing)
+ hs_lampshade: "a {color}lampshade bob",
+ hair_bald: "a bald head",
+ hair_buzz: "a {color}buzz cut",
+ hair_bowl: "a {color}bowl cut",
+ hair_mullet: "a {color}mullet",
+ hair_braids: "{color}braids",
+ hair_pigtails: "{color}pigtails",
+ hair_afro: "a {color}afro",
+ hair_punk: "a {color}mohawk",
+ hs_pompadour: "big, voluminous {color}waves",
+ hs_beehive: "a tall {color}beehive updo",
+ hs_dome: "a {color}dome-shaped perm",
+ hair_long: "long {color}hair",
+ hair_short: "short {color}hair",
+ hs_horns: "{color}hair shaped into two horns",
+ hs_softserve: "{color}hair piled up in a soft-serve swirl",
+ hs_sphere: "{color}curls in a perfect sphere",
+ hs_mouse: "two round {color}mouse-ear hair puffs",
+ hs_wings: "{color}hair swept out like wings",
+ hs_hedgehog: "{color}hair in hedgehog spikes",
+ hs_tufts: "{color}hair in side tufts",
+ hs_stairs: "{color}hair cut in stair steps",
+ hs_shelf: "a flat {color}shelf bob",
+ hs_corkscrews: "{color}corkscrew curls",
+ hs_sidecoil: "a single {color}side coil of hair",
+ hs_mushroom: "a {color}mushroom haircut",
+ // hair colour (adjectives)
+ hc_black: "jet black",
+ hc_darkbrown: "dark brown",
+ hc_chestnut: "chestnut",
+ hc_ginger: "ginger",
+ hc_red: "red",
+ hc_blonde: "blonde",
+ hc_platinum: "platinum blonde",
+ hc_grey: "grey",
+ hc_white: "white",
+ hc_pink: "pastel pink",
+ hc_lilac: "lilac",
+ hc_blue: "blue",
+ hc_green: "green",
+ // distinctive features
+ df_hetero: "heterochromia (two different eye colours)",
+ df_facetattoo: "a small face tattoo",
+ df_septum: "a septum piercing",
+ df_ears: "ear piercings",
+ df_slits: "brow slits",
+ df_bleached: "bleached eyebrows",
+ df_nobrows: "no eyebrows",
+ df_grill: "a gold grill on the teeth",
+ df_braces: "braces on the teeth",
+ df_scar: "a scar through one eyebrow",
+ df_gems: "face gems",
+ df_elf: "pointed elf ears",
+ df_lashes: "big dramatic lashes",
+ df_bandage: "a strip of tape across the nose",
+ // style
+ retro: "a retro vintage outfit",
+ sporty: "a sporty athleisure outfit",
+ y2k: "a Y2K outfit",
+ theatrical: "a theatrical stage costume",
+ goth: "an all-black goth outfit",
+ suits: "a tailored suit",
+ streetstyle: "a streetwear outfit",
+ casual: "a casual everyday outfit",
+ // accessories
+ acc_none: "no accessories",
+ acc_glasses: "glasses",
+ acc_headphones: "headphones",
+ acc_jewelry: "jewelry",
+ acc_hat: "a hat",
+ acc_bag: "a bag",
+};
+
+const CREATURE_GENDER: Record<string, string> = { female: "female", male: "male", trans_man: "trans-masculine", trans_woman: "trans-feminine", non_binary: "non-binary" };
+const CREATURE_NOUN: Record<CreatureType, string> = { insects: "insect", frogs: "frog", cats: "cat", dogs: "dog", capybaras: "capybara", birds: "bird" };
+const CREATURE_COAT: Record<CreatureType, string> = { insects: "body", frogs: "skin", cats: "fur", dogs: "fur", capybaras: "fur", birds: "feathers" };
+
+/** Each species as the prompt names it (creature types' species ids, from the research). */
+export const SPECIES_PHRASES: Record<string, string> = {
+ // insects
+ ant: "ant",
+ mantis: "praying mantis",
+ grasshopper: "grasshopper",
+ honeybee: "honeybee",
+ bumblebee: "bumblebee",
+ butterfly: "butterfly",
+ moth: "moth",
+ dragonfly: "dragonfly",
+ ladybird: "ladybird",
+ fluffy_tarantula: "fluffy tarantula",
+ // frogs
+ tree_frog: "tree frog",
+ bullfrog: "bullfrog",
+ horned_frog: "horned frog",
+ tomato_frog: "tomato frog",
+ rain_frog: "rain frog",
+ // cats
+ sphynx: "Sphynx cat",
+ maine_coon: "Maine Coon cat",
+ british_shorthair: "British Shorthair cat",
+ siamese: "Siamese cat",
+ persian: "Persian cat",
+ // dogs
+ pug: "pug",
+ borzoi: "borzoi",
+ dachshund: "dachshund",
+ poodle: "poodle",
+ corgi: "corgi",
+ // rodents (capybara body shapes)
+ cylindrical: "cylindrical capybara",
+ barrel: "barrel-shaped capybara",
+ slender: "slender capybara",
+ pear: "pear-shaped capybara",
+ broad_shoulders: "broad-shouldered capybara",
+ // birds
+ goose: "goose",
+ duck: "duck",
+ platypus: "platypus",
+ puffin: "puffin",
+ pigeon: "pigeon",
+};
+
+/** "Maine Coon cat", "tree frog", "barrel-shaped capybara", or the type ("cat") when no species is pinned. */
+export function speciesNoun(tier: CreatureType, species?: string): string {
+ const ok = !!species && !!creatureOf(tier)?.species.some((s) => s.id === species);
+ return (ok && SPECIES_PHRASES[species!]) || CREATURE_NOUN[tier];
+}
+
+/** The nearest everyday name for a body colour (#hex), for the prompt: "deep teal", "pale pink". */
+export function colorName(hex: string): string {
+ const m = /^#?([0-9a-f]{6})$/i.exec(hex.trim());
+ if (!m) return "";
+ const n = parseInt(m[1], 16);
+ const [r, g, b] = [(n >> 16) & 255, (n >> 8) & 255, n & 255].map((v) => v / 255);
+ const max = Math.max(r, g, b);
+ const min = Math.min(r, g, b);
+ const l = (max + min) / 2;
+ const d = max - min;
+ const s = d === 0 ? 0 : d / (1 - Math.abs(2 * l - 1));
+ if (s < 0.15 || d < 0.06) return l < 0.15 ? "black" : l > 0.88 ? "white" : l < 0.4 ? "dark grey" : l > 0.7 ? "light grey" : "grey";
+ let h = max === r ? ((g - b) / d) % 6 : max === g ? (b - r) / d + 2 : (r - g) / d + 4;
+ h = (h * 60 + 360) % 360;
+ const hue =
+ h < 15 || h >= 345 ? "red" : h < 40 ? (l < 0.45 ? "brown" : "orange") : h < 65 ? (l < 0.4 ? "olive" : "yellow") : h < 160 ? "green" : h < 190 ? "teal" : h < 250 ? "blue" : h < 290 ? "purple" : "pink";
+ const shade = l < 0.3 ? "deep " : l > 0.75 ? "pale " : "";
+ return `${shade}${hue}`;
+}
+
+const pick1 = (state: InfluencerState, category: string) => state.picks[category]?.[0];
+const phrases = (state: InfluencerState, category: string) => (state.picks[category] ?? []).map((id) => PHRASES[id]).filter(Boolean);
+const an = (word: string) => (/^[aeiou]/i.test(word) && !/^(uni|eu|one)/i.test(word) ? "an" : "a");
+/** "a afro" → "an afro" after a colour was (or wasn't) put in front. */
+const articles = (s: string) => s.replace(/\b(a|an) (\w)/g, (_, _a: string, w: string) => `${an(w)} ${w}`);
+const list = (xs: string[]) => (xs.length < 2 ? (xs[0] ?? "") : `${xs.slice(0, -1).join(", ")} and ${xs[xs.length - 1]}`);
+
+function hairPhrase(state: InfluencerState): string | undefined {
+ const style = pick1(state, "hair");
+ const color = pick1(state, "hair_colour");
+ const c = color ? PHRASES[color] : "";
+ if (!style) return c ? `${c} hair` : undefined;
+ if (style === "hair_bald") return PHRASES[style];
+ return articles(PHRASES[style].replace("{color}", c ? `${c} ` : ""));
+}
+
+function eyesPhrase(state: InfluencerState): string | undefined {
+ const shape = pick1(state, "eye_shape");
+ const color = pick1(state, "eye_color");
+ if (!shape && !color) return undefined;
+ return [shape && PHRASES[shape], color && PHRASES[color], "eyes"].filter(Boolean).join(" ");
+}
+
+/** Who it is: "a young adult East Asian woman", "a female anthropomorphic Maine Coon cat with pale pink fur". */
+function subject(state: InfluencerState): string {
+ if (isCreature(state.tier)) {
+ const g = pick1(state, "gender");
+ const noun = `${g ? `${CREATURE_GENDER[g]} ` : ""}anthropomorphic ${speciesNoun(state.tier, state.species)}`;
+ const color = state.bodyColor ? colorName(state.bodyColor) : "";
+ return `${an(noun)} ${noun}${color ? ` with ${color} ${CREATURE_COAT[state.tier]}` : ""}`;
+ }
+ const words = [pick1(state, "age"), pick1(state, "ethnicity_origin_base")].filter(Boolean).map((id) => PHRASES[id!]);
+ const g = pick1(state, "gender");
+ words.push(g ? PHRASES[g] : "person");
+ const s = words.join(" ");
+ return `${an(s)} ${s}`;
+}
+
+/**
+ * The character in one sentence, from the picks (the live summary, and the description every
+ * prompt starts from): "A young adult European man, tall, with an athletic build, …, wearing a tailored suit."
+ */
+export function describeInfluencer(state: InfluencerState): string {
+ const body = [pick1(state, "height") && PHRASES[pick1(state, "height")!], ...phrases(state, "skin_tone")].filter(Boolean);
+ const withs = [
+ ...phrases(state, "body_type"),
+ ...phrases(state, "proportions"),
+ ...phrases(state, "freak_head"),
+ ...phrases(state, "freak_neck"),
+ eyesPhrase(state),
+ ...phrases(state, "freak_face"),
+ hairPhrase(state),
+ ...(pick1(state, "facial_hair") && pick1(state, "facial_hair") !== "fh_none" ? phrases(state, "facial_hair") : []),
+ ...phrases(state, "distinctive"),
+ ].filter((x): x is string => !!x);
+ const accessories = state.picks.accessory ?? [];
+ const parts = [subject(state), ...body];
+ if (pick1(state, "facial_hair") === "fh_none") parts.push("clean-shaven");
+ if (withs.length) parts.push(`with ${list(withs)}`);
+ const outfit = phrases(state, "aesthetic")[0];
+ if (outfit) parts.push(`wearing ${outfit}`);
+ if (accessories.includes("acc_none")) parts.push("no accessories");
+ else if (accessories.length) parts.push(`${outfit ? "with" : "wearing"} ${list(phrases(state, "accessory"))}`);
+ const s = parts.join(", ");
+ return `${s.charAt(0).toUpperCase()}${s.slice(1)}.`;
+}
+
+/** The tier's style clause: realistic, bold caricature, extreme caricature, or anthropomorphic {species}. */
+export function tierStyle(state: InfluencerState): string {
+ if (isCreature(state.tier)) {
+ const noun = speciesNoun(state.tier, state.species);
+ return `Anthropomorphic ${noun}: an upright ${noun} character with a human-like body and posture, photographed for real, with true-to-life ${CREATURE_COAT[state.tier]} texture`;
+ }
+ if (state.tier === "freak") return "Bold caricature: photographic, but the chosen features are exaggerated for a memorable, slightly cartoonish look";
+ if (state.tier === "total") return "Extreme caricature: wildly exaggerated proportions and features, like a sculpted caricature brought to life, still photographic";
+ return "Realistic: a photorealistic person with natural proportions and real skin texture";
+}
+
+/** What the character's photos are: Add your face (their face goes on the character) or a reference (its look). */
+export type InfluencerStart = "scratch" | "reference" | "face";
+
+export interface CompileInput {
+ state: InfluencerState;
+ direction?: string;
+ start?: InfluencerStart;
+ /** How many clothing references go with the prompt (after the photo, if any). */
+ clothing?: number;
+}
+
+const tidy = (s?: string) => s?.trim().replace(/\s+/g, " ").replace(/[.\s]+$/, "");
+const imageList = (from: number, n: number) => (n === 1 ? `image ${from}` : `images ${list(Array.from({ length: n }, (_, i) => String(from + i)))}`);
+
+/**
+ * The whole prompt for an image model that draws the sheet itself (Nano Banana Pro, Seedream 5.0): a white
+ * background portrait plus full-body views, the character, the tier's style, the photos' roles and the Direction.
+ */
+export function compileSheetPrompt({ state, direction, start = "scratch", clothing = 0 }: CompileInput): string {
+ const photo = start !== "scratch";
+ return [
+ "Character sheet of an original AI influencer on a pure white background: a close-up portrait of the face, then full-body front, three-quarter, side profile and back views side by side",
+ `The character: ${tidy(describeInfluencer(state))}`,
+ tierStyle(state),
+ start === "face" && "The character has the face of the person in image 1: keep their identity and facial features exactly",
+ start === "reference" && "Base the character on the one in image 1 (face and overall look), changed as described",
+ clothing > 0 && `They wear the clothing shown in ${imageList(photo ? 2 : 1, clothing)}`,
+ tidy(direction) && `Direction: ${tidy(direction)}`,
+ "The same face, hair, body and outfit in every view; no text, no labels",
+ ]
+ .filter(Boolean)
+ .join(". ")
+ .concat(".");
+}
+
+/** The character for the open Soul Cast sheet workflow, whose graph adds the turnaround wording itself. */
+export function compileCastPrompt({ state, direction }: CompileInput): string {
+ return [tidy(describeInfluencer(state)), tierStyle(state), tidy(direction)].filter(Boolean).join(". ").concat(".");
+}
+
+/** Qwen-Image-Edit's instruction for the open engine's second step: the sheet is image 1, the photo and clothing follow. */
+export function compileDressPrompt({ start = "scratch", clothing = 0 }: CompileInput): string {
+ const photo = start !== "scratch";
+ return [
+ "Image 1 is a character turnaround sheet",
+ start === "face" && "Give the character in every view the face of the person in image 2: the same identity, facial features and skin tone",
+ start === "reference" && "Redraw the character in every view to look like the character in image 2: their face, hair and overall look",
+ clothing > 0 && `Dress the character in every view in the clothing shown in ${imageList(photo ? 3 : 2, clothing)}`,
+ "Keep the poses, the layout, the number of views and the white background of image 1 unchanged",
+ ]
+ .filter(Boolean)
+ .join(". ")
+ .concat(".");
+}
+
+/** Higgsfield AI Influencer's own fields: tier, selection (category → option ids), pinned_species, body_color. */
+export function higgsfieldFields(state: InfluencerState): Record<string, unknown> {
+ const creature = isCreature(state.tier);
+ const selection = Object.fromEntries(Object.entries(state.picks).filter(([k, v]) => k !== "tier" && v.length));
+ const species = creature && creatureOf(state.tier)?.species.some((s) => s.id === state.species) ? state.species : undefined;
+ return { tier: state.tier, selection, ...(species && { pinned_species: species }), ...(creature && state.bodyColor && { body_color: state.bodyColor.toLowerCase() }) };
+}
+
+/** The picks as chips for the summary: [Category label, "Option, Option"]. */
+export function summaryRows(state: InfluencerState): { category: string; label: string; options: string }[] {
+ return categoriesFor(state.tier).flatMap((c) => {
+ const ids = state.picks[c.id] ?? [];
+ const labels = ids.map((id) => c.options.find((o) => o.id === id)?.label).filter(Boolean);
+ return labels.length ? [{ category: c.id, label: c.label, options: labels.join(", ") }] : [];
+ });
+}
+
+/** A starting name for the saved character: "Suits mullet", "Maine Coon cat", "Bold character". */
+export function influencerName(state: InfluencerState): string {
+ if (isCreature(state.tier)) {
+ const s = speciesNoun(state.tier, state.species);
+ return `${s.charAt(0).toUpperCase()}${s.slice(1)}`;
+ }
+ const style = getOption("aesthetic", pick1(state, "aesthetic") ?? "")?.label;
+ const hair = getOption("hair", pick1(state, "hair") ?? "")?.label;
+ if (style && hair) return `${style} · ${hair}`;
+ return `${HUMAN_TIERS.find((t) => t.id === state.tier)?.label ?? "My"} influencer`;
+}
+
+// ---------------------------------------------------------------------------
+// Checking what comes in
+
+const HEX = /^#[0-9a-f]{6}$/i;
+
+/**
+ * A state from the browser made safe: unknown categories and options, options the tier doesn't show and
+ * picks over a category's limit are dropped (Features: one per slot). A conflict is reported, not fixed.
+ */
+export function cleanState(raw: unknown): { state: InfluencerState; problem: string | null } {
+ const r = (raw && typeof raw === "object" ? raw : {}) as Record<string, unknown>;
+ const tier = isTier(r.tier) ? r.tier : "normal";
+ const picks: Record<string, string[]> = {};
+ const rawPicks = (r.picks && typeof r.picks === "object" ? r.picks : {}) as Record<string, unknown>;
+ for (const c of categoriesFor(tier)) {
+ const ids = Array.isArray(rawPicks[c.id]) ? (rawPicks[c.id] as unknown[]).filter((x): x is string => typeof x === "string") : [];
+ let next: string[] = [];
+ for (const id of ids) if (c.options.some((o) => o.id === id) && !next.includes(id)) next = picked(c, next, id).next;
+ if (next.length) picks[c.id] = next;
+ }
+ const creature = isCreature(tier);
+ const species = creature && typeof r.species === "string" && creatureOf(tier)?.species.some((s) => s.id === r.species) ? r.species : undefined;
+ const bodyColor = creature && typeof r.bodyColor === "string" && HEX.test(r.bodyColor) ? r.bodyColor.toLowerCase() : undefined;
+ const locked = Array.isArray(r.locked) ? r.locked.filter((x): x is string => typeof x === "string" && CATEGORY.has(x)) : [];
+ const state: InfluencerState = { tier, picks, locked, ...(species && { species }), ...(bodyColor && { bodyColor }) };
+ return { state, problem: conflictIn(tier, picks) };
+}
+
+// ---------------------------------------------------------------------------
+// The plan per engine
+
+/** The cloud models that can draw the sheet: Higgsfield's own (with a key), then the two the research names. */
+export const INFLUENCER_CLOUD_MODELS = ["ai-influencer", "nano-banana-pro", "seedream-5-pro"] as const;
+export const INFLUENCER_OPEN_MODELS = { sheet: "oss-zimage-soul-cast", edit: "oss-qwen-edit" } as const;
+/** Qwen-Image-Edit 2511 takes three images: the sheet, then the photo and clothing. */
+const OPEN_EDIT_IMAGES = 3;
+
+export interface InfluencerRun {
+ engine: Engine;
+ state: InfluencerState;
+ direction?: string;
+ start: InfluencerStart;
+ /** The reference or face photo (start "reference" / "face"). */
+ photo?: string;
+ /** Up to three clothing references. */
+ clothing?: string[];
+ /** The cloud model asked for (INFLUENCER_CLOUD_MODELS); the best available one when left out. */
+ modelId?: string;
+}
+
+/** A step of the run, as createPipeline takes it (src/server/chains.ts). */
+export interface InfluencerStep {
+ key: string;
+ request: GenerationRequest;
+ after?: string;
+ chain?: ChainSlot[];
+}
+
+export interface InfluencerPlan {
+ steps: InfluencerStep[];
+ /** The model that makes the sheet you get. */
+ modelId: string;
+ notes: string[];
+}
+
+export const FEATURE = "influencer";
+
+/** Why a run can't start yet (null when it can): Higgsfield's words where it has them. */
+export function influencerBlocker(run: Pick<InfluencerRun, "state" | "direction" | "start" | "photo" | "clothing">): string | null {
+ const conflict = conflictIn(run.state.tier, run.state.picks);
+ if (conflict) return conflict;
+ if ((run.direction ?? "").length > MAX_DIRECTION) return "Keep the direction under 4,000 characters";
+ if ((run.clothing?.length ?? 0) > MAX_CLOTHING) return "You can add up to three clothing references";
+ if (run.start === "face" && !run.photo) return "Add your photo first";
+ if (run.start === "reference" && !run.photo) return "Add a reference image first";
+ return null;
+}
+
+/**
+ * The jobs for a run. Cloud: Higgsfield's AI Influencer with its own fields (a key, and not turned off),
+ * else Nano Banana Pro or Seedream 5.0 with the compiled prompt, the photo and clothing as references.
+ * Open: the Soul Cast sheet workflow (Z-Image Turbo) draws the character; with a photo or clothing,
+ * Qwen-Image-Edit 2511 then puts your face and clothes on that sheet, so the sheet keeps its wide shape.
+ */
+export function planInfluencer(run: InfluencerRun, caps: PlanCaps): InfluencerPlan {
+ const blocker = influencerBlocker(run);
+ if (blocker) throw new Error(blocker);
+ const { state, start } = run;
+ const direction = run.direction?.trim() || undefined;
+ const photo = start === "scratch" ? undefined : run.photo;
+ const clothing = run.clothing ?? [];
+ const title = influencerName(state);
+ const notes: string[] = [];
+
+ if (run.engine === "open") {
+ const sheet: InfluencerStep = {
+ key: "sheet",
+ request: { feature: FEATURE, modelId: INFLUENCER_OPEN_MODELS.sheet, op: "t2i", prompt: compileCastPrompt({ state, direction }), params: { numOutputs: 1 }, title },
+ };
+ if (!photo && !clothing.length) return { steps: [sheet], modelId: INFLUENCER_OPEN_MODELS.sheet, notes };
+ const room = OPEN_EDIT_IMAGES - 1 - (photo ? 1 : 0);
+ const used = clothing.slice(0, room);
+ if (clothing.length > used.length) notes.push(`Qwen-Image-Edit takes 3 images (the sheet${photo ? ", your photo" : ""} and clothing) — the first ${used.length === 1 ? "clothing reference is" : `${used.length} clothing references are`} used`);
+ notes.push(photo ? (start === "face" ? "Two steps: Z-Image Turbo draws the sheet, then Qwen-Image-Edit 2511 puts your face on it" : "Two steps: Z-Image Turbo draws the sheet, then Qwen-Image-Edit 2511 matches it to your reference") : "Two steps: Z-Image Turbo draws the sheet, then Qwen-Image-Edit 2511 dresses it in your clothing");
+ return {
+ steps: [
+ { ...sheet, request: { ...sheet.request, feature: `${FEATURE}-step`, title: `${title} · sheet` } },
+ {
+ key: "dress",
+ after: "sheet",
+ chain: [{ slot: "images", position: "first" }],
+ request: {
+ feature: FEATURE,
+ modelId: INFLUENCER_OPEN_MODELS.edit,
+ op: "edit",
+ prompt: compileDressPrompt({ state, start, clothing: used.length }),
+ inputs: { images: [...(photo ? [photo] : []), ...used] },
+ params: { numOutputs: 1 },
+ title,
+ },
+ },
+ ],
+ modelId: INFLUENCER_OPEN_MODELS.edit,
+ notes,
+ };
+ }
+
+ const has = (id: string) => !caps.has || caps.has(id);
+ const asked = run.modelId && (INFLUENCER_CLOUD_MODELS as readonly string[]).includes(run.modelId) ? run.modelId : undefined;
+ const native = caps.higgsfield && has("ai-influencer") && (!asked || asked === "ai-influencer");
+ if (asked === "ai-influencer" && !native) notes.push("AI Influencer needs a Higgsfield key — Nano Banana Pro draws the sheet from the same choices");
+ const images = [...(photo ? [photo] : []), ...clothing];
+ if (native) {
+ // Higgsfield builds the character from the picks itself: the Direction is the brief.
+ return {
+ steps: [
+ {
+ key: "sheet",
+ request: {
+ feature: FEATURE,
+ modelId: "ai-influencer",
+ op: photo ? "edit" : "t2i",
+ prompt: direction ?? "",
+ ...(images.length && { inputs: { images } }),
+ params: { numOutputs: 1, extra: higgsfieldFields(state) },
+ title,
+ },
+ },
+ ],
+ modelId: "ai-influencer",
+ notes,
+ };
+ }
+ const modelId = asked && asked !== "ai-influencer" && has(asked) ? asked : "nano-banana-pro";
+ return {
+ steps: [
+ {
+ key: "sheet",
+ request: {
+ feature: FEATURE,
+ modelId,
+ op: images.length ? "edit" : "t2i",
+ prompt: compileSheetPrompt({ state, direction, start: photo ? start : "scratch", clothing: clothing.length }),
+ ...(images.length && { inputs: { images } }),
+ params: { numOutputs: 1, aspectRatio: "16:9", ...(modelId === "nano-banana-pro" && { resolution: "2K" }) },
+ title,
+ },
+ },
+ ],
+ modelId,
+ notes,
+ };
+}
diff --git a/tests/influencer.test.ts b/tests/influencer.test.ts
new file mode 100644
index 00000000..efebd1d7
--- /dev/null
+++ b/tests/influencer.test.ts
@@ -0,0 +1,482 @@
+import fs from "node:fs";
+import path from "node:path";
+import { describe, expect, it } from "vitest";
+import { getModel, getPreset } from "@/lib/catalog";
+import { buildPayload } from "@/lib/catalog/payload";
+import { planGeneration } from "@/lib/catalog/plan";
+import {
+ categoriesFor,
+ cleanState,
+ colorName,
+ compileCastPrompt,
+ compileDressPrompt,
+ compileSheetPrompt,
+ CONFLICT_MESSAGES,
+ conflictFor,
+ CREATURE_TYPES,
+ describeInfluencer,
+ getOption,
+ higgsfieldFields,
+ INFLUENCER_CATEGORIES,
+ INFLUENCER_START,
+ influencerBlocker,
+ influencerName,
+ optionVisible,
+ PHRASES,
+ planInfluencer,
+ RAIL_ORDER,
+ resetPicks,
+ seededRandom,
+ setTier,
+ shuffleInfluencer,
+ SPECIES_PHRASES,
+ speciesNoun,
+ summaryRows,
+ tierStyle,
+ togglePick,
+ toggleLock,
+ type InfluencerRun,
+ type InfluencerState,
+ type InfluencerTier,
+} from "@/lib/influencer";
+
+const research = JSON.parse(fs.readFileSync(path.join(__dirname, "../docs/research/higgsfield-delta-4.json"), "utf8")).aiInfluencerBuilder as {
+ categories: { id: string; label: string; max: number; options: { id: string; label: string; swatch?: string; slot?: string; visibleIn?: string[] }[] }[];
+ creatureTypes: Record<string, string[]>;
+};
+
+const S = (tier: InfluencerTier, picks: Record<string, string[]> = {}, extra: Partial<InfluencerState> = {}): InfluencerState => ({ tier, picks, locked: [], ...extra });
+/** Pick several options in order through the rules. */
+const pickAll = (state: InfluencerState, ...pairs: [string, string][]) => pairs.reduce((s, [c, id]) => togglePick(s, c, id).state, state);
+const HUMAN: InfluencerTier[] = ["normal", "freak", "total"];
+const ALL_TIERS: InfluencerTier[] = [...HUMAN, ...CREATURE_TYPES.map((c) => c.id)];
+
+describe("option data (generated from the research JSON)", () => {
+ it("has the 19 categories, every option with its id, label, swatch and slot, and the 6 creature types", () => {
+ expect(INFLUENCER_CATEGORIES).toHaveLength(19);
+ expect(INFLUENCER_CATEGORIES.map((c) => [c.id, c.label, c.max])).toEqual(research.categories.map((c) => [c.id, c.label, c.max]));
+ for (const c of research.categories) {
+ const ours = INFLUENCER_CATEGORIES.find((x) => x.id === c.id)!;
+ expect(ours.options.map((o) => [o.id, o.label, o.swatch, o.slot])).toEqual(c.options.map((o) => [o.id, o.label, o.swatch?.toLowerCase(), o.slot]));
+ }
+ expect(INFLUENCER_CATEGORIES.find((c) => c.id === "skin_tone")!.options.map((o) => o.swatch)).toEqual(["#f1e2d5", "#e8c9b5", "#dab49a", "#b6976e", "#bc8e67", "#805135", "#543621", "#2d211b"]);
+ expect(CREATURE_TYPES.map((c) => [c.id, c.species.map((s) => s.id)])).toEqual(Object.entries(research.creatureTypes));
+ expect(CREATURE_TYPES.map((c) => c.label)).toEqual(["Insect", "Frog", "Cat", "Dog", "Rodent", "Bird"]);
+ });
+
+ it("names every option and species in the prompt, and nothing that no longer exists", () => {
+ const ids = INFLUENCER_CATEGORIES.filter((c) => c.id !== "tier").flatMap((c) => c.options.map((o) => o.id));
+ expect(ids.filter((id) => !PHRASES[id])).toEqual([]);
+ expect(Object.keys(PHRASES).filter((id) => !ids.includes(id))).toEqual([]);
+ const species = CREATURE_TYPES.flatMap((c) => c.species.map((s) => s.id));
+ expect(species.filter((id) => !SPECIES_PHRASES[id])).toEqual([]);
+ expect(Object.keys(SPECIES_PHRASES).filter((id) => !species.includes(id))).toEqual([]);
+ });
+
+ it("lists Character type, then gender, build, hairstyle, hair colour and style, then the rest", () => {
+ expect(RAIL_ORDER.slice(0, 6)).toEqual(["tier", "gender", "body_type", "hair", "hair_colour", "aesthetic"]);
+ expect(new Set(RAIL_ORDER).size).toBe(19);
+ });
+});
+
+describe("what each tier shows", () => {
+ const visible = (tier: InfluencerTier, cat: string) => categoriesFor(tier).find((c) => c.id === cat)?.options.map((o) => o.id) ?? [];
+
+ it("Average hides the Bold and Extreme options; Bold adds †; Extreme adds ‡", () => {
+ expect(visible("normal", "hair")).not.toContain("hs_lampshade");
+ expect(visible("freak", "hair")).toContain("hs_lampshade");
+ expect(visible("normal", "freak_face")).not.toContain("ff_nose_0");
+ expect(visible("freak", "freak_head")).toContain("head_tiny");
+ expect(visible("freak", "freak_head")).not.toContain("head_herojaw");
+ expect(visible("total", "freak_head")).toEqual(expect.arrayContaining(["head_ancient", "head_herojaw", "head_megachin"]));
+ expect(visible("freak", "body_type")).not.toContain("pr_centaur");
+ expect(visible("total", "body_type")).toContain("pr_centaur");
+ for (const t of HUMAN) expect(visible(t, "height")).not.toContain("h_short");
+ expect(categoriesFor("normal")).toHaveLength(18);
+ });
+
+ it("creature types show their 10 categories with every option but Centaur, and Short", () => {
+ for (const c of CREATURE_TYPES) {
+ const cats = categoriesFor(c.id);
+ expect(cats.map((x) => x.id).sort()).toEqual(["accessory", "aesthetic", "body_type", "distinctive", "facial_hair", "gender", "hair", "hair_colour", "height", "proportions"]);
+ expect(visible(c.id, "height")).toContain("h_short");
+ expect(visible(c.id, "body_type")).not.toContain("pr_centaur");
+ expect(visible(c.id, "hair")).toContain("hs_lampshade");
+ }
+ expect(optionVisible(getOption("skin_tone", "st_fair")!, "cats", "skin_tone")).toBe(false);
+ });
+});
+
+describe("pick rules", () => {
+ it("one-pick categories replace the pick, and a second click unpicks", () => {
+ let s = pickAll(INFLUENCER_START, ["gender", "male"], ["gender", "female"]);
+ expect(s.picks.gender).toEqual(["female"]);
+ s = togglePick(s, "gender", "female").state;
+ expect(s.picks.gender).toBeUndefined();
+ });
+
+ it("None clears the other accessories, another accessory clears None, and the oldest makes room past 3", () => {
+ let s = pickAll(INFLUENCER_START, ["accessory", "acc_glasses"], ["accessory", "acc_hat"], ["accessory", "acc_none"]);
+ expect(s.picks.accessory).toEqual(["acc_none"]);
+ s = togglePick(s, "accessory", "acc_bag").state;
+ expect(s.picks.accessory).toEqual(["acc_bag"]);
+ s = pickAll(s, ["accessory", "acc_glasses"], ["accessory", "acc_hat"]);
+ const r = togglePick(s, "accessory", "acc_jewelry");
+ expect(r.state.picks.accessory).toEqual(["acc_glasses", "acc_hat", "acc_jewelry"]);
+ expect(r.note).toBe("Accessories: up to 3 — Bag was replaced");
+ });
+
+ it("Features keep one option per slot, up to 4", () => {
+ let s = pickAll(S("freak"), ["freak_face", "fn_freckles"], ["freak_face", "ff_marks_12"]);
+ expect(s.picks.freak_face).toEqual(["ff_marks_12"]);
+ s = pickAll(s, ["freak_face", "fn_dimples"], ["freak_face", "ff_nose_1"], ["freak_face", "fn_fulllips"], ["freak_face", "ff_brows_5"]);
+ expect(s.picks.freak_face).toEqual(["fn_dimples", "ff_nose_1", "fn_fulllips", "ff_brows_5"]);
+ // Same slot as Full lips: replaces it, nothing else goes.
+ s = togglePick(s, "freak_face", "ff_lips_3").state;
+ expect(s.picks.freak_face).toEqual(["fn_dimples", "ff_nose_1", "ff_brows_5", "ff_lips_3"]);
+ });
+
+ it("refuses options the tier doesn't show", () => {
+ expect(togglePick(S("normal"), "hair", "hs_lampshade").state.picks.hair).toBeUndefined();
+ expect(togglePick(S("cats"), "skin_tone", "st_fair").state.picks).toEqual({});
+ });
+});
+
+describe("conflicts (Higgsfield's messages)", () => {
+ it("Heavy build with Tall or Very tall, either way round, in every tier", () => {
+ for (const tier of ALL_TIERS) {
+ const heavy = pickAll(S(tier), ["body_type", "body_heavy"]);
+ for (const h of ["h_tall", "h_very_tall"]) {
+ const r = togglePick(heavy, "height", h);
+ expect(r.conflict).toBe("Heavy build cannot be combined with Tall or Very tall.");
+ expect(r.state).toBe(heavy);
+ }
+ const tall = pickAll(S(tier), ["height", "h_tall"]);
+ expect(conflictFor(tall, "body_type", "body_heavy")).toBe(CONFLICT_MESSAGES.heavyTall);
+ expect(conflictFor(tall, "body_type", "body_slim")).toBeNull();
+ }
+ });
+
+ it("Heavy, Muscular or Ultra Muscular with Short legs or Long limbs, except in Average", () => {
+ for (const body of ["body_heavy", "body_muscular", "body_ultra"]) {
+ for (const p of ["pr_shortlegs", "pr_longlimbs"]) {
+ expect(conflictFor(pickAll(S("freak"), ["body_type", body]), "proportions", p)).toBe("This build cannot be combined with Short legs or Long limbs in this mode.");
+ expect(conflictFor(pickAll(S("dogs"), ["proportions", p]), "body_type", body)).toBe(CONFLICT_MESSAGES.buildLegs);
+ expect(conflictFor(pickAll(S("normal"), ["body_type", body]), "proportions", p)).toBeNull();
+ }
+ }
+ expect(conflictFor(pickAll(S("total"), ["body_type", "body_athletic"]), "proportions", "pr_shortlegs")).toBeNull();
+ // Replacing the conflicting build is fine: the new pick is what counts.
+ const s = pickAll(S("freak"), ["proportions", "pr_shortlegs"], ["body_type", "body_slim"]);
+ expect(conflictFor(s, "body_type", "body_athletic")).toBeNull();
+ });
+
+ it("unpicking never conflicts", () => {
+ const s = S("freak", { body_type: ["body_muscular"], proportions: ["pr_shortlegs"] });
+ expect(conflictFor(s, "proportions", "pr_shortlegs")).toBeNull();
+ expect(togglePick(s, "proportions", "pr_shortlegs").state.picks.proportions).toBeUndefined();
+ });
+});
+
+describe("switching the character type", () => {
+ it("drops what the new tier doesn't show and names it", () => {
+ const s = pickAll(S("total"), ["hair", "hs_horns"], ["freak_head", "head_ancient"], ["gender", "female"]);
+ const r = setTier(s, "normal");
+ expect(r.state.picks).toEqual({ gender: ["female"] });
+ expect(r.dropped).toEqual(["Hair horns", "Caveman"]);
+ });
+
+ it("Average → Bold drops the leg proportions a big build can't have there", () => {
+ const s = pickAll(S("normal"), ["body_type", "body_muscular"], ["proportions", "pr_shortlegs"], ["proportions", "pr_shoulders"]);
+ const r = setTier(s, "freak");
+ expect(r.state.picks.proportions).toEqual(["pr_shoulders"]);
+ expect(r.dropped).toEqual(["Short legs"]);
+ });
+
+ it("keeps the species within its type and the body colour for creatures", () => {
+ const cat = S("cats", { gender: ["male"] }, { species: "persian", bodyColor: "#ff8800" });
+ expect(setTier(cat, "dogs").state).toMatchObject({ tier: "dogs", bodyColor: "#ff8800", picks: { gender: ["male"] } });
+ expect(setTier(cat, "dogs").state.species).toBeUndefined();
+ expect(setTier(cat, "normal").state.bodyColor).toBeUndefined();
+ expect(setTier(S("normal", { skin_tone: ["st_fair"] }), "cats").dropped).toEqual(["Fair"]);
+ });
+
+ it("Reset all clears the picks and locks but keeps the type", () => {
+ expect(resetPicks(S("birds", { gender: ["male"] }, { locked: ["gender"], species: "duck" }))).toEqual({ tier: "birds", picks: {}, locked: [] });
+ });
+});
+
+describe("Shuffle", () => {
+ const runs = (state: InfluencerState, n: number, opts = {}) => Array.from({ length: n }, (_, i) => shuffleInfluencer(state, seededRandom(i + 1), opts));
+ const share = (xs: InfluencerState[], cat: string, id: string) => xs.filter((x) => x.picks[cat]?.[0] === id).length / xs.length;
+
+ it("is repeatable with a seed", () => {
+ expect(shuffleInfluencer(S("freak"), seededRandom(42))).toEqual(shuffleInfluencer(S("freak"), seededRandom(42)));
+ expect(shuffleInfluencer(S("freak"), seededRandom(42))).not.toEqual(shuffleInfluencer(S("freak"), seededRandom(43)));
+ });
+
+ it("uses the researched weights: male 67% / female 33%, Suits 40%, Retro 20%, Bob 20% where it shows", () => {
+ const freak = runs(S("freak"), 4000);
+ expect(new Set(freak.map((x) => x.picks.gender[0]))).toEqual(new Set(["male", "female"]));
+ expect(share(freak, "gender", "male")).toBeCloseTo(0.67, 1);
+ expect(share(freak, "aesthetic", "suits")).toBeCloseTo(0.4, 1);
+ expect(share(freak, "aesthetic", "retro")).toBeCloseTo(0.2, 1);
+ expect(share(freak, "aesthetic", "goth")).toBeCloseTo(0.4 / 6, 1);
+ expect(share(freak, "hair", "hs_lampshade")).toBeCloseTo(0.2, 1);
+ const normal = runs(S("normal"), 1000);
+ expect(share(normal, "hair", "hs_lampshade")).toBe(0);
+ // Without Bob every hairstyle is equally likely.
+ expect(share(normal, "hair", "hair_mullet")).toBeCloseTo(1 / 11, 1);
+ });
+
+ it("never shuffles a build it shouldn't, nor a conflict", () => {
+ for (const tier of ALL_TIERS) {
+ for (const s of runs(S(tier), 600)) {
+ const body = s.picks.body_type?.[0];
+ const height = s.picks.height?.[0] ?? "";
+ const props = s.picks.proportions ?? [];
+ expect(body).not.toBe("body_curvy");
+ if (tier === "normal") expect(body).not.toBe("body_ultra");
+ if (body === "body_heavy") {
+ expect(["h_tall", "h_very_tall"]).not.toContain(height);
+ expect(props).not.toContain("pr_waist");
+ }
+ if (body === "pr_centaur") expect(props).not.toContain("pr_egg");
+ if (body === "body_ultra") expect(s.picks.freak_neck?.[0]).not.toBe("neck_long");
+ expect(cleanState(s).problem).toBeNull();
+ // Everything it picks is something the tier shows, within each category's limit.
+ expect(cleanState(s).state.picks).toEqual(s.picks);
+ }
+ }
+ });
+
+ it("gives facial hair only to men and trans men", () => {
+ for (const s of runs(S("total"), 600)) {
+ const g = s.picks.gender[0];
+ if (g !== "male" && g !== "trans_man") expect(s.picks.facial_hair).toEqual(["fh_none"]);
+ }
+ expect(new Set(runs(S("total"), 600).filter((s) => s.picks.gender[0] === "male").map((s) => s.picks.facial_hair[0])).size).toBeGreaterThan(4);
+ });
+
+ it("keeps locked picks, and what a photo decides", () => {
+ const locked = toggleLock(S("freak", { gender: ["non_binary"], hair: ["hs_wings"] }), "hair");
+ for (const s of runs(locked, 50)) expect(s.picks.hair).toEqual(["hs_wings"]);
+ const fixed = S("normal", { gender: ["trans_woman"], ethnicity_origin_base: ["indian"], skin_tone: ["st_tan"], age: ["senior"], eye_color: ["eye_green"] });
+ for (const s of runs(fixed, 50, { reference: true })) expect(s.picks).toMatchObject(fixed.picks);
+ // Bold keeps gender, ethnicity and age; skin and eyes shuffle.
+ const bold = runs({ ...fixed, tier: "freak" }, 50, { reference: true });
+ for (const s of bold) expect(s.picks).toMatchObject({ gender: ["trans_woman"], ethnicity_origin_base: ["indian"], age: ["senior"] });
+ expect(bold.some((s) => s.picks.skin_tone[0] !== "st_tan")).toBe(true);
+ // Without a photo nothing is kept.
+ expect(runs(fixed, 50).some((s) => s.picks.gender[0] !== "trans_woman")).toBe(true);
+ });
+
+ it("leaves the type, species and body colour alone", () => {
+ const s = shuffleInfluencer(S("cats", {}, { species: "sphynx", bodyColor: "#336699" }), seededRandom(7));
+ expect(s).toMatchObject({ tier: "cats", species: "sphynx", bodyColor: "#336699" });
+ });
+});
+
+describe("the prompt compiler", () => {
+ it("puts every category's phrase into the description", () => {
+ for (const tier of ["total", "cats"] as InfluencerTier[]) {
+ for (const c of categoriesFor(tier)) {
+ for (const o of c.options) {
+ const d = describeInfluencer(S(tier, { [c.id]: [o.id] }));
+ // A hairstyle with no colour picked: "a {color}afro" reads "an afro".
+ const phrase = PHRASES[o.id].includes("{color}") ? PHRASES[o.id].replace("{color}", "").replace(/\ba ([aeiou])/, "an $1") : PHRASES[o.id];
+ const want = c.id === "gender" && tier === "cats" ? undefined : c.id === "eye_shape" || c.id === "eye_color" ? `${phrase} eyes` : c.id === "hair_colour" ? `${phrase} hair` : phrase;
+ if (want) expect(d.toLowerCase(), `${c.id}/${o.id}`).toContain(want.toLowerCase());
+ }
+ }
+ }
+ });
+
+ it("reads like a sentence", () => {
+ const s = S("normal", {
+ gender: ["male"],
+ age: ["adult"],
+ ethnicity_origin_base: ["european"],
+ height: ["h_tall"],
+ body_type: ["body_athletic"],
+ eye_shape: ["es_almond"],
+ eye_color: ["eye_hazel"],
+ hair: ["hair_mullet"],
+ hair_colour: ["hc_black"],
+ facial_hair: ["fh_stubble"],
+ aesthetic: ["suits"],
+ accessory: ["acc_glasses", "acc_hat"],
+ });
+ expect(describeInfluencer(s)).toBe("A young adult European man, tall, with an athletic build, almond-shaped hazel eyes, a jet black mullet and stubble, wearing a tailored suit, with glasses and a hat.");
+ expect(describeInfluencer(INFLUENCER_START)).toBe("A person.");
+ expect(describeInfluencer(S("normal", { hair: ["hair_afro"] }))).toBe("A person, with an afro.");
+ expect(describeInfluencer(S("normal", { hair: ["hair_long"], hair_colour: ["hc_platinum"] }))).toContain("long platinum blonde hair");
+ expect(describeInfluencer(S("normal", { hair: ["hair_bald"], hair_colour: ["hc_red"] }))).toContain("a bald head");
+ expect(describeInfluencer(S("normal", { gender: ["female"], facial_hair: ["fh_none"], accessory: ["acc_none"] }))).toBe("A woman, clean-shaven, no accessories.");
+ });
+
+ it("words the tier: realistic, bold caricature, extreme caricature, anthropomorphic {species}", () => {
+ expect(tierStyle(S("normal"))).toMatch(/^Realistic/);
+ expect(tierStyle(S("freak"))).toMatch(/^Bold caricature/);
+ expect(tierStyle(S("total"))).toMatch(/^Extreme caricature/);
+ expect(tierStyle(S("cats", {}, { species: "maine_coon" }))).toMatch(/^Anthropomorphic Maine Coon cat: an upright Maine Coon cat/);
+ expect(tierStyle(S("frogs"))).toMatch(/^Anthropomorphic frog/);
+ expect(describeInfluencer(S("capybaras", { gender: ["female"] }, { species: "barrel", bodyColor: "#f4c2d7" }))).toBe("A female anthropomorphic barrel-shaped capybara with pale pink fur.");
+ expect(describeInfluencer(S("insects", {}, { species: "ant" }))).toBe("An anthropomorphic ant.");
+ expect(speciesNoun("dogs", "persian")).toBe("dog");
+ });
+
+ it("names body colours", () => {
+ expect(colorName("#000000")).toBe("black");
+ expect(colorName("#ffffff")).toBe("white");
+ expect(colorName("#808080")).toBe("grey");
+ expect(colorName("#ff0000")).toBe("red");
+ expect(colorName("#102a6b")).toBe("deep blue");
+ expect(colorName("#22c55e")).toBe("green");
+ expect(colorName("#8b5a2b")).toBe("brown");
+ expect(colorName("#14b8a6")).toBe("teal");
+ expect(colorName("nope")).toBe("");
+ });
+
+ it("builds the sheet prompt with the photo's and the clothing's roles and the Direction", () => {
+ const s = S("freak", { gender: ["female"] });
+ const p = compileSheetPrompt({ state: s, direction: " She runs a ceramics studio. ", start: "face", clothing: 2 });
+ expect(p).toMatch(/^Character sheet of an original AI influencer on a pure white background: a close-up portrait of the face, then full-body/);
+ expect(p).toContain("The character: A woman");
+ expect(p).toContain("Bold caricature");
+ expect(p).toContain("the face of the person in image 1");
+ expect(p).toContain("the clothing shown in images 2 and 3");
+ expect(p).toContain("Direction: She runs a ceramics studio.");
+ expect(compileSheetPrompt({ state: s, clothing: 1 })).toContain("the clothing shown in image 1");
+ expect(compileSheetPrompt({ state: s, start: "reference" })).toContain("Base the character on the one in image 1");
+ expect(compileCastPrompt({ state: s, direction: "loves surfing" })).toBe("A woman. Bold caricature: photographic, but the chosen features are exaggerated for a memorable, slightly cartoonish look. loves surfing.");
+ expect(compileDressPrompt({ state: s, start: "face", clothing: 1 })).toBe(
+ "Image 1 is a character turnaround sheet. Give the character in every view the face of the person in image 2: the same identity, facial features and skin tone. Dress the character in every view in the clothing shown in image 3. Keep the poses, the layout, the number of views and the white background of image 1 unchanged.",
+ );
+ expect(compileDressPrompt({ state: s, clothing: 2 })).toContain("clothing shown in images 2 and 3");
+ });
+
+ it("sends Higgsfield its own fields", () => {
+ expect(higgsfieldFields(S("cats", { gender: ["male"], hair: ["hair_afro"] }, { species: "pug", bodyColor: "#AABBCC" }))).toEqual({ tier: "cats", selection: { gender: ["male"], hair: ["hair_afro"] }, body_color: "#aabbcc" });
+ expect(higgsfieldFields(S("dogs", { gender: ["male"] }, { species: "pug", bodyColor: "#AABBCC" }))).toEqual({ tier: "dogs", selection: { gender: ["male"] }, pinned_species: "pug", body_color: "#aabbcc" });
+ expect(higgsfieldFields(S("normal", { accessory: ["acc_glasses", "acc_bag"] }))).toEqual({ tier: "normal", selection: { accessory: ["acc_glasses", "acc_bag"] } });
+ });
+
+ it("summarises and names", () => {
+ const s = S("normal", { gender: ["male"], aesthetic: ["suits"], hair: ["hair_mullet"], accessory: ["acc_glasses", "acc_hat"] });
+ expect(summaryRows(s)).toEqual([
+ { category: "gender", label: "Gender", options: "Male" },
+ { category: "hair", label: "Hairstyle", options: "Mullet" },
+ { category: "aesthetic", label: "Style", options: "Suits" },
+ { category: "accessory", label: "Accessories", options: "Glasses, Hat" },
+ ]);
+ expect(influencerName(s)).toBe("Suits · Mullet");
+ expect(influencerName(S("freak"))).toBe("Bold influencer");
+ expect(influencerName(S("cats", {}, { species: "maine_coon" }))).toBe("Maine Coon cat");
+ });
+});
+
+describe("checking what the browser sends", () => {
+ it("drops unknown, hidden and surplus picks, keeps one per slot, and reports a conflict", () => {
+ const { state, problem } = cleanState({
+ tier: "normal",
+ picks: { gender: ["male", "female"], hair: ["hs_lampshade", "nope"], freak_face: ["fn_freckles", "fn_mole"], bogus: ["x"], accessory: ["acc_glasses", "acc_none"] },
+ species: "pug",
+ bodyColor: "#123456",
+ locked: ["gender", "bogus"],
+ });
+ expect(state).toEqual({ tier: "normal", picks: { gender: ["female"], freak_face: ["fn_mole"], accessory: ["acc_none"] }, locked: ["gender"] });
+ expect(problem).toBeNull();
+ expect(cleanState({ tier: "freak", picks: { body_type: ["body_heavy"], height: ["h_very_tall"] } }).problem).toBe(CONFLICT_MESSAGES.heavyTall);
+ expect(cleanState({ tier: "dogs", species: "pug", bodyColor: "#ABCDEF" }).state).toEqual({ tier: "dogs", picks: {}, locked: [], species: "pug", bodyColor: "#abcdef" });
+ expect(cleanState({ tier: "dogs", species: "persian", bodyColor: "red" }).state).toEqual({ tier: "dogs", picks: {}, locked: [] });
+ expect(cleanState(null).state).toEqual(INFLUENCER_START);
+ });
+});
+
+describe("the plan per engine", () => {
+ const face = "/api/files/me.jpg";
+ const clothes = ["/api/files/a.png", "/api/files/b.png", "/api/files/c.png"];
+ const state = S("freak", { gender: ["female"], hair: ["hs_beehive"], aesthetic: ["goth"] });
+ const run = (o: Partial<InfluencerRun>): InfluencerRun => ({ engine: "cloud", state, start: "scratch", ...o });
+ const KEY = { higgsfield: true, has: () => true };
+ const NO_KEY = { higgsfield: false, has: () => true };
+ const valid = (p: ReturnType<typeof planInfluencer>) => p.steps.map((s) => planGeneration(s.request, getModel, getPreset));
+
+ it("cloud with a Higgsfield key: AI Influencer with its own fields; the photo is image_url, clothing item_image_urls", () => {
+ const p = planInfluencer(run({ start: "face", photo: face, clothing: clothes.slice(0, 2), direction: "A potter from Porto" }), KEY);
+ expect(p.modelId).toBe("ai-influencer");
+ const r = p.steps[0].request;
+ expect(r).toMatchObject({ feature: "influencer", modelId: "ai-influencer", op: "edit", prompt: "A potter from Porto", inputs: { images: [face, ...clothes.slice(0, 2)] } });
+ expect(r.params?.extra).toEqual({ tier: "freak", selection: state.picks });
+ const [plan] = valid(p);
+ const route = getModel("ai-influencer")!.routes.find((x) => x.op === plan.op)!;
+ expect(buildPayload(route.map!, { prompt: plan.prompt, images: r.inputs!.images, ...plan.params })).toEqual({
+ brief: "A potter from Porto",
+ image_url: face,
+ item_image_urls: clothes.slice(0, 2),
+ tier: "freak",
+ selection: state.picks,
+ });
+ // From scratch with clothing: no image_url, an empty brief is fine.
+ const t2i = planInfluencer(run({ clothing: clothes }), KEY);
+ const [plan2] = valid(t2i);
+ expect(plan2.op).toBe("t2i");
+ const route2 = getModel("ai-influencer")!.routes.find((x) => x.op === "t2i")!;
+ expect(buildPayload(route2.map!, { prompt: plan2.prompt, images: clothes, ...plan2.params })).toEqual({ brief: "", item_image_urls: clothes, tier: "freak", selection: state.picks });
+ });
+
+ it("cloud without a key: Nano Banana Pro (or Seedream 5.0) draws a wide sheet from the compiled prompt", () => {
+ const p = planInfluencer(run({ start: "face", photo: face, clothing: [clothes[0]] }), NO_KEY);
+ expect(p.modelId).toBe("nano-banana-pro");
+ expect(p.notes).toEqual([]);
+ expect(p.steps[0].request).toMatchObject({ op: "edit", inputs: { images: [face, clothes[0]] }, params: { aspectRatio: "16:9", resolution: "2K", numOutputs: 1 } });
+ expect(p.steps[0].request.prompt).toContain("the face of the person in image 1");
+ expect(p.steps[0].request.prompt).toContain("clothing shown in image 2");
+ valid(p);
+ const asked = planInfluencer(run({ modelId: "ai-influencer" }), NO_KEY);
+ expect(asked.modelId).toBe("nano-banana-pro");
+ expect(asked.notes).toEqual(["AI Influencer needs a Higgsfield key — Nano Banana Pro draws the sheet from the same choices"]);
+ expect(asked.steps[0].request.op).toBe("t2i");
+ const seedream = planInfluencer(run({ modelId: "seedream-5-pro" }), KEY);
+ expect(seedream.modelId).toBe("seedream-5-pro");
+ expect(seedream.steps[0].request.params).toEqual({ numOutputs: 1, aspectRatio: "16:9" });
+ valid(seedream);
+ expect(planInfluencer(run({ modelId: "flux-3-max" }), NO_KEY).modelId).toBe("nano-banana-pro");
+ });
+
+ it("open from scratch: the Soul Cast sheet workflow with the compiled character", () => {
+ const p = planInfluencer(run({ engine: "open", direction: "loves jazz" }), NO_KEY);
+ expect(p.steps).toHaveLength(1);
+ expect(p.steps[0].request).toMatchObject({ feature: "influencer", modelId: "oss-zimage-soul-cast", op: "t2i", prompt: compileCastPrompt({ state, direction: "loves jazz" }) });
+ valid(p);
+ });
+
+ it("open with your face: the sheet, then Qwen-Image-Edit 2511 puts the face (and one clothing reference) on it", () => {
+ const p = planInfluencer(run({ engine: "open", start: "face", photo: face, clothing: clothes }), NO_KEY);
+ expect(p.modelId).toBe("oss-qwen-edit");
+ expect(p.steps.map((s) => [s.key, s.request.feature, s.request.modelId, s.after])).toEqual([
+ ["sheet", "influencer-step", "oss-zimage-soul-cast", undefined],
+ ["dress", "influencer", "oss-qwen-edit", "sheet"],
+ ]);
+ expect(p.steps[1].chain).toEqual([{ slot: "images", position: "first" }]);
+ expect(p.steps[1].request.inputs?.images).toEqual([face, clothes[0]]);
+ expect(p.steps[1].request.prompt).toBe(compileDressPrompt({ state, start: "face", clothing: 1 }));
+ expect(p.notes[0]).toBe("Qwen-Image-Edit takes 3 images (the sheet, your photo and clothing) — the first clothing reference is used");
+ valid(p);
+ const dressed = planInfluencer(run({ engine: "open", clothing: clothes }), NO_KEY);
+ expect(dressed.steps[1].request.inputs?.images).toEqual(clothes.slice(0, 2));
+ expect(dressed.notes).toEqual(["Qwen-Image-Edit takes 3 images (the sheet and clothing) — the first 2 clothing references are used", "Two steps: Z-Image Turbo draws the sheet, then Qwen-Image-Edit 2511 dresses it in your clothing"]);
+ // A photo only matters when the run starts from it.
+ expect(planInfluencer(run({ engine: "open", start: "scratch", photo: face }), NO_KEY).steps).toHaveLength(1);
+ });
+
+ it("says what is missing or too much, in Higgsfield's words where it has them", () => {
+ expect(influencerBlocker(run({ direction: "x".repeat(4001) }))).toBe("Keep the direction under 4,000 characters");
+ expect(influencerBlocker(run({ direction: "x".repeat(4000) }))).toBeNull();
+ expect(influencerBlocker(run({ clothing: [...clothes, "/api/files/d.png"] }))).toBe("You can add up to three clothing references");
+ expect(influencerBlocker(run({ start: "face" }))).toBe("Add your photo first");
+ expect(influencerBlocker(run({ start: "reference" }))).toBe("Add a reference image first");
+ expect(() => planInfluencer(run({ state: S("freak", { body_type: ["body_ultra"], proportions: ["pr_longlimbs"] }) }), KEY)).toThrow(CONFLICT_MESSAGES.buildLegs);
+ });
+});