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.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Layouts everywhere: a Layout node in Canvas, words drawn by the model in Marketing and Ads, a layout planner and the Layout Poster skill
Claude1ff3d12425de
diff --git a/skills/layout-poster/SKILL.md b/skills/layout-poster/SKILL.mdnew file mode 100644index 00000000..d8f9dfa0--- /dev/null+++ b/skills/layout-poster/SKILL.md@@ -0,0 +1,68 @@+---+name: layout-poster+description: Plan a poster, ad or cover as a layout of boxes (a headline, a product, a price, a button) with the exact words, and render it with an image model that places boxes. Use for text placement, posters, sale ads, menus and covers where the words and the subject must land in given places.+license: Apache-2.0 (adapted from OpenMOSS MOSS-Image's prompt-enhancer skill; see the notice at the end)+compatibility: Needs a Fuobe server. Fuobe Assist runs these steps itself; other agents call the generate tool on Fuobe's MCP endpoint (/api/mcp) or use the fuobe CLI.+metadata:+ title: Layout Poster+ when_to_use: The user wants a poster, a sale ad, a flyer, a menu or a cover with exact words in given places ("a sale poster for my candle shop, 30% off"), or asks for a layout.+ icon: layout-grid+ studio: /image+ tags: layout, poster, text, ads, design+ offline_kind: image+ offline_aspect: "3:4"+ offline_outputs: "2"+ offline_style: designed poster with a bold headline at the top, the product in the middle and a call-to-action button at the bottom, clean graphic design+---++# Layout Poster++Turn the user's idea into a layout: one box per thing to place, each with what it looks like,+and the exact words for the text boxes. A model that places boxes then draws each in its place.+Read [references/layout.md](references/layout.md) before writing the draft.++## 1. Decide the deliverable+- Use a layout when exact text placement, a poster, several panels or controlled positions help.+ An ordinary scene or photo needs only a good prompt: skip the layout then.+- Keep the user's subject, counts, style and the words they want shown, verbatim (spelling,+ capitals, punctuation, language). Write real copy, never "headline here". Don't invent facts+ (dates, prices, addresses) the user didn't give; ask only when a missing decision changes the+ picture a lot.++## 2. Pick the canvas+- Use the size the user gives; with only an aspect ratio, pick pixels of that shape; otherwise+ 1024 × 1024, or 768 × 1024 (3:4) for a poster. Both sides are multiples of 16.++## 3. Write the draft+- Pixel boxes from the top-left corner: `[x_min, y_min, x_max, y_max]`, x within 0..width and+ y within 0..height, `bbox_coord_space: "abs"`, `bbox_format: "xyxy"`. Never 0-1 fractions,+ never centred boxes: Fuobe converts them for the model.+- `summary.caption` describes the whole picture: subject, setting, medium, light, palette, mood.+- Usually 3 to 6 boxes: a headline (large), supporting words (smaller), the product or person,+ a price tag or a button. A box is a placement, not a border or a panel to draw.+- A text item's `caption` describes its lettering (size, weight, colour, typeface style); its+ `text` holds the exact words, with `\n` for a line break you want. Check every string fits its+ box at that size: a long line needs a wide box.++## 4. Render it+Call `generate` with the draft as the job's `layout` and the whole picture as its `prompt`:+- Your GPU: `oss-moss-image` (MOSS-Image, free).+- Cloud: `moss-image` (MOSS-Image on fal), `ideogram-4-5` or `flux-3`: each draws the exact text+ in place. Fuobe turns prompt rewriting off for a layout.+- Other models read the layout as sentences, not exact positions: say so if the user picks one.+Show the user the boxes in words (what goes where) with the price before running. Layout+prompts are experimental: the boxes guide the picture, they don't pin it.++In the Image studio the same draft opens in Layout mode, where **Plan layout** writes a first+draft from a sentence and the user drags the boxes; Canvas has a Layout node, and Marketing and+Ads Studio offer "Words drawn by the model".++## Using Fuobe from an agent+The `generate` tool on Fuobe's MCP endpoint takes the same `layout` field.++---+Adapted from OpenMOSS MOSS-Image, `skills/moss-image-prompt-enhancer/SKILL.md` and+`references/layout.md` at commit 2b46b1e0e13b5aaec253879e0d006a42564b8b27+(https://github.com/OpenMOSS/MOSS-Image). Copyright OpenMOSS. Licensed under the Apache+License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0). Changed for Fuobe: the+compile step runs inside Fuobe, the models and tools are Fuobe's, and the text was shortened.diff --git a/skills/layout-poster/references/layout.md b/skills/layout-poster/references/layout.mdnew file mode 100644index 00000000..47e29317--- /dev/null+++ b/skills/layout-poster/references/layout.md@@ -0,0 +1,53 @@+# Pixel layout draft++Adapted from OpenMOSS MOSS-Image, `skills/moss-image-prompt-enhancer/references/layout.md` at+commit 2b46b1e0e13b5aaec253879e0d006a42564b8b27. Copyright OpenMOSS. Licensed under the Apache+License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0). Changed for Fuobe: Fuobe+compiles the draft for each model itself, and the example is Fuobe's own.++The draft is `summary` plus a flat `items` array, in readable JSON. Fuobe turns it into each+model's own form (MOSS-Image's centred boxes, FLUX.3's layout table, Ideogram's JSON prompt).++## Fields++- `width`, `height`: positive whole multiples of 16, the size of the picture to make.+- `bbox_coord_space`: exactly `"abs"`. `bbox_format`: exactly `"xyxy"`.+- `summary`: `caption` (the whole picture, not empty), optionally `meta` (medium or genre tags)+ and `canvas` (`single`, `multi_panel` or `collage`).+- `items`: each has a `label` (`object`, `character` or `text`), a `caption` and a four-number+ `bbox`. A text item also has `text`: the exact visible characters, `\n` for a line break.+ Use separate text items when they must sit apart.+- `tags` and `palette`: optional string arrays on items (and `palette` on the summary).++Positions are on the whole canvas, text on an object included. Items may overlap.++## Example++A 768 × 1024 sale poster for a candle shop:++```json+{+ "width": 768,+ "height": 1024,+ "bbox_coord_space": "abs",+ "bbox_format": "xyxy",+ "summary": {+ "caption": "A warm autumn sale poster for a small candle shop: three lit soy candles on a wooden table, soft amber light, cream and rust palette, calm and cosy.",+ "meta": ["poster", "graphic design"],+ "canvas": "single"+ },+ "items": [+ { "label": "text", "caption": "Large bold cream serif headline with generous spacing", "text": "Autumn Glow", "bbox": [64, 48, 704, 200] },+ { "label": "text", "caption": "Rust-red rounded tag with bold white letters", "text": "30% OFF", "bbox": [256, 216, 512, 296] },+ { "label": "object", "caption": "Three lit soy candles in amber glass jars on a worn oak table, soft glow", "bbox": [112, 320, 656, 848] },+ { "label": "text", "caption": "Small cream sans-serif line, easy to read", "text": "Hand-poured in Leeds", "bbox": [192, 880, 576, 944] }+ ]+}+```++## Checks before rendering++Read every string against the wording asked for. Check the line breaks, the length and the+letter size fit each box at this resolution: a short title needs less room than a paragraph.+Make the layout bigger or simpler rather than dropping words or squeezing letters. When you+change a draft, keep what wasn't asked to change and keep one coordinate convention.diff --git a/src/app/api/layout/plan/route.ts b/src/app/api/layout/plan/route.tsnew file mode 100644index 00000000..3830f3ef--- /dev/null+++ b/src/app/api/layout/plan/route.ts@@ -0,0 +1,21 @@+import { z } from "zod";+import { PLAN_WORDS_MAX } from "@/lib/layout-plan";+import { planLayoutFromWords, planSide } from "@/server/layout-plan";++const Body = z.object({+ words: z.string().trim().min(1).max(PLAN_WORDS_MAX),+ width: z.number().optional(),+ height: z.number().optional(),+});++/**+ * POST /api/layout/plan {words, width, height}: a starting layout for the Layout editor's canvas, planned from a+ * sentence (src/server/layout-plan.ts). It plans with the install's AI helper, so it is the owner's: a guest or an+ * account gets the proxy's own-gpu-tool answer (src/proxy.ts).+ */+export async function POST(request: Request) {+ const parsed = Body.safeParse(await request.json().catch(() => ({})));+ if (!parsed.success) return Response.json({ error: "Describe the picture to plan, in a sentence" }, { status: 400 });+ const { words, width, height } = parsed.data;+ return Response.json(await planLayoutFromWords(words, planSide(width), planSide(height)));+}diff --git a/src/components/canvas/canvas-context.tsx b/src/components/canvas/canvas-context.tsxindex 40cc8b40..bcd52ede 100644--- a/src/components/canvas/canvas-context.tsx+++ b/src/components/canvas/canvas-context.tsx@@ -19,6 +19,7 @@ import {Gem,ImageIcon,Languages,+ LayoutDashboard,MessageSquareText,Mic2,MonitorPlay,@@ -57,6 +58,7 @@ import type { EngineMode } from "@/lib/api";export const ICONS: Record<string, LucideIcon> = {Type,+ LayoutDashboard,ImageIcon,Film,AudioLines,diff --git a/src/components/canvas/nodes.tsx b/src/components/canvas/nodes.tsxindex 69389312..e53a5b0a 100644--- a/src/components/canvas/nodes.tsx+++ b/src/components/canvas/nodes.tsx@@ -31,8 +31,10 @@ import {Volume2,VolumeX,Table,+ LayoutDashboard,X,} from "lucide-react";+import dynamic from "next/dynamic";import Link from "next/link";import { memo, useEffect, useMemo, useRef, useState } from "react";import {@@ -117,6 +119,11 @@ import { matchSpokenLanguage, spokenLanguageName, spokenLanguageOptions } from "import { keyCombo } from "@/lib/keys";import { cn } from "@/lib/utils";import { responseError, toastError } from "@/lib/refusals";+import { KIND_COLOR } from "@/lib/layout-edit";+import { readLayout, readsBoxes, type LayoutDraft } from "@/lib/layout-prompt";+import { layoutCanvas } from "@/lib/catalog/plan";+import { getModel } from "@/lib/catalog";+import type { EditorCanvas } from "@/components/studio/layout-editor";import { BOARD_NODE_TYPES, type BoardType } from "./board";import { NodeIcon, PORT_COLOR, useEditorActions, useEditorGlobals, useEditorSelector, useNodeResults, useNodeView, type EditorSnapshot, type NodeResults } from "./canvas-context";@@ -1754,6 +1761,116 @@ const TableNode = memo(function TableNode({ id, data, selected }: NodeProps<Flow);}, sameNodeProps);+// ---------------------------------------------------------------------------+// Layout: boxes for a headline, a product, a price; the image model it feeds draws each in its place++const LayoutEditor = dynamic(() => import("@/components/studio/layout-editor").then((m) => m.LayoutEditor));++const LAYOUT_ASPECTS = ["1:1", "4:5", "3:4", "2:3", "9:16", "16:9", "3:2", "4:3"];+const EMPTY_LAYOUT: LayoutDraft = { summary: { caption: "", meta: [], canvas: "single" }, items: [], aspect: "1:1" };++/** The first model a node feeds ("model id|aspect ratio"), so the editor sizes the canvas as that model renders. */+const downstreamOf = (s: EditorSnapshot, id: string): string => {+ for (const e of s.graph.edges) {+ if (e.source !== id) continue;+ const t = s.byId.get(e.target);+ if (t?.data.modelId) return `${t.data.modelId}|${t.data.params?.aspectRatio ?? ""}`;+ }+ return "";+};++/** A canvas of that shape, 1024 px on its longer side in steps of 16 (no image model to ask). */+function plainCanvas(aspect: string | undefined): EditorCanvas {+ const r = ratioNum(aspect);+ const r16 = (v: number) => Math.max(16, Math.round(v / 16) * 16);+ const width = r >= 1 ? 1024 : r16(1024 * r);+ const height = r >= 1 ? r16(1024 / r) : 1024;+ return { width, height, asked: { width, height }, exact: false };+}++const ratioNum = (aspect: string | undefined) => {+ const [a, b] = (aspect ?? "1:1").split(":").map(Number);+ return a > 0 && b > 0 ? a / b : 1;+};++const LayoutNode = memo(function LayoutNode({ id, data, selected }: NodeProps<FlowNode>) {+ const actions = useEditorActions();+ const { readOnly } = useEditorGlobals();+ const [open, setOpen] = useState(false);+ const draft = readLayout(data.layout) ?? EMPTY_LAYOUT;+ const feeds = useEditorSelector(downstreamOf, id);+ const [modelId, nodeAspect] = feeds.split("|");+ const found = modelId ? getModel(modelId) : undefined;+ const model = found?.kind === "image" ? found : undefined;+ const aspects = model?.options.aspectRatios?.filter((a) => a !== "auto") ?? LAYOUT_ASPECTS;+ const aspect = nodeAspect || draft.aspect || "1:1";+ const canvasFor = (a: string | undefined): EditorCanvas => (model ? layoutCanvas(model, { ...(a && { aspectRatio: a }) }, "t2i") : plainCanvas(a));+ const texts = draft.items.filter((it) => it.label === "text").length;+ const summary = draft.items.length ? `${draft.items.length} box${draft.items.length === 1 ? "" : "es"}${texts ? ` · ${texts} with words` : ""}` : "No boxes yet";+ return (+ <>+ <NodeShell id={id} type="layout" data={data} selected={!!selected} out="text" width={260}>+ <div className="space-y-2 p-3">+ <button+ type="button"+ onClick={() => setOpen(true)}+ disabled={readOnly}+ aria-label={`Edit layout: ${summary}`}+ className={cn("relative mx-auto block w-full overflow-hidden rounded-md border border-dashed border-border-strong bg-muted/50 focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:outline-none", NO_DRAG)}+ style={{ aspectRatio: `${ratioNum(aspect)}`, maxWidth: `calc(12rem * ${ratioNum(aspect)})` }}+ >+ {draft.items.map((it, i) => (+ <span+ key={i}+ aria-hidden+ className="absolute overflow-hidden rounded-[2px] border px-0.5 text-left text-[8px] leading-tight text-foreground/80"+ style={{+ left: `${it.box[0] * 100}%`,+ top: `${it.box[1] * 100}%`,+ width: `${(it.box[2] - it.box[0]) * 100}%`,+ height: `${(it.box[3] - it.box[1]) * 100}%`,+ borderColor: it.color ?? KIND_COLOR[it.label],+ background: `color-mix(in oklab, ${it.color ?? KIND_COLOR[it.label]} 14%, transparent)`,+ }}+ >+ {it.label === "text" ? it.text : ""}+ </span>+ ))}+ {!draft.items.length && <span className="absolute inset-0 grid place-items-center p-2 text-center text-[12px] text-muted-foreground">Draw boxes for a headline, a product, a price</span>}+ </button>+ <div className="flex items-center justify-between gap-2">+ <span className="truncate text-[12px] text-muted-foreground">+ {aspect} · {summary}+ </span>+ {!readOnly && (+ <button type="button" className={chip} onClick={() => setOpen(true)}>+ <LayoutDashboard className="size-3" /> Edit layout+ </button>+ )}+ </div>+ <p className="text-[11px] leading-snug text-muted-foreground">+ {found && !readsBoxes(found) ? "This model reads the layout as words, not exact positions." : "Wire it into an image model's Prompt. With a table, {Column} in a box's words fills row by row."}+ </p>+ </div>+ </NodeShell>+ {/* Beside the card, not in it: the card's menus and clicks stay out of the editor. */}+ {open && (+ <LayoutEditor+ open={open}+ onOpenChange={setOpen}+ layout={draft}+ caption={draft.summary.caption}+ aspect={aspect}+ aspects={aspects}+ canvasFor={canvasFor}+ model={model}+ onDone={(r) => actions.update(id, { layout: { ...r.layout, summary: { ...r.layout.summary, caption: r.caption.trim() }, ...(r.aspect && { aspect: r.aspect }) } })}+ />+ )}+ </>+ );+}, sameNodeProps);+export const NODE_TYPES = {prompt: PromptNode,"image-input": MediaInputNode,@@ -1773,6 +1890,7 @@ export const NODE_TYPES = {concat: GeneratorNode,restore: GeneratorNode,table: TableNode,+ layout: LayoutNode,output: OutputNode,note: NoteNode,...BOARD_NODE_TYPES,diff --git a/src/components/studio/layout-editor.tsx b/src/components/studio/layout-editor.tsxindex 308341c4..3282f573 100644--- a/src/components/studio/layout-editor.tsx+++ b/src/components/studio/layout-editor.tsx@@ -106,7 +106,11 @@ export function LayoutEditor(props: {ref={content}showCloseButton={false}aria-describedby="layout-editor-hint"- className="flex h-[100svh] w-screen max-w-none flex-col gap-0 overflow-hidden rounded-none p-0 outline-none sm:h-[min(92vh,880px)] sm:w-[min(96vw,1180px)] sm:max-w-none sm:rounded-xl"+ // "nokey": a board under the dialog (Canvas) leaves its keys alone; the keys stay in the editor (Escape still closes it).+ className="nokey flex h-[100svh] w-screen max-w-none flex-col gap-0 overflow-hidden rounded-none p-0 outline-none sm:h-[min(92vh,880px)] sm:w-[min(96vw,1180px)] sm:max-w-none sm:rounded-xl"+ onKeyDown={(e) => {+ if (e.key !== "Escape") e.stopPropagation();+ }}onOpenAutoFocus={(e) => {e.preventDefault();content.current?.focus();diff --git a/src/lib/catalog/canvas.ts b/src/lib/catalog/canvas.tsindex 5005d036..cd023ebc 100644--- a/src/lib/catalog/canvas.ts+++ b/src/lib/catalog/canvas.ts@@ -15,6 +15,8 @@ import { chainedWaitMessage, keyframeChain } from "./keyframes";import { estimateCost, inferOperation, planGeneration, routesFor, type Plan } from "./plan";import { replacedBy, replacementOf } from "./replaced";import { REGEN_COPY, REGEN_MODEL } from "./regenerate";+import { compileWords, LAYOUT_PARAM, readLayout, type LayoutDraft } from "@/lib/layout-prompt";+import { fillLayout, layoutPlaceholders } from "@/lib/layout-surfaces";import {OPERATION_LABELS,OPERATION_OUTPUT,@@ -62,6 +64,7 @@ export type CanvasNodeType =| "concat"| "restore"| "table"+ | "layout"| "output"| "note";@@ -111,6 +114,8 @@ export interface CanvasNodeData {rows?: string[][];/** Translate (video) on the open engine: the Translate & dub session it started (its result comes back from there). */dubId?: string;+ /** Layout: its boxes, one row per box (src/lib/layout-prompt.ts), drawn in the Layout editor. */+ layout?: LayoutDraft;}export interface CanvasNode {@@ -242,6 +247,7 @@ export const NODE_SPECS: Record<CanvasNodeType, NodeSpec> = {concat: { type: "concat", label: "Assemble film", group: "Utilities", icon: "Film", ops: ["concat"], description: "Up to 50 clips in one film: trim and mute each, pick the frame" },restore: { type: "restore", label: "Restore & colourise", group: "Utilities", icon: "Palette", ops: ["restore-video"], description: "Old or black-and-white footage, cleaned and in colour" },table: { type: "table", label: "Table", group: "Inputs", icon: "Table", description: "Rows of words: what it feeds runs once per row" },+ layout: { type: "layout", label: "Layout", group: "Inputs", icon: "LayoutDashboard", description: "Boxes for a headline, a product, a price: the image model draws each in its place" },output: { type: "output", label: "Output", group: "Output", icon: "MonitorPlay", description: "Preview what's connected, side by side" },note: { type: "note", label: "Sticky note", group: "Output", icon: "StickyNote", description: "A note on the board (not run)" },};@@ -295,6 +301,7 @@ export const PALETTE: PaletteItem[] = [{ ...pick("concat"), id: "concat", keywords: "concatenate join merge stitch edit trim mute film assemble" },{ ...pick("restore"), id: "restore", keywords: "restore colourise colorize archive old footage black and white film scan vhs" },{ ...pick("table"), id: "table", data: { columns: ["Subject"], rows: [[""], [""], [""]] }, keywords: "rows batch spreadsheet list variations csv grid" },+ { ...pick("layout"), id: "layout", data: { layout: { summary: { caption: "", meta: [], canvas: "single" }, items: [], aspect: "1:1" } }, keywords: "layout boxes poster text placement composition headline price moss" },{ ...pick("output"), id: "output", keywords: "preview compare result" },{ ...pick("note"), id: "note", keywords: "comment annotation" },];@@ -608,7 +615,7 @@ const toPortType = (k: MediaKind | undefined): PortType | null => (k === "image"/** The type of a node's output handle (null = no output handle). */export function outputType(_graph: CanvasGraph, n: CanvasNode): PortType | null {- if (n.type === "prompt" || n.type === "table") return "text";+ if (n.type === "prompt" || n.type === "table" || n.type === "layout") return "text";if (n.type === "clone-voice") return "voice";if (n.type === "element") return "element";if (MEDIA_INPUT_TYPE[n.type]) return MEDIA_INPUT_TYPE[n.type]!;@@ -763,6 +770,7 @@ export function singleInput(graph: CanvasGraph, target: string, targetHandle?: stype Source =| { kind: "text"; text: string }+ | { kind: "layout"; draft: LayoutDraft }| { kind: "media"; url: string }| { kind: "element"; handle: string }| { kind: "node"; nodeId: string };@@ -858,6 +866,11 @@ function sourceOf(graph: CanvasGraph, s: CanvasNode): Source | { error: string }const first = tableRows(s)[0];return first ? { kind: "text", text: rowText(first) } : { error: `Fill in a row of “${nodeLabel(s)}”` };}+ // A layout goes in whole: the request carries it and the plan compiles it for the model at the size it renders.+ if (s.type === "layout") {+ const draft = readLayout(s.data.layout);+ return draft?.items.length ? { kind: "layout", draft } : { error: `Draw a box in “${nodeLabel(s)}”: Edit layout` };+ }if (s.type === "clone-voice") {// A sample wired in wins over the node's own file (a recording, a generated voice).const e = graph.edges.find((x) => x.target === s.id && x.targetHandle === "audio");@@ -954,6 +967,7 @@ function buildRequest(graph: CanvasGraph, n: CanvasNode, model: ModelDef, singleconst deps: string[] = [];const texts: string[] = [];const handles: string[] = [];+ const layouts: LayoutDraft[] = [];let generatedText = 0;for (const port of ports) {@@ -973,6 +987,7 @@ function buildRequest(graph: CanvasGraph, n: CanvasNode, model: ModelDef, singleif (port.id === "prompt") {for (const src of list) {if (src.kind === "text" && src.text) texts.push(src.text);+ if (src.kind === "layout") layouts.push(src.draft);if (src.kind === "node") {generatedText++;chain.push({ slot: "prompt" });@@ -1011,6 +1026,11 @@ function buildRequest(graph: CanvasGraph, n: CanvasNode, model: ModelDef, single}}if (generatedText > 1) return { error: "Connect one generated text at a time — join the others into one text model" };+ if (layouts.length > 1) return { error: "Connect one layout at a time" };+ // A picture model takes the layout itself (params.extra.layout: planLayout compiles it for that model at the size it+ // renders, prompt rewriting off); anything else reads it as sentences.+ const layout = layouts[0] && model.kind === "image" ? layouts[0] : undefined;+ if (layouts[0] && !layout) texts.push(compileWords(layouts[0]));// A voice wired into a model that only speaks preset voices: say which ones clone.if (!model.options.voiceClone && graph.edges.some((e) => e.target === n.id && e.targetHandle === "voice")) {const cloners = MODELS.filter((m) => !m.hidden && m.options.voiceClone && op && supportsOp(m, op) && m.engine === model.engine).map((m) => m.name);@@ -1030,6 +1050,11 @@ function buildRequest(graph: CanvasGraph, n: CanvasNode, model: ModelDef, singleconst params: GenParams = { ...n.data.params };for (const k of Object.keys(params) as (keyof GenParams)[]) if (params[k] === undefined || params[k] === "") delete params[k];+ if (layout) {+ params.extra = { ...params.extra, [LAYOUT_PARAM]: layout };+ // The boxes were drawn on a shape: the picture takes it unless the node picks its own.+ if (!params.aspectRatio && layout.aspect && model.options.aspectRatios?.includes(layout.aspect)) params.aspectRatio = layout.aspect;+ }const request: GenerationRequest = {feature: "canvas",modelId: model.id,@@ -1051,6 +1076,9 @@ function buildRequest(graph: CanvasGraph, n: CanvasNode, model: ModelDef, singleexport const TABLE_LIMITS = { rows: 50, columns: 8, cell: 2000, column: 40 } as const;+/** A Layout node holds up to this many boxes. */+export const LAYOUT_NODE_LIMITS = { boxes: 64 } as const;+/** A table's filled rows (a row with at least one cell written), each with one cell per column. */export function tableRows(t: Pick<CanvasNode, "data">): string[][] {const width = Math.max(1, t.data.columns?.length ?? 1);@@ -1123,7 +1151,10 @@ function rowRequest(graph: CanvasGraph, n: CanvasNode, model: ModelDef, b: { tabconst columns = (b.table.data.columns ?? []).map((c) => c.trim());const own = n.data.prompt ?? "";const direct = graph.edges.some((e) => e.source === b.table.id && e.target === n.id);- const named = direct && columns.some((c) => c && own.includes(`{${c}}`));+ // Layouts wired into this node: "{Column}" in their words fills from each row too (one layout, a batch of posters).+ const layoutIds = graph.edges.filter((e) => e.target === n.id && e.targetHandle === "prompt" && nodes.get(e.source)?.type === "layout").map((e) => e.source);+ const layoutNames = new Set(layoutIds.flatMap((id) => layoutPlaceholders(readLayout(nodes.get(id)!.data.layout) ?? { summary: { caption: "", meta: [], canvas: "single" }, items: [] })));+ const named = direct && columns.some((c) => c && (own.includes(`{${c}}`) || layoutNames.has(c)));const feeds = tablesFeeding(graph);const perRow = (id: string) => {const r = feeds(nodes.get(id)!);@@ -1135,7 +1166,12 @@ function rowRequest(graph: CanvasGraph, n: CanvasNode, model: ModelDef, b: { tabconst prompt = named ? columns.reduce((p, c, j) => (c ? p.replaceAll(`{${c}}`, cells[j]) : p), own) : own;const rowGraph: CanvasGraph = {...graph,- nodes: graph.nodes.map((x) => (x.id === b.table.id ? { ...x, type: "prompt" as const, data: { text: named ? "" : rowText(cells) } } : x.id === n.id ? { ...x, data: { ...x.data, prompt } } : x)),+ nodes: graph.nodes.map((x) => {+ if (x.id === b.table.id) return { ...x, type: "prompt" as const, data: { text: named ? "" : rowText(cells) } };+ if (x.id === n.id) return { ...x, data: { ...x.data, prompt } };+ const d = direct && layoutIds.includes(x.id) ? readLayout(x.data.layout) : null;+ return d ? { ...x, data: { ...x.data, layout: fillLayout(d, columns, cells) } } : x;+ }),};const r = buildRequest(rowGraph, rowGraph.nodes.find((x) => x.id === n.id)!, model, true);if ("error" in r) return { error: `Row ${i + 1}: ${r.error}` };diff --git a/src/lib/catalog/marketing.ts b/src/lib/catalog/marketing.tsindex 80927ebe..ca44cf24 100644--- a/src/lib/catalog/marketing.ts+++ b/src/lib/catalog/marketing.ts@@ -975,10 +975,36 @@ export const MARKETING_IMAGE_NOTE: Record<Engine, string> = {* Whether a run's words are set over the picture in the browser (an open model, or the Original on either engine), not* drawn by the model (GPT Image 2.5, Ideogram, Recraft, Nano Banana Pro in the cloud).*/-export const wordsOnTop = (engine: Engine, modelId: string): boolean => engine === "open" || modelId === MARKETING_IMAGE_MODEL;+export const wordsOnTop = (engine: Engine, modelId: string, drawn = false): boolean => !drawn && (engine === "open" || modelId === MARKETING_IMAGE_MODEL);++/**+ * "Words drawn by the model" (N7-8), a choice on the formats with words (Ads, Poster, Marketplace) and in Ads Studio:+ * the copy's places (planAd, src/lib/layout-surfaces.ts) become a layout, and a model that reads boxes draws the+ * headline, the button and the product in them. Setting the words on top in the browser stays the default: it gives+ * your exact fonts. MOSS-Image on your GPU; MOSS-Image hosted on fal, Ideogram 4.5 or FLUX.3 in the cloud, each with+ * prompt expansion off (src/lib/catalog/plan.ts planLayout).+ */+export const DRAWN_WORDS_MODELS: Record<Engine, ModelChoice[]> = {+ open: [{ id: "oss-moss-image", name: "MOSS-Image", note: "MOSS-Image on your GPU · draws your words in place, free" }],+ cloud: [+ { id: "moss-image", name: "MOSS-Image", note: "MOSS-Image, hosted on fal · draws your words in place" },+ { id: "ideogram-4-5", name: "Ideogram 4.5", note: "Draws the exact text in place" },+ { id: "flux-3", name: "FLUX.3", note: "Draws the text in place and keeps your product photo" },+ ],+};++export const DRAWN_WORDS_LABEL = "Words drawn by the model";+/** The option's hint, beside the default it leaves alone. */+export const DRAWN_WORDS_HINT = "The headline and button are drawn into the picture, in their places. Off: they're set on top in your brand fonts, letter for letter.";++/** The model that draws the words on an engine: the one asked for when it is a choice there, else the first. */+export function drawnWordsModel(engine: Engine, asked?: string | null): string {+ return asked && DRAWN_WORDS_MODELS[engine].some((c) => c.id === asked) ? asked : DRAWN_WORDS_MODELS[engine][0].id;+}/** The models a Marketing Studio format can use on an engine, the default first: the Original for every image format. */-export function formatModels(format: FormatDef, engine: Engine, has: { product: boolean; avatar: boolean }): ModelChoice[] {+export function formatModels(format: FormatDef, engine: Engine, has: { product: boolean; avatar: boolean }, drawn = false): ModelChoice[] {+ if (drawn && format.text && format.pipeline === "image") return DRAWN_WORDS_MODELS[engine];const original: ModelChoice = { id: MARKETING_IMAGE_MODEL, note: MARKETING_IMAGE_NOTE[engine] };if (engine === "open") {switch (format.pipeline) {@@ -1031,6 +1057,8 @@ export const AD_VISUAL_MODELS: Record<Engine, ModelChoice[]> = {{ id: MARKETING_IMAGE_MODEL, name: "Fuobe Marketing Image", note: "Fuobe Original · Qwen-Image-Edit 2511 with your product photo, hosted on fal" },{ id: "nano-banana-pro", name: "Nano Banana Pro", note: "Google's Gemini 3 Pro Image, through fal" },{ id: "gpt-image-2-5", name: "GPT Image 2.5", note: "OpenAI's GPT Image 2.5 Flare, through fal" },+ // A model that reads boxes gets a "keep clear" layout: the product placed where the words leave room (src/server/ads.ts).+ { id: "flux-3", name: "FLUX.3", note: "Black Forest Labs' FLUX.3 through fal, with the product kept clear of the words" },],};diff --git a/src/lib/layout-plan.ts b/src/lib/layout-plan.tsnew file mode 100644index 00000000..59d62baf--- /dev/null+++ b/src/lib/layout-plan.ts@@ -0,0 +1,89 @@+/*+ * "Plan layout" (N7-8): a sentence ("a sale poster for my candle shop, 30% off") becomes a starting layout to adjust.+ * A text model writes a pixel draft (the instructions below, adapted with the Assist skill skills/layout-poster from+ * OpenMOSS's Apache-2.0 prompt-enhancer skill); parseLayout reads it, validateLayout checks it. With no text model, or+ * when its answer can't be used, planByRules lays out a poster from the sentence itself. Pure: the server's route and+ * the tests share it.+ */+import { aspectOf, parseLayout, validateLayout, type LayoutBox, type LayoutDraft, type LayoutItem } from "./layout-prompt";++/** The longest sentence the planner takes. */+export const PLAN_WORDS_MAX = 1000;++/**+ * The planner's instructions. Adapted from OpenMOSS MOSS-Image's prompt-enhancer skill (skills/moss-image-prompt-enhancer+ * SKILL.md and references/layout.md at 2b46b1e0e13b5aaec253879e0d006a42564b8b27), Copyright OpenMOSS, Apache License 2.0.+ */+export const LAYOUT_PLAN_SYSTEM = `You plan image layouts for a picture model that places boxes. Answer with ONE JSON object and nothing else: no code fence, no words before or after it.+The schema: {"width": W, "height": H, "bbox_coord_space": "abs", "bbox_format": "xyxy", "summary": {"caption": "...", "meta": ["..."], "canvas": "single"}, "items": [{"label": "object" | "character" | "text", "caption": "...", "text": "...", "bbox": [x_min, y_min, x_max, y_max]}]}+Rules:+- Use exactly the width and height given. Boxes are whole pixels from the top-left corner: x from 0 to width, y from 0 to height. Never use 0-1 fractions.+- summary.caption describes the whole picture: subject, setting, medium, lighting, palette and mood, in plain sentences.+- One box per coherent visible unit: a headline, a product, a person, a price tag, a button. Usually 3 to 6 boxes. Boxes may overlap where the picture needs it.+- A "text" item carries the exact visible words in "text" (keep the user's wording, spelling and language) and its caption describes the lettering: size, weight, colour, typeface style. Write real copy, never "headline here".+- An "object" or "character" item's caption describes what it looks like. A box is a placement, not a border or a panel to draw.+- Establish a reading order and hierarchy: the headline large, supporting words smaller, enough room for the words to read at this size.+- Keep the user's subject, counts, style and any words they want shown. Don't invent facts such as dates, addresses or prices they didn't give.`;++/** What the planner is asked: the sentence and the canvas it draws on. */+export function planRequest(words: string, width: number, height: number): string {+ return `Canvas: ${width} × ${height} pixels (width × height).\nPlan the layout for: ${words.trim()}`;+}++/** A model's answer as a draft on this canvas, when it is one that runs (no errors from validateLayout). */+export function readPlanned(text: string | null | undefined, width: number, height: number): LayoutDraft | null {+ if (!text?.trim()) return null;+ const parsed = parseLayout(text, { width, height });+ if (!parsed || !parsed.draft.items.length) return null;+ const draft: LayoutDraft = { ...parsed.draft, aspect: aspectOf(width, height) ?? parsed.draft.aspect };+ return validateLayout(draft, width, height).some((i) => i.level === "error") ? null : draft;+}++// ---------------------------------------------------------------------------+// The rules (no text model)++const OFFER = /(\d{1,3}\s?%\s?off|half price|buy one,? get one(?: free)?|free shipping|[$£€]\s?\d+(?:[.,]\d{1,2})?|\d+(?:[.,]\d{1,2})?\s?(?:usd|eur|gbp|€|£))/i;+const QUOTED = /["“”«‘']([^"“”«»‘’']{2,80})["”»’']/;+const FOR_WHOM = /\bfor (?:my|our|the|a|an)\s+([\p{L}\p{N}'&-]+(?:\s+[\p{L}\p{N}'&-]+){0,3})/iu;+const STOP = /\s+(?:with|and|that|which|in|on|at|for)\b.*$/i;++const title = (s: string) =>+ s+ .trim()+ .split(/\s+/)+ .map((w) => (w.length > 2 || /^[A-Z]/.test(w) ? w[0].toUpperCase() + w.slice(1) : w))+ .join(" ");++const box = (x0: number, y0: number, x1: number, y1: number): LayoutBox => [x0, y0, x1, y1];++/**+ * A poster from the sentence alone: the words in quotes (or an offer such as "30% off", or who it is for) as the+ * headline, the offer under it when the headline is something else, the subject in the middle and a button. Portrait+ * and square canvases stack them; a wide one puts the words in a column beside the subject.+ */+export function planByRules(words: string, width: number, height: number): LayoutDraft {+ const said = words.trim().replace(/\s+/g, " ");+ const quoted = QUOTED.exec(said)?.[1]?.trim();+ const offer = OFFER.exec(said)?.[1]?.trim();+ const whom = FOR_WHOM.exec(said)?.[1]?.replace(STOP, "").trim();+ const headline = quoted ?? (offer ? offer.toUpperCase() : whom ? title(whom) : title(said.split(/[,.;:!?]/)[0].split(" ").slice(0, 5).join(" ")));+ const second = quoted && offer ? offer.toUpperCase() : !quoted && offer && whom ? title(whom) : "";+ const subject = said.replace(QUOTED, "").replace(OFFER, "").replace(/[,\s]+$/, "").trim() || said;+ const wide = width > height * 1.2;+ const items: LayoutItem[] = wide+ ? [+ { label: "text", caption: "A large, bold headline in clean lettering, high contrast against the background", text: headline, box: box(0.06, 0.18, 0.48, 0.44) },+ ...(second ? [{ label: "text" as const, caption: "Smaller supporting words under the headline, bold and easy to read", text: second, box: box(0.06, 0.48, 0.44, 0.6) }] : []),+ { label: "text", caption: "A rounded button with a short call to action in bold letters", text: "Shop now", box: box(0.06, 0.7, 0.28, 0.82) },+ { label: "object", caption: `The hero of the picture: ${subject}`, box: box(0.52, 0.1, 0.94, 0.9) },+ ]+ : [+ { label: "text", caption: "A large, bold headline in clean lettering, high contrast against the background", text: headline, box: box(0.08, 0.05, 0.92, 0.2) },+ ...(second ? [{ label: "text" as const, caption: "Smaller supporting words under the headline, bold and easy to read", text: second, box: box(0.2, 0.21, 0.8, 0.29) }] : []),+ { label: "object", caption: `The hero of the picture: ${subject}`, box: box(0.14, 0.32, 0.86, 0.82) },+ { label: "text", caption: "A rounded button with a short call to action in bold letters", text: "Shop now", box: box(0.3, 0.86, 0.7, 0.95) },+ ];+ const caption = said ? said[0].toUpperCase() + said.slice(1).replace(/[.\s]*$/, ".") : "";+ const aspect = aspectOf(width, height);+ return { summary: { caption, meta: ["poster", "graphic design"], canvas: "single" }, items, ...(aspect && { aspect }) };+}diff --git a/src/lib/layout-surfaces.ts b/src/lib/layout-surfaces.tsnew file mode 100644index 00000000..5d0537ab--- /dev/null+++ b/src/lib/layout-surfaces.ts@@ -0,0 +1,253 @@+/*+ * Layouts from the places that already know where things go (docs/research/new-models-7.md §4.10, N7-8): Ads Studio's+ * planned rectangles (planAd), Marketing Studio's formats (the same planner, in the layout the browser sets the words+ * in), and a Canvas Layout node fed by a Table. Pure: the browser, the server and the tests share it.+ *+ * Two kinds of layout come out of an ad plan:+ * - "words": the headline, body and button as text items with their exact words, the logo area, a colour panel and+ * the product as object items, so a model that reads boxes (MOSS-Image, FLUX.3, Ideogram 4.5) draws the whole ad;+ * - "clear": the product alone, in the part of the picture the words leave free, so a picture that gets its words set+ * on top in the browser keeps the product out of their way.+ */+import { planAd, sizeFor, themeFrom, type AdContent, type AdLayout, type AdPlan, type Measure, type Rect, type TextBox } from "@/components/ads/layout";+import type { LayoutBox, LayoutDraft, LayoutItem } from "./layout-prompt";++/**+ * A text width without a canvas (the server and tests): about half the font size per character, a little more in+ * bold. The boxes guide the model; they don't set the type, so an estimate is enough.+ */+export const roughMeasure: Measure = (text, font) => {+ const px = Number(/(\d+(?:\.\d+)?)px/.exec(font)?.[1] ?? 16);+ const bold = /^\s*[6-9]00\b/.test(font);+ return [...text].length * px * (bold ? 0.58 : 0.52);+};++export type AdDraftMode = "words" | "clear";++export interface AdDraftOptions {+ mode: AdDraftMode;+ /** What the product (or the scene) looks like: the picture's own description. */+ product: string;+ /** The whole picture in words (the summary caption). */+ caption: string;+ /** Style tags (summary.meta). */+ meta?: string[];+}++const clamp01 = (v: number) => Math.max(0, Math.min(1, v));+const round = (v: number) => Math.round(v * 1e4) / 1e4;++function boxOf(r: Rect, W: number, H: number): LayoutBox {+ return [round(clamp01(r.x / W)), round(clamp01(r.y / H)), round(clamp01((r.x + r.w) / W)), round(clamp01((r.y + r.h) / H))];+}++/** A text block's rectangle on the canvas (as planRects reads it). */+function textRect(b: TextBox): Rect {+ return {+ x: b.align === "center" ? b.x - b.width / 2 : b.x,+ y: b.y,+ w: b.width,+ h: b.lines.length * b.lineHeight,+ };+}++function intersect(a: Rect, b: Rect): Rect | null {+ const x0 = Math.max(a.x, b.x);+ const y0 = Math.max(a.y, b.y);+ const x1 = Math.min(a.x + a.w, b.x + b.w);+ const y1 = Math.min(a.y + a.h, b.y + b.h);+ return x1 > x0 && y1 > y0 ? { x: x0, y: y0, w: x1 - x0, h: y1 - y0 } : null;+}++/** Every rectangle the words (and the logo) take, as the browser draws them. */+export function copyRects(plan: AdPlan): Rect[] {+ return [plan.logo, plan.brand && textRect(plan.brand), textRect(plan.headline), plan.body && textRect(plan.body), plan.cta].filter((r): r is Rect => !!r && r.w > 0 && r.h > 0);+}++/**+ * Where the product goes: the picture's rectangle, less the words' space. When the words sit on the picture (Overlay,+ * Band), the largest free part of it above, below, left or right of them; a part smaller than a fifth of the picture+ * is no room for a product, so the whole picture is used.+ */+export function productRect(plan: AdPlan): Rect {+ const img: Rect = plan.image ? { x: plan.image.x, y: plan.image.y, w: plan.image.w, h: plan.image.h } : { x: 0, y: 0, w: plan.w, h: plan.h };+ const over = copyRects(plan)+ .filter((r) => r !== plan.logo)+ .map((r) => intersect(r, img))+ .filter((r): r is Rect => !!r);+ if (!over.length) return img;+ const x0 = Math.min(...over.map((r) => r.x));+ const y0 = Math.min(...over.map((r) => r.y));+ const x1 = Math.max(...over.map((r) => r.x + r.w));+ const y1 = Math.max(...over.map((r) => r.y + r.h));+ const gap = plan.w * 0.02;+ const parts: Rect[] = [+ { x: img.x, y: img.y, w: img.w, h: y0 - gap - img.y },+ { x: img.x, y: y1 + gap, w: img.w, h: img.y + img.h - y1 - gap },+ { x: img.x, y: img.y, w: x0 - gap - img.x, h: img.h },+ { x: x1 + gap, y: img.y, w: img.x + img.w - x1 - gap, h: img.h },+ ].filter((r) => r.w > 0 && r.h > 0);+ const best = parts.sort((a, b) => b.w * b.h - a.w * a.h)[0];+ return best && best.w * best.h >= (img.w * img.h) / 5 ? best : img;+}++/** The family a CSS font string names first ("800 64px \"Inter\", system-ui" → Inter). */+const familyOf = (font: string) => /"([^"]+)"/.exec(font)?.[1] ?? "clean sans-serif";+/** A text colour as words a model reads: its hex, or white / near-black for the planner's rgba shades. */+const colourWords = (c: string) => (/^#[0-9a-f]{6}$/i.test(c) ? `colour ${c}` : /255,\s*255,\s*255/.test(c) ? "white" : `colour ${c}`);++const sentence = (s: string) => s.trim().replace(/[.\s]+$/, "");++/** An ad plan as a layout draft (see the file comment for the two modes). */+export function adPlanDraft(plan: AdPlan, o: AdDraftOptions): LayoutDraft {+ const W = plan.w;+ const H = plan.h;+ const items: LayoutItem[] = [];+ const product = sentence(o.product) || "The product";+ if (o.mode === "words") {+ if (plan.panel)+ items.push({+ label: "object",+ caption: `A flat, solid ${plan.panel.color} colour panel with nothing printed on it`,+ box: boxOf(plan.panel, W, H),+ });+ items.push({+ label: "object",+ caption: product,+ box: boxOf(productRect(plan), W, H),+ });+ if (plan.logo)+ items.push({+ label: "object",+ caption: "The brand's logo, small and crisp",+ box: boxOf(plan.logo, W, H),+ });+ const text = (b: TextBox | undefined, what: string) => {+ const words = b?.lines.join("\n").trim();+ if (!b || !words) return;+ items.push({+ label: "text",+ caption: `${what}, ${b.align === "center" ? "centred" : "left-aligned"}, ${colourWords(b.color)}, in a ${familyOf(b.font)}-style typeface`,+ text: words,+ box: boxOf(textRect(b), W, H),+ });+ };+ text(plan.brand, "The brand name in small capitals");+ text(plan.headline, "A large, bold headline");+ text(plan.body, "Smaller supporting copy, easy to read");+ const label = plan.cta?.text.lines.join(" ").trim();+ if (plan.cta && label) {+ items.push({+ label: "text",+ caption: `A rounded pill button in ${plan.cta.color} with its label in bold ${colourWords(plan.cta.text.color)} letters`,+ text: label,+ box: boxOf(plan.cta, W, H),+ });+ }+ } else {+ items.push({+ label: "object",+ caption: product,+ box: boxOf(productRect(plan), W, H),+ });+ }+ const shade = o.mode === "words" && plan.scrim ? "A soft dark shade fades in behind the words so they read clearly" : "";+ const clear = o.mode === "clear" ? "No text, letters or logos anywhere; the rest of the picture stays calm and uncluttered" : "";+ const caption = [sentence(o.caption), shade, clear].filter(Boolean).join(". ");+ const aspect = aspectFrom(W, H);+ return {+ summary: {+ caption: caption ? `${caption}.` : "",+ meta: o.meta ?? [],+ canvas: "single",+ },+ items,+ ...(aspect && { aspect }),+ };+}++function gcd(a: number, b: number): number {+ return b ? gcd(b, a % b) : a;+}+const aspectFrom = (w: number, h: number) => {+ const g = gcd(Math.round(w), Math.round(h));+ return g ? `${Math.round(w) / g}:${Math.round(h) / g}` : undefined;+};++export interface AdDraftInput {+ /** "4:5", "3:4"… (the picture's shape). */+ ratio: string;+ layout: AdLayout;+ content: AdContent;+ brand?: {+ colors?: string[];+ fonts?: { heading?: string; body?: string };+ logo?: string;+ } | null;+ mode: AdDraftMode;+ product: string;+ caption: string;+ meta?: string[];+}++/**+ * The layout for an ad or a Marketing Studio picture: planned as the browser would set it (planAd, with the brand's+ * colours and fonts and the logo's place when there is one), then turned into a draft. The draft keeps the shape+ * asked for, so the server compiles it at the size the model renders (src/lib/catalog/plan.ts planLayout).+ */+export function adDraft(i: AdDraftInput): LayoutDraft {+ const { w, h } = sizeFor(i.ratio);+ const plan = planAd({+ ratio: i.ratio,+ layout: i.layout,+ content: i.content,+ theme: themeFrom(i.brand),+ image: { w, h },+ logo: i.brand?.logo ? { w: 3, h: 1 } : null,+ measure: roughMeasure,+ });+ const draft = adPlanDraft(plan, {+ mode: i.mode,+ product: i.product,+ caption: i.caption,+ meta: i.meta,+ });+ return /^\d+:\d+$/.test(i.ratio) ? { ...draft, aspect: i.ratio } : draft;+}++// ---------------------------------------------------------------------------+// Tables (Canvas): one layout, a batch of posters++const PLACEHOLDER = /\{([^{}\n]{1,40})\}/g;++/** The "{Column}" names a layout's words use (text items, captions and the whole picture's caption). */+export function layoutPlaceholders(draft: LayoutDraft): string[] {+ const found = new Set<string>();+ const scan = (s?: string) => {+ for (const m of (s ?? "").matchAll(PLACEHOLDER)) found.add(m[1].trim());+ };+ scan(draft.summary.caption);+ for (const it of draft.items) {+ scan(it.text);+ scan(it.caption);+ }+ return [...found];+}++/** A layout with a table row's cells in its "{Column}" placeholders (names as the columns spell them, trimmed). */+export function fillLayout(draft: LayoutDraft, columns: string[], cells: string[]): LayoutDraft {+ const at = new Map<string, string>();+ columns.forEach((c, j) => {+ if (c.trim()) at.set(c.trim(), cells[j] ?? "");+ });+ const fill = (s: string) => s.replace(PLACEHOLDER, (all, name: string) => (at.has(name.trim()) ? at.get(name.trim())! : all));+ return {+ ...draft,+ summary: { ...draft.summary, caption: fill(draft.summary.caption) },+ items: draft.items.map((it) => ({+ ...it,+ caption: fill(it.caption),+ ...(it.text !== undefined && { text: fill(it.text) }),+ })),+ };+}diff --git a/src/server/ads.ts b/src/server/ads.tsindex dd7eca95..c168cc4a 100644--- a/src/server/ads.ts+++ b/src/server/ads.ts@@ -8,6 +8,7 @@ import {MAX_ADS_PER_PRODUCT,MAX_PRODUCTS_PER_RUN,adVisualModel,+ drawnWordsModel,MARKETING_IMAGE_MODEL,type AdConcept,type AdCreative,@@ -16,7 +17,9 @@ import {type Product,} from "@/lib/catalog/marketing";import type { Engine, Generation, GenerationRequest, OutputFile } from "@/lib/catalog/types";-import { getModel } from "@/lib/catalog";+import { getModel, supportsOp } from "@/lib/catalog";+import { adDraft } from "@/lib/layout-surfaces";+import { LAYOUT_PARAM, readsBoxes } from "@/lib/layout-prompt";import { getBrand, getProduct, listProducts, parseJsonObject } from "./brand";import { db } from "./db";import { llmText } from "./enhance";@@ -44,6 +47,11 @@ export const BatchBody = z.object({direction: z.string().max(1000).optional(),/** The visual model (AD_VISUAL_MODELS); Fuobe Marketing Image when left out or not offered on this engine. */modelId: z.string().max(80).optional(),+ /**+ * "Words drawn by the model": each ad is drawn whole from a layout of its planned rectangles (headline, body and+ * button as text, the logo area and the product as objects) by a model that reads boxes (DRAWN_WORDS_MODELS), in 4:5.+ */+ drawnWords: z.boolean().optional(),});export type BatchInput = z.infer<typeof BatchBody>;@@ -157,11 +165,41 @@ export async function writeConcepts(brand: BrandKit, product: Product, count: nuconst NO_TEXT = "No text, letters, words, logos or watermarks anywhere in the picture; leave calm space for a headline";-export function visualRequest(c: Pick<AdConcept, "visual" | "headline">, product: Product | null, brand: BrandKit, engine: Engine, asked?: string | null): GenerationRequest {- const hero = product?.images[0];- const modelId = adVisualModel(engine, asked);+/** The format a drawn ad is made in (the one it is shown and downloaded in, as a baked ad is). */+export const DRAWN_AD_RATIO = "4:5";++/**+ * An ad's picture. Words set on top (the default): the visual alone, no text in it; a visual model that reads boxes+ * also gets a "keep clear" layout, the product placed where the words leave room. Words drawn by the model: the whole+ * ad as a layout of planAd's rectangles, drawn by MOSS-Image (or Ideogram 4.5 / FLUX.3 in the cloud).+ */+export function visualRequest(+ c: Pick<AdConcept, "visual" | "headline"> & Partial<Pick<AdConcept, "body" | "cta">>,+ product: Product | null,+ brand: BrandKit,+ engine: Engine,+ asked?: string | null,+ drawn = false,+): GenerationRequest {+ const modelId = drawn ? drawnWordsModel(engine, asked) : adVisualModel(engine, asked);const model = getModel(modelId);+ // A model that draws from words alone (MOSS-Image, Ideogram 4.5) describes the product instead of copying the photo.+ const hero = drawn && model && !supportsOp(model, "edit") ? undefined : product?.images[0];const aspect = model?.options.aspectRatios?.includes("4:5") ? "4:5" : model?.options.aspectRatios?.includes("3:4") ? "3:4" : undefined;+ const visual = c.visual.replace(/[.\s]+$/, "");+ const layout =+ drawn || (model && readsBoxes(model))+ ? adDraft({+ ratio: aspect ?? DRAWN_AD_RATIO,+ layout: "overlay",+ content: drawn ? { headline: c.headline, body: c.body || undefined, cta: c.cta || undefined, brand: brand.name } : { headline: c.headline },+ brand,+ mode: drawn ? "words" : "clear",+ product: product ? `${product.name}: ${visual}` : visual,+ caption: "",+ meta: ["advertising", drawn ? "social media ad" : "photography"],+ })+ : undefined;return {feature: "ads",modelId,@@ -169,16 +207,16 @@ export function visualRequest(c: Pick<AdConcept, "visual" | "headline">, product...(modelId === MARKETING_IMAGE_MODEL && { engine }),op: hero ? "edit" : "t2i",prompt: [- `Advertising photograph: ${c.visual.replace(/[.\s]+$/, "")}`,+ `${drawn ? "A finished social media ad" : "Advertising photograph"}: ${visual}`,hero && "Keep the product exactly as in the reference photo: shape, label, logo, text and colours",brandLine(brand),- NO_TEXT,+ !drawn && NO_TEXT,].filter(Boolean).join(". ").concat("."),inputs: hero ? { images: [hero] } : undefined,- params: { aspectRatio: aspect, numOutputs: 1 },+ params: { aspectRatio: aspect, numOutputs: 1, ...(layout && { extra: { [LAYOUT_PARAM]: layout } }) },title: c.headline,batchTitle: `${brand.name} · ads`,};@@ -210,8 +248,11 @@ interface CreativeRow {interface CreativeMeta {engine: Engine;modelId: string;- /** "baked": drawn whole, words included, in one format by a one-shot ad model before build plan O7 (history). */- route: "fuobe" | "baked";+ /**+ * "baked": drawn whole, words included, in one format by a one-shot ad model before build plan O7 (history).+ * "drawn": drawn whole from a layout of its rectangles by a model that reads boxes ("Words drawn by the model").+ */+ route: "fuobe" | "baked" | "drawn";direction?: string;/** A baked ad's one format. */ratio?: string;@@ -243,7 +284,7 @@ export function estimateBatch(input: BatchInput, draft?: { brand: BrandKit; prodif (!brand) throw new AdsError("That brand no longer exists");const total = input.items.reduce((n, i) => n + i.count, 0);const product = draft ? draft.product : getProduct(input.items[0].productId);- const p = previewGeneration(visualRequest({ visual: "the product", headline: "Ad" }, product, brand, input.engine, input.modelId));+ const p = previewGeneration(visualRequest({ visual: "the product", headline: "Ad", cta: "Shop now" }, product, brand, input.engine, input.modelId, !!input.drawnWords));let copy = 0;try {copy = previewGeneration({ feature: "ads", modelId: input.engine === "open" ? "oss-text-llm" : "text-llm", op: "write", prompt: "copy" }).costUsd ?? 0;@@ -282,11 +323,11 @@ export function createBatch(input: BatchInput, fixed: FixedCopy = {}): { batchIdreturn { product: p, count: i.count };});const est = estimateBatch(input); // validates the model, engine mode and price now- const route = "fuobe";+ const route = input.drawnWords ? "drawn" : "fuobe";const batchId = nanoid(10);const now = Date.now();db().prepare("INSERT INTO ad_batches (id, brand_id, engine, route, model_id, direction, created_at) VALUES (?, ?, ?, ?, ?, ?, ?)").run(batchId, brand.id, input.engine, route, est.modelId, input.direction ?? null, now);- const meta: CreativeMeta = { engine: input.engine, modelId: est.modelId, route, direction: input.direction };+ const meta: CreativeMeta = { engine: input.engine, modelId: est.modelId, route, direction: input.direction, ...(route === "drawn" && { ratio: DRAWN_AD_RATIO }) };const insert = db().prepare("INSERT INTO ad_creatives (id, batch_id, brand_id, product_id, position, status, generation_id, meta_json, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, NULL, ?, ?, ?)",);@@ -330,7 +371,7 @@ async function fillBatch(batchId: string, brand: BrandKit, ids: { id: string; pr.run(k.angle, k.headline, k.body, k.cta, k.visual, Date.now(), c.id).changes;if (!ok) return;try {- setGen(c.id, createGenerations(visualRequest(k, product, brand, input.engine, input.modelId), { batchId })[0]);+ setGen(c.id, createGenerations(visualRequest(k, product, brand, input.engine, input.modelId, !!input.drawnWords), { batchId })[0]);} catch (e) {fail(c.id, (e as Error).message);}@@ -375,8 +416,9 @@ function toCreative(r: CreativeRow): AdCreative {error: s.error,generationId: r.generation_id,image: s.image,- baked: meta.route === "baked",- ...(meta.route === "baked" && { ratio: (AD_RATIOS as readonly string[]).includes(meta.ratio ?? "") ? (meta.ratio as AdCreative["ratio"]) : "4:5" }),+ // A drawn ad holds its words, as a baked one does: shown and downloaded whole, in the format it was made in.+ baked: meta.route === "baked" || meta.route === "drawn",+ ...((meta.route === "baked" || meta.route === "drawn") && { ratio: (AD_RATIOS as readonly string[]).includes(meta.ratio ?? "") ? (meta.ratio as AdCreative["ratio"]) : "4:5" }),layout: r.layout,engine: meta.engine,modelId: meta.modelId,@@ -459,8 +501,10 @@ export async function retryCreative(id: string): Promise<AdCreative> {let concept: AdConcept = { angle: r.angle ?? "", headline: r.headline ?? "", body: r.body ?? "", cta: r.cta ?? "", visual: r.visual ?? "" };if (!concept.headline || !concept.visual) concept = (await writeConcepts(brand, product ?? fakeProduct(brand), 1, meta.direction, r.position))[0];// The batch's own visual model (a baked ad's one-shot model isn't one: Fuobe Marketing Image makes it).- const g = createGenerations(visualRequest(concept, product, brand, meta.engine, meta.modelId), { batchId: r.batch_id })[0];- const fresh: CreativeMeta = { ...meta, route: "fuobe", ratio: undefined };+ // A drawn ad is drawn again (the same words, in their places).+ const drawn = meta.route === "drawn";+ const g = createGenerations(visualRequest(concept, product, brand, meta.engine, meta.modelId, drawn), { batchId: r.batch_id })[0];+ const fresh: CreativeMeta = { ...meta, route: drawn ? "drawn" : "fuobe", ratio: drawn ? DRAWN_AD_RATIO : undefined };db().prepare("UPDATE ad_creatives SET angle = ?, headline = ?, body = ?, cta = ?, visual = ?, meta_json = ? WHERE id = ?").run(concept.angle, concept.headline, concept.body, concept.cta, concept.visual, JSON.stringify(fresh), id);diff --git a/src/server/assist/tools.ts b/src/server/assist/tools.tsindex 89e2153d..c8ecf2c3 100644--- a/src/server/assist/tools.ts+++ b/src/server/assist/tools.ts@@ -7,6 +7,7 @@ import { offeredModels } from "../model-access";import { dualEngine, runsOn } from "@/lib/catalog/engines";import { pricingAt } from "@/lib/catalog/promo";import { currentModelId } from "@/lib/catalog/replaced";+import { LAYOUT_PARAM, parseLayout } from "@/lib/layout-prompt";import { OPERATION_LABELS, type ChainSlot, type GenerationRequest, type MediaKind, type ModelDef, type Operation } from "@/lib/catalog/types";import { type PlannedJob, totalCost } from "@/lib/assist";import { STORYBOARD_MODELS } from "@/lib/catalog/storyboard";@@ -278,6 +279,12 @@ const Job = z.object({end_time: z.number().optional().describe("Trim: where the kept part ends, in seconds."),num_layers: z.number().int().optional().describe("Layers: how many layers to split the image into."),system: z.string().optional().describe("Write: extra instructions for the writer (tone, format, length)."),+ layout: z+ .record(z.string(), z.unknown())+ .optional()+ .describe(+ "Image models that place boxes (MOSS-Image, FLUX.3, Ideogram 4.5): a pixel layout draft {width, height, bbox_coord_space: \"abs\", bbox_format: \"xyxy\", summary: {caption, meta, canvas}, items: [{label: object|character|text, caption, text, bbox: [x_min, y_min, x_max, y_max]}]} (the layout-poster skill). Fuobe compiles it for the model at the size it renders; other models read it as sentences.",+ ),after: z.number().int()@@ -332,6 +339,9 @@ function asRequest(j: JobInput): GenerationRequest {...(j.voice_audio && { voiceAudio: j.voice_audio }),};const shots = j.shots && j.shots > 1 ? shotList(getModel(currentModelId(j.model_id)), j.shots) : undefined;+ // A layout draft (the layout-poster skill): read on its own canvas, compiled by the plan for the model it runs on.+ const layout = j.layout ? parseLayout(j.layout)?.draft : undefined;+ const extra = { ...(j.system && { system: j.system }), ...(layout && { [LAYOUT_PARAM]: layout }) };return {feature: "assist",modelId: j.model_id,@@ -341,7 +351,7 @@ function asRequest(j: JobInput): GenerationRequest {negativePrompt: j.negative_prompt,inputs: Object.keys(inputs).length ? inputs : undefined,params: {- aspectRatio: j.aspect_ratio,+ aspectRatio: j.aspect_ratio ?? layout?.aspect,resolution: j.resolution,duration: shots ? undefined : j.duration,numOutputs: j.outputs ? Math.max(1, Math.min(4, j.outputs)) : undefined,@@ -353,7 +363,7 @@ function asRequest(j: JobInput): GenerationRequest {endTime: j.end_time,numLayers: j.num_layers,...(shots && { shots }),- ...(j.system && { extra: { system: j.system } }),+ ...(Object.keys(extra).length && { extra }),},};}diff --git a/src/server/canvas.ts b/src/server/canvas.tsindex a9dc3520..803ade25 100644--- a/src/server/canvas.ts+++ b/src/server/canvas.ts@@ -19,6 +19,7 @@ import {CANVAS_TEXT_MAX as TEXT_MAX,CONCAT_LIMITS,TABLE_LIMITS,+ LAYOUT_NODE_LIMITS,cleanGraph,concatClips,depIdentity,@@ -44,6 +45,7 @@ import {type StepSource,} from "@/lib/catalog/canvas";import type { Engine, Generation, GenerationRequest, MediaKind } from "@/lib/catalog/types";+import { readLayout } from "@/lib/layout-prompt";import { createPipeline } from "./chains";import { db } from "./db";import { listElements } from "./elements";@@ -103,6 +105,7 @@ const NODE_TYPES = ["translate","concat","table",+ "layout","output","note",] as const satisfies readonly CanvasNodeType[];@@ -131,6 +134,21 @@ const Handle = z.max(200).transform((h) => h.replace(/[^\p{L}\p{N}_-]/gu, "").slice(0, 60) || undefined);+/** A Layout node's draft: up to 64 boxes with their words clamped, fractions on the canvas (readLayout keeps the rest). */+const LayoutData = z+ .unknown()+ .transform((v) => readLayout(v) ?? undefined)+ .refine((d) => !d || d.items.length <= LAYOUT_NODE_LIMITS.boxes, `A layout holds up to ${LAYOUT_NODE_LIMITS.boxes} boxes`)+ .transform((d) =>+ d+ ? {+ ...d,+ summary: { ...d.summary, caption: d.summary.caption.slice(0, TEXT_MAX), meta: d.summary.meta.slice(0, 20).map((m) => m.slice(0, 80)) },+ items: d.items.map((it) => ({ ...it, caption: it.caption.slice(0, 2000), ...(it.text !== undefined && { text: it.text.slice(0, 2000) }) })),+ }+ : undefined,+ );+const NodeData = z.object({label: clamped(80).optional(),text: clamped(TEXT_MAX).optional(),@@ -169,6 +187,8 @@ const NodeData = z.object({rows: z.array(z.array(z.string().max(TABLE_LIMITS.cell)).max(TABLE_LIMITS.columns)).max(TABLE_LIMITS.rows * 2).optional(),// Translate (video) on the open engine: the dub it started in Translate & dub.dubId: z.string().max(40).optional(),+ // Layout: its boxes (read as a Fuobe draft, anything else dropped).+ layout: LayoutData.optional(),});const Num = z.number().finite();diff --git a/src/server/layout-plan.ts b/src/server/layout-plan.tsnew file mode 100644index 00000000..424e6a1a--- /dev/null+++ b/src/server/layout-plan.ts@@ -0,0 +1,26 @@+import "server-only";+import { LAYOUT_MULTIPLE, type LayoutDraft } from "@/lib/layout-prompt";+import { LAYOUT_PLAN_SYSTEM, planByRules, planRequest, readPlanned } from "@/lib/layout-plan";+import { llmText, llmTextBackend } from "./enhance";++/**+ * "Plan layout" (the Layout editor; N7-8): the sentence becomes a draft on the editor's canvas. The install's AI helper+ * (Claude when it is allowed, else a local model) writes it; an answer that doesn't read as a layout, or one that+ * validateLayout refuses, falls back to the rules, as does an install with no AI helper.+ */+export interface PlannedLayout {+ layout: LayoutDraft;+ /** Who planned it: the AI helper, or Fuobe's rules. */+ by: "llm" | "rules";+}++export async function planLayoutFromWords(words: string, width: number, height: number, ask: (system: string, user: string) => Promise<string | null> = (s, u) => llmText(s, u, { json: "object" })): Promise<PlannedLayout> {+ if (llmTextBackend()) {+ const planned = readPlanned(await ask(LAYOUT_PLAN_SYSTEM, planRequest(words, width, height)).catch(() => null), width, height);+ if (planned) return { layout: planned, by: "llm" };+ }+ return { layout: planByRules(words, width, height), by: "rules" };+}++/** A canvas side the planner takes: a multiple of 16 from 256 to 2048 px (else the 1024 default). */+export const planSide = (v: unknown): number => (typeof v === "number" && Number.isInteger(v) && v >= 256 && v <= 2048 && v % LAYOUT_MULTIPLE === 0 ? v : 1024);diff --git a/src/server/marketing.ts b/src/server/marketing.tsindex 904f68af..c2f998ae 100644--- a/src/server/marketing.ts+++ b/src/server/marketing.ts@@ -48,7 +48,9 @@ import {} from "@/lib/catalog/marketing";import { dualEngine } from "@/lib/catalog/engines";import { routesFor } from "@/lib/catalog/plan";-import { themeFrom } from "@/components/ads/layout";+import { themeFrom, type AdLayout } from "@/components/ads/layout";+import { adDraft } from "@/lib/layout-surfaces";+import { LAYOUT_PARAM } from "@/lib/layout-prompt";import type { ChainSlot, Engine, GenerationRequest, ModelDef, Operation } from "@/lib/catalog/types";import { getBrand, getProduct } from "./brand";import { createPipeline, type PipelineStep } from "./chains";@@ -99,6 +101,8 @@ export const MarketingBody = z.object({voiceSample: FILE.optional(),script: z.string().max(2000).optional(),website: z.string().max(300).optional(),+ /** "Words drawn by the model" (formats with words): the headline and button drawn in place from a layout. */+ drawnWords: z.boolean().optional(),});export type MarketingInput = z.infer<typeof MarketingBody>;@@ -304,7 +308,9 @@ export function planMarketing(input: MarketingInput, ctx: PlanContext): RunPlan}}// Models switched off in Settings → Models & licences aren't picked while another choice is on.- const listed = formatModels(f, input.engine, { product: hasProduct, avatar: !!input.avatar });+ // "Words drawn by the model": only where the format has words, on a picture.+ const drawn = !!input.drawnWords && !!f.text && f.pipeline === "image";+ const listed = formatModels(f, input.engine, { product: hasProduct, avatar: !!input.avatar }, drawn);// A choice listed only to say it runs on your GPU (the Original's Standalone shot in the cloud) is refused in its words.const elsewhere = listed.find((c) => c.unavailable && c.id === input.modelId);if (elsewhere) throw new PlanError(`${need(elsewhere.id).name} makes ${f.name} shots on your GPU only (${elsewhere.unavailable}): switch to your GPU, or pick another model`);@@ -319,13 +325,13 @@ export function planMarketing(input: MarketingInput, ctx: PlanContext): RunPlanif (f.pipeline === "image") {const modelId = input.modelId && choices.some((c) => c.id === input.modelId) ? input.modelId : choices[0].id;const model = need(modelId);- const onTop = wordsOnTop(input.engine, modelId);+ const onTop = wordsOnTop(input.engine, modelId, drawn);const refs = [...(f.product !== "none" ? productImages.slice(0, 1) : []),...(input.avatar && f.avatar !== "none" ? [input.avatar] : []),...(input.reference ? [input.reference] : []),// The logo as a reference lets a partner model draw it; otherwise it is set on top in the browser.- ...(!onTop && f.text && brand?.logo && !isSvg(brand.logo) ? [brand.logo] : []),+ ...(!onTop && !drawn && f.text && brand?.logo && !isSvg(brand.logo) ? [brand.logo] : []),];const max = model.options.maxImages ?? (supportsOp(model, "edit") ? 1 : 0);let images = refs.slice(0, Math.max(0, max));@@ -355,7 +361,8 @@ export function planMarketing(input: MarketingInput, ctx: PlanContext): RunPlanhasProduct && op === "edit" && KEEP_PRODUCT,input.reference && "Use the last reference photo for the setting and light",prompt,- textLine(f, onTop, headline, cta, brand),+ // Drawn words come from the layout's text boxes, in their places.+ !drawn && textLine(f, onTop, headline, cta, brand),brandText,);// bria-product-shot and Product Photography take the scene alone.@@ -365,6 +372,23 @@ export function planMarketing(input: MarketingInput, ctx: PlanContext): RunPlanmeta.overlay = onTop && f.text && (headline || cta) ? { headline: headline || undefined, cta: cta || undefined } : null;// Words set in the browser go on one picture per run: a batch is that many runs (runsFor), each composed.const batch = meta.overlay ? 1 : Math.min(input.batch ?? 1, f.batch);+ // The copy's places as the browser would set them (frame for posters, overlay for the rest), drawn by the model.+ const layout =+ drawn && (headline || cta)+ ? adDraft({+ ratio: aspect ?? f.defaultAspect,+ layout: overlayLayout(f.id) as AdLayout,+ content: { headline, cta: cta || undefined },+ brand,+ mode: "words",+ product: product ? `${product.name}${product.description ? `, ${product.description.replace(/\s+/g, " ").trim().slice(0, 160)}` : ""}` : scene || prompt || "The subject of the picture",+ caption: "",+ meta: [f.id === "poster" ? "poster" : "advertising", "graphic design"],+ })+ : undefined;+ if (drawn && !layout) notes.push("Add a headline or a button to have them drawn in place");+ if (layout) notes.push(`${model.name} draws your headline and button in their places, so the lettering is the model's, not your brand fonts`);+ if (layout && hasProduct && op === "t2i") notes.push(`${model.name} draws your product from its name and description, not from your photo`);if (onTop && f.text) notes.push("Your headline is set over the picture in your brand fonts, so the words come out exact");// On the user's GPU a Standalone shot of one product photo is cut out and relit into the scene (White_to_Scene).const productShot = open && modelId === MARKETING_IMAGE_MODEL && f.id === "product-standalone" && op === "edit" && images.length === 1;@@ -386,7 +410,7 @@ export function planMarketing(input: MarketingInput, ctx: PlanContext): RunPlanop,prompt: model.options.promptless ? undefined : scenePrompt.slice(0, MAX_PROMPT),inputs: images.length ? { images } : undefined,- params: { aspectRatio: aspect, numOutputs: batch, ...(palette && { palette }), ...(productShot && { extra: { productShot: true } }) },+ params: { aspectRatio: aspect, numOutputs: batch, ...(palette && { palette }), ...((productShot || layout) && { extra: { ...(productShot && { productShot: true }), ...(layout && { [LAYOUT_PARAM]: layout }) } }) },title,batchTitle: title,},diff --git a/tests/assist-skills.test.ts b/tests/assist-skills.test.tsindex f4e631de..8ccafcd3 100644--- a/tests/assist-skills.test.ts+++ b/tests/assist-skills.test.ts@@ -254,11 +254,11 @@ describe("context updates", () => {});describe("skills on the server", () => {- it("loads every built-in from skills/: 20, valid, unique, each with when-to-use and an icon", () => {+ it("loads every built-in from skills/: 21, valid, unique, each with when-to-use and an icon", () => {const list = skills.listSkills();const builtin = list.filter((s) => s.source === "builtin");- expect(builtin).toHaveLength(20);- expect(new Set(builtin.map((s) => s.name)).size).toBe(20);+ expect(builtin).toHaveLength(21);+ expect(new Set(builtin.map((s) => s.name)).size).toBe(21);for (const s of builtin) {expect(s.whenToUse, s.name).not.toBe("");expect(s.icon, s.name).toBeTruthy();diff --git a/tests/originals-marketing.test.ts b/tests/originals-marketing.test.tsindex f58bc25d..c114ca30 100644--- a/tests/originals-marketing.test.ts+++ b/tests/originals-marketing.test.ts@@ -84,7 +84,7 @@ describe("Fuobe Marketing Image", () => {expect(pickable(formatModels(FORMATS["product-standalone"], "open", { product: true, avatar: false })).map((c) => c.id)).toEqual([MARKETING_IMAGE_MODEL]);expect(getModel(MARKETING_IMAGE_MODEL)?.engineNote).toMatch(/runs on your GPU only .*relit into the scene.*offers partner models instead/);expect(formatModels(FORMATS["product-standalone"], "open", { product: true, avatar: false })[0].note).toBe("Fuobe Original · Qwen-Image 2.1 on your GPU");- expect(AD_VISUAL_MODELS.cloud.map((c) => c.id)).toEqual([MARKETING_IMAGE_MODEL, "nano-banana-pro", "gpt-image-2-5"]);+ expect(AD_VISUAL_MODELS.cloud.map((c) => c.id)).toEqual([MARKETING_IMAGE_MODEL, "nano-banana-pro", "gpt-image-2-5", "flux-3"]);expect(adVisualModel("open", "nano-banana-pro")).toBe(MARKETING_IMAGE_MODEL);expect(adVisualModel("cloud", "gpt-image-2-5")).toBe("gpt-image-2-5");// Its words are set over the picture on both engines; a partner draws them.diff --git a/tests/skills-spec.test.ts b/tests/skills-spec.test.tsindex 8d4c3030..0680cb0f 100644--- a/tests/skills-spec.test.ts+++ b/tests/skills-spec.test.ts@@ -59,8 +59,8 @@ function frontmatter(text: string) {}describe("skills follow the Agent Skills spec", () => {- it("finds the 20 built-in skills and the agent skill", () => {- expect(skillFiles).toHaveLength(21);+ it("finds the 21 built-in skills and the agent skill", () => {+ expect(skillFiles).toHaveLength(22);});for (const file of skillFiles) {