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
Originals O5: Character swap clicks take the clicked person, the first frame keeps the clip's shape, Describe my character
Claude431514c707e4
diff --git a/scripts/comfy/README.md b/scripts/comfy/README.mdindex 70bbddda..d1d4fba1 100644--- a/scripts/comfy/README.md+++ b/scripts/comfy/README.md@@ -311,6 +311,11 @@ node validate-workflows.mjs video-character-swap-h3 video-character-swap-h3-rela- **Licences, as information**: MiniMax H3 Community License (territory excludes the US, the EU, the UK and South Korea;over US$20M yearly revenue needs MiniMax's written authorization; show "MiniMax H3"), Meta's SAM License, Apache-2.0(Turbo LoRA), GPL-3.0 (both packs). The admin decides what runs (Settings → Models & licences).+- **Clicks**: the provider moves them into the frame the pack prepares (its `canvas_dimensions`: a 0.5 / 1.0 MP budget+ on the 32-pixel grid, the clip scaled to cover and the middle cropped) and sets SelectSubject to `index` 0, since+ `SAM3_Detect` returns the clicked mask first and the "person" detections after it. Person numbers (`index`) are SAM's+ detections in order of confidence, not left to right. A window and history the pack's `validate_settings` would+ refuse (history ≥ window) is brought below the window.- **GPU**: tested by their authors on a 96 GB RTX PRO 6000 and on a 24 GB RTX 4090 with 128 GB RAM and offloading.- **Comfy Developer Platform** (what Openjutsu deploys to): a deployment is not a plain ComfyUI server — it is driven bythe v2 API (`@comfyorg/sdk`: upload, job, poll), not `/prompt` and `/history` — so Fuobe does not add a provider for it.diff --git a/scripts/comfy/install-comfyui.sh b/scripts/comfy/install-comfyui.shindex 5c99666d..f2ed4947 100755--- a/scripts/comfy/install-comfyui.sh+++ b/scripts/comfy/install-comfyui.sh@@ -67,10 +67,15 @@ doneH3_TOOL_REF="${H3_TOOL_REF:-0670e4fdf95adf2262caa4b81afed2a9c4ae4b7b}"if [ "${H3_PACK:-1}" = "1" ] && [ ! -d "$COMFYUI_DIR/custom_nodes/h3_character_swap" ]; thenh3tmp="$(mktemp -d)"- git clone -q --filter=blob:none --no-checkout https://github.com/akatz-labs/h3-character-swap-tool "$h3tmp/tool"- git -C "$h3tmp/tool" sparse-checkout set --no-cone /worker_nodes/h3_character_swap/- git -C "$h3tmp/tool" checkout -q "$H3_TOOL_REF" && cp -r "$h3tmp/tool/worker_nodes/h3_character_swap" "$COMFYUI_DIR/custom_nodes/h3_character_swap" \- || echo "warn: could not fetch h3_character_swap at $H3_TOOL_REF"+ # Each step is guarded (set -e): a failed fetch warns and the rest of the install goes on.+ if git clone -q --filter=blob:none --no-checkout https://github.com/akatz-labs/h3-character-swap-tool "$h3tmp/tool" \+ && git -C "$h3tmp/tool" sparse-checkout set --no-cone /worker_nodes/h3_character_swap/ \+ && git -C "$h3tmp/tool" checkout -q "$H3_TOOL_REF" \+ && cp -r "$h3tmp/tool/worker_nodes/h3_character_swap" "$COMFYUI_DIR/custom_nodes/h3_character_swap"; then+ :+ else+ echo "warn: could not fetch h3_character_swap at $H3_TOOL_REF"+ firm -rf "$h3tmp"fiif [ "${H3_PACK:-1}" = "1" ] && { ! command -v ffmpeg >/dev/null || ! command -v ffprobe >/dev/null; }; then@@ -82,9 +87,12 @@ fiH3_RELAY_REF="${H3_RELAY_REF:-e2a7665b6eb8ea37a88c0de2c9c6b69a8f7c9220}" # 2.0.1, 2026-10-21if [ "${H3_RELAY:-0}" = "1" ]; thendest="$COMFYUI_DIR/custom_nodes/h3-relay"- [ -d "$dest/.git" ] || git clone -q https://github.com/akatz-ai/h3-relay "$dest"- git -C "$dest" fetch -q --depth 1 origin "$H3_RELAY_REF" 2>/dev/null || true- git -C "$dest" checkout -q "$H3_RELAY_REF" 2>/dev/null || echo "warn: could not pin h3-relay to $H3_RELAY_REF"+ if [ -d "$dest/.git" ] || git clone -q https://github.com/akatz-ai/h3-relay "$dest"; then+ git -C "$dest" fetch -q --depth 1 origin "$H3_RELAY_REF" 2>/dev/null || true+ git -C "$dest" checkout -q "$H3_RELAY_REF" 2>/dev/null || echo "warn: could not pin h3-relay to $H3_RELAY_REF"+ else+ echo "warn: could not fetch h3-relay"+ fifi# Union of the packs' requirements, minus GPU-only / unbuildable extrasdiff --git a/scripts/comfy/library.spec.mjs b/scripts/comfy/library.spec.mjsindex 0cf5bc3f..2e6f86d3 100644--- a/scripts/comfy/library.spec.mjs+++ b/scripts/comfy/library.spec.mjs@@ -132,7 +132,7 @@ export const CUSTOM_NODE_REPOS = {// Genjutsu's Character swap (docs/research/openjutsu-6.md): Akatz Labs' H3 nodes, GPL-3.0. Not installed on the// validation server (entries list them with `packs`); install-comfyui.sh pins both.h3_character_swap: 'https://github.com/akatz-labs/h3-character-swap-tool/tree/0670e4fdf95adf2262caa4b81afed2a9c4ae4b7b/worker_nodes/h3_character_swap',- 'h3-relay': 'https://github.com/akatz-ai/h3-relay',+ 'h3-relay': 'https://github.com/akatz-ai/h3-relay/tree/e2a7665b6eb8ea37a88c0de2c9c6b69a8f7c9220',};// Node classes of the packs entries list in `packs` (packs the validation server doesn't have installed): the builddiff --git a/src/app/api/genjutsu/describe/route.ts b/src/app/api/genjutsu/describe/route.tsnew file mode 100644index 00000000..9586b694--- /dev/null+++ b/src/app/api/genjutsu/describe/route.ts@@ -0,0 +1,10 @@+import { describeCharacter, DescribeSchema } from "@/server/genjutsu";+import { body, handle } from "@/server/shorts-schemas";++/** "Describe my character": the engine's text model writes what the character looks like from their picture. */+export async function POST(request: Request) {+ return handle(async () => {+ const input = await body(request, DescribeSchema, "Add a picture of your character first");+ return Response.json(await describeCharacter(input));+ });+}diff --git a/src/app/api/genjutsu/transcribe/route.ts b/src/app/api/genjutsu/transcribe/route.tsnew file mode 100644index 00000000..544b963e--- /dev/null+++ b/src/app/api/genjutsu/transcribe/route.ts@@ -0,0 +1,10 @@+import { transcribeClip, TranscribeSchema } from "@/server/genjutsu";+import { body, handle } from "@/server/shorts-schemas";++/** The clip's words for Character swap's "What's said": one transcription the page picks the part's lines from. */+export async function POST(request: Request) {+ return handle(async () => {+ const input = await body(request, TranscribeSchema, "Add a clip first");+ return Response.json(transcribeClip(input), { status: 201 });+ });+}diff --git a/src/components/genjutsu/character-panel.tsx b/src/components/genjutsu/character-panel.tsxindex 17f39fc7..1844a441 100644--- a/src/components/genjutsu/character-panel.tsx+++ b/src/components/genjutsu/character-panel.tsx@@ -1,6 +1,7 @@"use client";-import { Cpu, Scale, TriangleAlert } from "lucide-react";+import { AudioLines, Cpu, Loader2, Scale, Sparkles, TriangleAlert } from "lucide-react";+import { Button } from "@/components/ui/button";import { Input } from "@/components/ui/input";import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";import { Switch } from "@/components/ui/switch";@@ -12,9 +13,10 @@ import {CHARACTER_GPU,CHARACTER_LIMITS,CHARACTER_SWAP,- HISTORY_CHOICES,+ historyChoicesFor,SPEECH_LABELS,SWAP_LORAS,+ WHO_INDEX_LABEL,WHO_LABELS,WINDOW_CHOICES,type CharacterOptions,@@ -26,10 +28,19 @@ import {import type { GenjutsuTarget, Maker } from "@/lib/catalog/genjutsu";import type { Engine } from "@/lib/catalog/types";+/** A helper the panel offers (Describe my character, the clip's words): its action, whether it's running or can run. */+export interface PanelHelper {+ run: () => void;+ busy: boolean;+ /** Why it can't run yet (it is disabled with this as its hint). */+ blocked?: string | null;+}+/*** Character swap's own settings (Openjutsu's and Akatz Labs' H3 Character Swap tool's, on Genjutsu): who to swap,- * the quality, the first frame made first, what the character looks like, the seed, and under Advanced the speech,- * the swap LoRA's release and the H3 settings of the open graph. The limits and the GPU line sit under it.+ * the quality, the first frame made first, what the character looks like (or Describe it from the picture), the seed,+ * and under Advanced the speech (or the clip's own words), the swap LoRA's release and the H3 settings of the open+ * graph. The limits and the GPU line sit under it.*/export function CharacterControls({engine,@@ -42,6 +53,8 @@ export function CharacterControls({seed,onSeed,seedProblem,+ describe,+ words,}: {engine: Engine;maker: Maker | null;@@ -53,12 +66,24 @@ export function CharacterControls({seed: string;onSeed: (s: string) => void;seedProblem?: string | null;+ /** "Describe my character" from the character picture (the engine's text model). */+ describe?: PanelHelper;+ /** "Use the clip's words": the part's lines from a transcription of the clip. */+ words?: PanelHelper;}) {const set = (patch: Partial<CharacterOptions>) => onChange({ ...value, ...patch });const h3 = !!maker?.h3;const open = engine === "open";const anchors = ANCHOR_MODELS[engine];const who: SwapWho = value.who ?? "largest";+ const window = value.windowFrames ?? CHARACTER_SWAP.window;+ const histories = historyChoicesFor(window);+ // fal's H3 route needs a swap LoRA: "None" is a GPU choice.+ const loraChoices = [+ { value: "v1.5" as const, label: "V1.5", title: SWAP_LORAS["v1.5"].label },+ { value: "v1" as const, label: "V1", title: SWAP_LORAS.v1.label },+ ...(open ? [{ value: "none" as const, label: "None", title: "MiniMax H3 with the Turbo LoRA only" }] : []),+ ];return (<div className="space-y-4">{target === "type" && (@@ -70,9 +95,9 @@ export function CharacterControls({options={(Object.keys(WHO_LABELS) as SwapWho[]).map((w) => ({ value: w, label: WHO_LABELS[w] }))}/>{who === "index" && (- <div className="flex items-center gap-2 pt-1">- <label htmlFor="gj-person" className="text-[12px] text-muted-foreground">- Person number, from the left+ <div className="flex flex-wrap items-center gap-2 pt-1">+ <label htmlFor="gj-person" className="text-[12px] text-muted-foreground" title={WHO_INDEX_LABEL[engine].hint}>+ {WHO_INDEX_LABEL[engine].label}</label><Inputid="gj-person"@@ -84,6 +109,7 @@ export function CharacterControls({onChange={(e) => set({ index: Math.max(0, Math.min(CHARACTER_SWAP.maxPeople - 1, Math.round(Number(e.target.value) || 1) - 1)) })}className="h-8 w-20 text-[13px]"/>+ {open && <p className="w-full text-[12px] leading-snug text-muted-foreground">{WHO_INDEX_LABEL.open.hint}.</p>}</div>)}</Field>@@ -130,15 +156,22 @@ export function CharacterControls({</div>)}- <Field label="What your character looks like (optional)" htmlFor="gj-description">- <Input- id="gj-description"- value={value.description ?? ""}- onChange={(e) => set({ description: e.target.value || undefined })}- maxLength={CHARACTER_SWAP.maxDescriptionChars}- placeholder="e.g. “a young woman with short silver hair and a green raincoat”"- className="text-[13px]"- />+ <Field label="What your character looks like (optional)" htmlFor="gj-description" hint={describe?.blocked ?? undefined}>+ <div className="flex flex-col items-start gap-1.5">+ <Input+ id="gj-description"+ value={value.description ?? ""}+ onChange={(e) => set({ description: e.target.value || undefined })}+ maxLength={CHARACTER_SWAP.maxDescriptionChars}+ placeholder="e.g. “a young woman with short silver hair and a green raincoat”"+ className="text-[13px]"+ />+ {describe && (+ <Button type="button" size="sm" variant="outline" className="rounded-full" disabled={describe.busy || !!describe.blocked} onClick={describe.run}>+ {describe.busy ? <Loader2 className="size-3.5 animate-spin" /> : <Sparkles className="size-3.5" />} Describe my character+ </Button>+ )}+ </div></Field><Field label="Seed (optional)" htmlFor="gj-seed" hint={seedProblem ?? "Blank is random"}>@@ -166,7 +199,7 @@ export function CharacterControls({</Select></Field>{value.speech !== "none" && (- <Field label="What's said (optional)" htmlFor="gj-dialogue">+ <Field label="What's said (optional)" htmlFor="gj-dialogue" hint={words?.blocked ?? undefined}><Textareaid="gj-dialogue"value={value.dialogue ?? ""}@@ -176,19 +209,15 @@ export function CharacterControls({placeholder="The words in the part, so the lips follow them"className="resize-none text-[13px]"/>+ {words && (+ <Button type="button" size="sm" variant="outline" className="mt-1.5 rounded-full" disabled={words.busy || !!words.blocked} onClick={words.run}>+ {words.busy ? <Loader2 className="size-3.5 animate-spin" /> : <AudioLines className="size-3.5" />} {words.busy ? "Listening to the clip…" : "Use the clip's words"}+ </Button>+ )}</Field>)}- <Field label="Swap LoRA" hint="Akatz Labs' Character Swap LoRA">- <Segmented- label="Swap LoRA"- value={value.lora ?? "v1.5"}- onChange={(l: SwapLora) => set({ lora: l === "v1.5" ? undefined : l })}- options={[- { value: "v1.5" as const, label: "V1.5", title: SWAP_LORAS["v1.5"].label },- { value: "v1" as const, label: "V1", title: SWAP_LORAS.v1.label },- { value: "none" as const, label: "None", title: "MiniMax H3 with the Turbo LoRA only" },- ]}- />+ <Field label="Swap LoRA" hint={open ? "Akatz Labs' Character Swap LoRA" : "Akatz Labs' Character Swap LoRA (fal's route needs one)"}>+ <Segmented label="Swap LoRA" value={value.lora ?? "v1.5"} onChange={(l: SwapLora) => set({ lora: l === "v1.5" ? undefined : l })} options={loraChoices} /></Field>{open && (<>@@ -198,12 +227,14 @@ export function CharacterControls({</span><Switch checked={value.audioGuide !== false} onCheckedChange={(on) => set({ audioGuide: on ? undefined : false })} aria-label="Audio guide" /></label>- <label className="flex items-center justify-between gap-3 text-[13px]">- <span>- Masked generation <span className="text-[12px] text-muted-foreground">· only the person is remade</span>- </span>- <Switch checked={value.useMask !== false} onCheckedChange={(on) => set({ useMask: on ? undefined : false })} aria-label="Masked generation" />- </label>+ {maker?.h3?.maskSwitch && (+ <label className="flex items-center justify-between gap-3 text-[13px]">+ <span>+ Masked generation <span className="text-[12px] text-muted-foreground">· only the person is remade</span>+ </span>+ <Switch checked={value.useMask !== false} onCheckedChange={(on) => set({ useMask: on ? undefined : false })} aria-label="Masked generation" />+ </label>+ )}<Field label="Mask margin" htmlFor="gj-grow" hint="Pixels around the person"><Inputid="gj-grow"@@ -217,8 +248,19 @@ export function CharacterControls({/></Field><div className="grid grid-cols-2 gap-2">- <FrameSelect id="gj-window" label="Window" value={value.windowFrames ?? CHARACTER_SWAP.window} choices={WINDOW_CHOICES} onChange={(n) => set({ windowFrames: n === CHARACTER_SWAP.window ? undefined : n })} />- <FrameSelect id="gj-history" label="History" value={value.historyFrames ?? CHARACTER_SWAP.history} choices={HISTORY_CHOICES} onChange={(n) => set({ historyFrames: n === CHARACTER_SWAP.history ? undefined : n })} />+ <FrameSelect+ id="gj-window"+ label="Window"+ value={window}+ choices={WINDOW_CHOICES}+ onChange={(n) => {+ // The pack refuses a history as long as the window: it comes down with it.+ const h = value.historyFrames ?? CHARACTER_SWAP.history;+ const fit = h < n ? h : Math.max(...historyChoicesFor(n));+ set({ windowFrames: n === CHARACTER_SWAP.window ? undefined : n, historyFrames: fit === CHARACTER_SWAP.history ? undefined : fit });+ }}+ />+ <FrameSelect id="gj-history" label="History" value={value.historyFrames ?? CHARACTER_SWAP.history} choices={histories} onChange={(n) => set({ historyFrames: n === CHARACTER_SWAP.history ? undefined : n })} /></div></>)}diff --git a/src/components/genjutsu/genjutsu-studio.tsx b/src/components/genjutsu/genjutsu-studio.tsxindex c576cd20..8a032bbb 100644--- a/src/components/genjutsu/genjutsu-studio.tsx+++ b/src/components/genjutsu/genjutsu-studio.tsx@@ -23,7 +23,7 @@ import { radioKeys, radioTab } from "@/components/studio/radio-keys";import { SketchEditor, type Stroke } from "@/components/studio/sketch-editor";import { VideoTrimmer, type TrimRange, type VideoTrimmerHandle } from "@/components/studio/video-trimmer";import { useEngine, useGenerations, useModelAccess } from "@/lib/api";-import { CHARACTER_SWAP, cutsInPart, cutWarning, seedProblem, type CharacterOptions, type CharacterQuality } from "@/lib/catalog/character-swap";+import { CHARACTER_SWAP, cutsInPart, cutWarning, partWords, seedProblem, type CharacterOptions, type CharacterQuality } from "@/lib/catalog/character-swap";import {chooseMaker,decodeSetup,@@ -32,6 +32,7 @@ import {genjutsuProblem,getMode,makerLicence,+ makerOffered,makersFor,MODE_TARGETS,OPEN_TARGET_PROBLEM,@@ -47,12 +48,12 @@ import {type Maker,} from "@/lib/catalog/genjutsu";import { chainState } from "@/lib/catalog/shorts";-import type { PixelPoint } from "@/lib/catalog/types";+import type { Generation, PixelPoint } from "@/lib/catalog/types";import { downloadHref, downloadName } from "@/lib/library";import { keepOffered, offered } from "@/lib/model-access";import { cn } from "@/lib/utils";import { CharacterControls, CharacterFacts } from "./character-panel";-import { useGenjutsuEstimate, useGenjutsuRun, type GenjutsuBody } from "./hooks";+import { useDescribeCharacter, useGenjutsuEstimate, useGenjutsuRun, useTranscribeClip, waitForGeneration, type GenjutsuBody } from "./hooks";import { LookPicker, type LookSource } from "./look-picker";import { SetupCode } from "./setup-code";import { useClipCuts } from "./use-cuts";@@ -165,7 +166,7 @@ export function GenjutsuStudio() {const isOn = (id: string) => offered(access, id, engine);const choice = chooseMaker({ engine, mode, target, tier, look: effLook ?? (mode === "restyle" ? lookPlaceholder(lookSource) : undefined), modelId: picked[choiceKey], offered: isOn });const maker: Maker | null = "maker" in choice ? choice.maker : null;- const options = keepOffered(makersFor(engine, mode, target), (m) => isOn(m.id));+ const options = keepOffered(makersFor(engine, mode, target), (m) => makerOffered(m, isOn));const references = mode === "restyle" ? [] : ready(refs);const showRefs = mode !== "restyle";const maxRefs = isCharacter ? Math.max(1, maker?.refs.max ?? 1) : GENJUTSU.maxReferences;@@ -175,6 +176,51 @@ export function GenjutsuStudio() {const partCuts = isCharacter && range ? cutsInPart(cuts ?? undefined, { start: range.startTime, end: range.endTime }) : [];const cut = cutWarning(partCuts);const seedNumber = seedOf(seed);+ // Character swap's H3 makers take H3's two qualities; the other makers (Recast, P-Video…) Genjutsu's own.+ const askedQuality = isCharacter && maker?.h3 ? charQuality : quality;++ // "Describe my character" (the engine's text model) and "Use the clip's words" (one transcription of the clip; any+ // part takes its own lines from it, so it is kept per clip).+ const describeMutation = useDescribeCharacter();+ const transcribeMutation = useTranscribeClip();+ const [clipWords, setClipWords] = useState<{ url: string; g: Generation } | null>(null);+ const [listening, setListening] = useState(false);+ const alive = useRef<AbortController | null>(null);+ useEffect(() => () => alive.current?.abort(), []);+ const describeCharacter = () => {+ const image = refs.find((r) => !r.uploading)?.ref;+ if (!image) return;+ describeMutation+ .mutateAsync({ engine, image })+ .then((r) => setCharacter((c) => ({ ...c, description: r.description })))+ .catch((e: Error) => toast.error(friendly(e.message)));+ };+ const fillClipWords = async () => {+ if (!clip?.url || !range) return;+ const url = clip.url;+ const part = { start: range.startTime, end: range.endTime };+ setListening(true);+ alive.current?.abort();+ const ctl = new AbortController();+ alive.current = ctl;+ try {+ let g = clipWords?.url === url ? clipWords.g : null;+ if (!g) {+ const { id } = await transcribeMutation.mutateAsync({ engine, source: { url, ...(duration ? { duration } : {}) } });+ g = await waitForGeneration(id, { signal: ctl.signal });+ setClipWords({ url, g });+ }+ const out = g.outputs.find((o) => o.kind === "text");+ const cues = Array.isArray(out?.meta?.cues) ? (out.meta.cues as { start: number; end: number; text: string }[]) : undefined;+ const text = cues ? partWords(cues, part) : (out?.text ?? "").trim().slice(0, 2000);+ if (text) setCharacter((c) => ({ ...c, dialogue: text }));+ else toast("Nobody speaks in this part of the clip", { description: "Pick “No dialogue”, or type the words." });+ } catch (e) {+ if (!ctl.signal.aborted) toast.error(friendly((e as Error).message));+ } finally {+ if (alive.current === ctl) setListening(false);+ }+ };// The selection's first frame, grabbed by the browser: what points and paint are made on.const startAt = range ? Math.round(range.startTime * 100) / 100 : null;@@ -218,6 +264,7 @@ export function GenjutsuStudio() {if (s.tier) setTier(s.tier);if (s.mode === "character") {if (s.quality === "480p" || s.quality === "768p") setCharQuality(s.quality);+ if (s.quality && (GENJUTSU.qualities as string[]).includes(s.quality)) setQuality(s.quality);setCharacter(s.character ?? {});} else if (s.quality) setQuality(s.quality);const t = s.target ?? MODE_TARGETS[s.mode][0];@@ -286,7 +333,7 @@ export function GenjutsuStudio() {engine,...(maker ? { model: maker.id } : {}),...(maker?.tier ? { tier: maker.tier } : {}),- quality: isCharacter ? charQuality : quality,+ quality: askedQuality,...(target ? { target } : {}),...(mode === "swap" && subject.trim() ? { subject: subject.trim() } : {}),...(prompt.trim() ? { prompt: prompt.trim() } : {}),@@ -330,7 +377,7 @@ export function GenjutsuStudio() {points: clicks,mask: !!paint,look: effLook,- ...(isCharacter ? { seed: seedNumber } : {}),+ ...(isCharacter ? { seed: seedNumber, character } : {}),}): null;const body: GenjutsuBody | null =@@ -340,7 +387,7 @@ export function GenjutsuStudio() {mode,modelId: maker.id,...(maker.tier ? { tier: maker.tier } : {}),- quality: isCharacter ? charQuality : quality,+ quality: askedQuality,...(target ? { target } : {}),...(mode === "swap" && subject.trim() ? { subject: subject.trim() } : {}),...(prompt.trim() ? { prompt: prompt.trim() } : {}),@@ -596,6 +643,8 @@ export function GenjutsuStudio() {seed={seed}onSeed={setSeed}seedProblem={seedProblem(seedNumber)}+ describe={{ run: describeCharacter, busy: describeMutation.isPending, blocked: refs.some((r) => !r.uploading) ? null : "Add your character's picture to describe it" }}+ words={{ run: () => void fillClipWords(), busy: listening, blocked: clip?.url && !clip.uploading && range ? null : "Add the clip first" }}/>)}@@ -640,12 +689,8 @@ export function GenjutsuStudio() {)}{(!isCharacter || !maker?.h3) && (- <Field label="Resolution" hint={maker ? upFirst(resolutionWords(maker, isCharacter ? charQuality : quality)) : undefined}>- {isCharacter ? (- <Segmented label="Resolution" value={charQuality} onChange={setCharQuality} options={CHARACTER_SWAP.qualities.map((q) => ({ value: q, label: q }))} />- ) : (- <Segmented label="Resolution" value={quality} onChange={setQuality} options={GENJUTSU.qualities.map((q) => ({ value: q, label: q }))} />- )}+ <Field label="Resolution" hint={maker ? upFirst(resolutionWords(maker, quality)) : undefined}>+ <Segmented label="Resolution" value={quality} onChange={setQuality} options={GENJUTSU.qualities.map((q) => ({ value: q, label: q }))} /></Field>)}diff --git a/src/components/genjutsu/hooks.ts b/src/components/genjutsu/hooks.tsindex 9688f767..f373f4be 100644--- a/src/components/genjutsu/hooks.ts+++ b/src/components/genjutsu/hooks.ts@@ -76,3 +76,28 @@ export function useGenjutsuRun() {},});}++/** "Describe my character": the engine's text model writes the description from the character picture. */+export function useDescribeCharacter() {+ return useMutation({ mutationFn: (b: { engine: Engine; image: string }) => send<{ description: string }>("/api/genjutsu/describe", "POST", b) });+}++/** The clip's words (one transcription; the page takes the part's lines from its cues). */+export function useTranscribeClip() {+ return useMutation({ mutationFn: (b: { engine: Engine; source: { url: string; duration?: number } }) => send<{ id: string; modelId: string }>("/api/genjutsu/transcribe", "POST", b) });+}++/** Waits for one generation to finish (polling; the page's helpers that fill a field from it). */+export async function waitForGeneration(id: string, o: { signal?: AbortSignal; timeoutMs?: number } = {}): Promise<Generation> {+ const deadline = Date.now() + (o.timeoutMs ?? 15 * 60_000);+ while (Date.now() < deadline) {+ if (o.signal?.aborted) throw new Error("Stopped");+ const res = await fetch(`/api/generations/${id}`, { signal: o.signal });+ if (!res.ok) throw new Error(res.status === 404 ? "That job is gone" : `Request failed (${res.status})`);+ const g = (await res.json()) as Generation;+ if (g.status === "succeeded") return g;+ if (g.status === "failed" || g.status === "canceled") throw new Error(g.error || "It didn't finish");+ await new Promise((r) => setTimeout(r, 1500));+ }+ throw new Error("It is taking too long — try again later");+}diff --git a/src/components/model-access-view.tsx b/src/components/model-access-view.tsxindex bcce1718..2162d390 100644--- a/src/components/model-access-view.tsx+++ b/src/components/model-access-view.tsx@@ -123,7 +123,7 @@ function LoraRow({ l, on, onChange }: { l: LoraInfo; on: boolean; onChange: (on:{l.name}</label><p className="text-[12px] text-muted-foreground [overflow-wrap:anywhere]">- {l.group === "look" ? "Look" : l.group === "motion" ? "Camera motion" : "Effect"} · {l.base}+ {l.group === "look" ? "Look" : l.group === "motion" ? "Camera motion" : l.group === "adapter" ? "Model adapter" : "Effect"} · {l.base}</p><LicenceLine licence={l.licence} /></div>diff --git a/src/lib/catalog/character-swap.ts b/src/lib/catalog/character-swap.tsindex 45c1153c..9bbbdae3 100644--- a/src/lib/catalog/character-swap.ts+++ b/src/lib/catalog/character-swap.ts@@ -47,6 +47,14 @@ export type SwapSpeech = "character" | "other" | "offscreen" | "none";export type SwapLora = "v1.5" | "v1" | "none";export const WHO_LABELS: Record<SwapWho, string> = { largest: "Largest", leftmost: "Leftmost", rightmost: "Rightmost", index: "Person #" };+/**+ * What "Person #n" counts, per engine: fal's prompt names the nth person from the left; the open graph's SelectSubject+ * takes SAM 3.1's nth detection, and SAM orders its detections by confidence (the surest first), not by position.+ */+export const WHO_INDEX_LABEL: Record<Engine, { label: string; hint: string }> = {+ cloud: { label: "Person number, from the left", hint: "Said in the prompt" },+ open: { label: "Detection number", hint: "In SAM 3.1's order: the person it is surest of first, not left to right — for a position, pick Leftmost or Rightmost, or click them" },+};export const SPEECH_LABELS: Record<SwapSpeech, { label: string; hint: string }> = {character: { label: "My character speaks", hint: "Lips follow the clip's own voice" },other: { label: "Someone else speaks", hint: "The character listens" },@@ -72,12 +80,19 @@ export const SWAP_LORAS: Record<Exclude<SwapLora, "none">, { label: string; fileconst H3_LORA_LICENCE = { commercial: true, hostedOk: true, snapshotDate: "2026-10-27", name: "MiniMax H3 Community License" };-/** The swap LoRA a run carries (fal loads it by its pinned Hugging Face URL; ComfyUI gets the file downloaded). */-export function swapLoraRef(lora: SwapLora | undefined): LoraRef {+/**+ * The swap LoRA a run carries (fal loads it by its pinned Hugging Face URL; ComfyUI gets the file downloaded). "none"+ * has no file: the open graph runs H3 with the Turbo LoRA alone, and fal's route (which needs a LoRA) refuses it+ * (CLOUD_NO_LORA) rather than quietly running V1.5.+ */+export function swapLoraRef(lora: Exclude<SwapLora, "none"> | undefined): LoraRef {const l = SWAP_LORAS[lora === "v1" ? "v1" : "v1.5"];return { file: l.file, url: l.url, weightName: l.file, strength: 1, version: l.url.split("/resolve/")[1]?.split("/")[0], licence: H3_LORA_LICENCE };}+/** fal's H3 + LoRA route takes 1–3 LoRAs: "no swap LoRA" is the open graph's choice only. */+export const CLOUD_NO_LORA = "On the cloud, fal's H3 route runs with a swap LoRA — pick V1.5 or V1 (no LoRA runs on your GPU)";+/** lightx2v's FL2V Turbo 8-step LoRA the open graphs load (Apache-2.0 at this revision). */export const TURBO_LORA: LoraRef = {file: "minimax_h3_fl2v_turbo_8step_v1.0_768p_comfyui_bf16.safetensors",@@ -151,49 +166,107 @@ export function alignFrames(n: number): number {return f;}-/** Frames of a part at H3's 24 fps. */-export const partFrames = (seconds: number) => Math.max(1, Math.round(seconds * CHARACTER_SWAP.fps));--/**- * How many diffusion windows a part takes (the pack plans source-aligned windows over the part padded to H3's grid):- * 5 s → 1, 7.5 s and 10 s → 2, 12.5 s and 15 s → 3 (docs/research/openjutsu-6.md §3.4).- */-export function h3Windows(seconds: number, windowFrames: number = CHARACTER_SWAP.window): number {- return Math.max(1, Math.ceil(alignFrames(partFrames(seconds)) / Math.max(22, windowFrames)));-}+/** Frames of a part at H3's 24 fps, as the pack's PrepareVideo keeps them (floor(seconds × 24)). */+export const partFrames = (seconds: number) => Math.max(1, Math.floor(seconds * CHARACTER_SWAP.fps + 1e-6));/** Window sizes the pack takes (17n + 5, 22 … 362) and continuation history (0, 1 or 17n + 1, 18 … 341). */export const WINDOW_CHOICES = Array.from({ length: 21 }, (_, i) => 22 + 17 * i);export const HISTORY_CHOICES = [0, 1, ...Array.from({ length: 20 }, (_, i) => 18 + 17 * i)];const nearest = (xs: number[], v: number) => xs.reduce((a, b) => (Math.abs(b - v) < Math.abs(a - v) ? b : a));-export const windowFrames = (v: number | undefined) => String(nearest(WINDOW_CHOICES, v ?? CHARACTER_SWAP.window));-export const historyFrames = (v: number | undefined) => String(nearest(HISTORY_CHOICES, v ?? CHARACTER_SWAP.history));++/** The pack's window and history for what was asked (each snapped to its grid; history shorter than the window). */+export function windowPlan(window: number | undefined, history: number | undefined): { window: number; history: number } {+ const w = nearest(WINDOW_CHOICES, window ?? CHARACTER_SWAP.window);+ const h = nearest(HISTORY_CHOICES, history ?? CHARACTER_SWAP.history);+ // planning.validate_settings: "History must be smaller than the generation window."+ return { window: w, history: h < w ? h : Math.max(...HISTORY_CHOICES.filter((x) => x < w)) };+}+export const windowFrames = (v: number | undefined) => String(windowPlan(v, 0).window);+export const historyFrames = (v: number | undefined, window?: number) => String(windowPlan(window ?? 362, v).history);++/** The history lengths a window takes (the pack refuses a history as long as the window). */+export const historyChoicesFor = (window: number) => HISTORY_CHOICES.filter((h) => h < window);++/** What the pack would refuse in a window and history asked for, or null. */+export function windowProblem(c: { windowFrames?: number; historyFrames?: number }): string | null {+ if (c.windowFrames === undefined && c.historyFrames === undefined) return null;+ const w = nearest(WINDOW_CHOICES, c.windowFrames ?? CHARACTER_SWAP.window);+ const h = nearest(HISTORY_CHOICES, c.historyFrames ?? CHARACTER_SWAP.history);+ return h >= w ? `History (${h} frames) must be shorter than the window (${w} frames)` : null;+}++/**+ * How many diffusion windows a part takes: the pack's plan_windows (planning.py at 0670e4f, the same in H3 Relay). The+ * first window has no history; each later one starts on the last frame already made (history before it) and delivers+ * up to window − 1 new frames, its size the smallest on H3's grid that fits what is left. 5 s → 1, 10 s → 2, 15 s → 3.+ */+export function h3Windows(seconds: number, window?: number, history?: number): number {+ const p = windowPlan(window, history);+ const count = partFrames(seconds);+ let n = 0;+ let covered = 0;+ while (covered < count) {+ const eh = n ? p.history : 0;+ const start = covered - (eh ? 1 : 0);+ const needed = Math.min(count - start, p.window);+ const size = WINDOW_CHOICES.find((v) => v >= needed && v > eh) ?? p.window;+ covered = Math.min(count, start + size);+ n++;+ }+ return Math.max(1, n);+}++/** The pixel budgets of the pack's PrepareVideo (video.py PIXEL_BUDGETS; H3 Relay's video_prep.py is the same). */+export const H3_PIXEL_BUDGET: Record<CharacterQuality, number> = { "480p": 500_000, "768p": 1_000_000 };/**- * The size H3 works at for a clip: the short edge at 768 (or 480) px, the area capped at 768 × 1344 (480 × 840), each side- * rounded to 32 (ComfyUI's adapt_canvas). Clicks on the first frame are moved into these pixels. For 480p the pack's own- * rule isn't published: this scales ComfyUI's 768 rule, so clicks there are an estimate.+ * The size H3 works at for a clip: the pack's canvas_dimensions. A clip already on the 32-pixel grid and within the+ * budget (0.5 MP at "480", 1.0 MP at "768") keeps its size; otherwise the shape on the 32-pixel grid within the budget+ * nearest the ideal area-scaled one (squared log distances on each side; the larger area on a tie).*/export function h3Canvas(width: number, height: number, quality: string | undefined): { width: number; height: number } {- const short = characterQuality(quality) === "480p" ? 480 : 768;- const maxArea = short * Math.round((short * 1344) / 768);+ const budget = H3_PIXEL_BUDGET[characterQuality(quality)];+ if (!(width > 0 && height > 0) || !Number.isFinite(width * height)) return { width: 32, height: 32 };+ if (width * height <= budget && width % 32 === 0 && height % 32 === 0) return { width, height };const ratio = width / height;- let [w, h] = ratio >= 1 ? [short * ratio, short] : [short, short / ratio];- if (w * h > maxArea) {- const s = Math.sqrt(maxArea / (w * h));- w *= s;- h *= s;+ const iw = Math.sqrt(budget * ratio);+ const ih = Math.sqrt(budget / ratio);+ let best: [number, number, number, number] | null = null;+ const less = (a: [number, number, number, number], b: [number, number, number, number]) => {+ for (let i = 0; i < 4; i++) if (a[i] !== b[i]) return a[i] < b[i];+ return false;+ };+ for (let w = 32; w <= Math.min(16384, Math.floor(budget / 32)); w += 32) {+ const maxH = Math.min(16384, Math.floor(Math.floor(budget / w) / 32) * 32);+ for (const h of new Set([Math.max(32, Math.min(maxH, Math.floor(ih / 32) * 32)), Math.max(32, Math.min(maxH, Math.ceil(ih / 32) * 32))])) {+ const c: [number, number, number, number] = [Math.log(w / iw) ** 2 + Math.log(h / ih) ** 2, -(w * h), w, h];+ if (!best || less(c, best)) best = c;+ }}- const r32 = (v: number) => Math.max(32, Math.round(v / 32) * 32);- return { width: r32(w), height: r32(h) };+ return { width: best![2], height: best![3] };}-/** Clicks in the clip's pixels → SAM3_Detect's JSON points in H3's canvas: [positive, negative] ("" when none). */+/**+ * A point in the clip's pixels → the same spot in H3's prepared frame: the pack scales the clip to cover the canvas+ * (FFmpeg scale=ceil(max(w, h·dar)) × ceil(max(h, w/dar))) and crops the middle, so a point in the cut-off margin lands+ * on the nearest edge.+ */+export function toH3Canvas(p: { x: number; y: number }, clip: { width: number; height: number }, quality: string | undefined): { x: number; y: number } {+ const c = h3Canvas(clip.width, clip.height, quality);+ const dar = clip.width / clip.height;+ const sw = Math.ceil(Math.max(c.width, c.height * dar) - 1e-6);+ const sh = Math.ceil(Math.max(c.height, c.width / dar) - 1e-6);+ const x0 = Math.floor((sw - c.width) / 2);+ const y0 = Math.floor((sh - c.height) / 2);+ const clamp = (v: number, max: number) => Math.max(0, Math.min(max - 1, Math.round(v)));+ return { x: clamp((p.x / clip.width) * sw - x0, c.width), y: clamp((p.y / clip.height) * sh - y0, c.height) };+}++/** Clicks in the clip's pixels → SAM3_Detect's JSON points in H3's prepared frame: [positive, negative] ("" when none). */export function samCoords(points: PixelPoint[] | undefined, clip: { width: number; height: number }, quality: string | undefined): [string, string] {if (!points?.length || !clip.width || !clip.height) return ["", ""];- const c = h3Canvas(clip.width, clip.height, quality);- const at = (p: PixelPoint) => ({ x: Math.round((p.x / clip.width) * c.width), y: Math.round((p.y / clip.height) * c.height) });+ const at = (p: PixelPoint) => toH3Canvas(p, clip, quality);const pos = points.filter((p) => p.label !== "negative").map(at);const neg = points.filter((p) => p.label === "negative").map(at);return [pos.length ? JSON.stringify(pos) : "", neg.length ? JSON.stringify(neg) : ""];@@ -239,6 +312,21 @@ export function speechLine(speech: SwapSpeech | undefined, dialogue?: string): s}}+/**+ * The words spoken in a part, from a transcription of the whole clip (cues in clip seconds): every cue that overlaps+ * the part, in order (Akatz Labs feed each segment's dialogue into its prompt the same way).+ */+export function partWords(cues: { start: number; end: number; text: string }[] | undefined, part: { start: number; end: number }): string {+ const inside = (cues ?? []).filter((c) => Number.isFinite(c.start) && Number.isFinite(c.end) && c.end > part.start + 0.05 && c.start < part.end - 0.05);+ return tidy(+ inside+ .sort((a, b) => a.start - b.start)+ .map((c) => c.text.trim())+ .filter(Boolean)+ .join(" "),+ ).slice(0, 2000);+}+export interface SwapPromptInput extends Pick<CharacterOptions, "who" | "index" | "subject" | "description" | "speech" | "dialogue"> {engine: Engine;/** The anchor first frame goes along (Picture 2 / Image 2). */@@ -296,6 +384,24 @@ export const ANCHOR_MODELS: Record<Engine, { id: string; label: string; note: stexport const anchorModel = (engine: Engine, id?: string) => ANCHOR_MODELS[engine].find((m) => m.id === id) ?? ANCHOR_MODELS[engine][0];+/**+ * The aspect ratio the anchor edit is asked for, so the first frame keeps the part's shape: "auto" (the first image's+ * shape) when the model takes it, else the ratio it lists nearest the clip's. Undefined: the model has no ratios, or+ * the clip's size isn't known.+ */+export function anchorAspect(ratios: readonly string[] | undefined, clip: { width?: number; height?: number }): string | undefined {+ if (!ratios?.length) return undefined;+ if (ratios.includes("auto")) return "auto";+ if (!clip.width || !clip.height) return undefined;+ const want = Math.log(clip.width / clip.height);+ const value = (r: string) => {+ const [a, b] = r.split(":").map(Number);+ return a > 0 && b > 0 ? Math.log(a / b) : NaN;+ };+ const listed = ratios.filter((r) => Number.isFinite(value(r)));+ return listed.length ? listed.reduce((best, r) => (Math.abs(value(r) - want) < Math.abs(value(best) - want) ? r : best)) : undefined;+}+/** What a run says when the anchor frame couldn't be made (the swap goes ahead without it). */export const ANCHOR_FALLBACK = "Couldn't make the first frame — swapped without it";@@ -405,7 +511,7 @@ export const CHARACTER_LICENCES: CharacterLicence[] = [item: "H3 Relay 2.0 node pack (Akatz Labs)",name: "GPL-3.0",class: "commercial",- url: "https://github.com/akatz-ai/h3-relay",+ url: "https://github.com/akatz-ai/h3-relay/tree/e2a7665b6eb8ea37a88c0de2c9c6b69a8f7c9220",note: "GPL-3.0 code (Sendy Software LLC and contributors); vendored Context Loop and Spectrum GPL-3.0",},{@@ -424,12 +530,20 @@ export const CHARACTER_LICENCES: CharacterLicence[] = [},];-/** The node packs, in the shape Settings → Models & licences lists packs (src/lib/licences.ts NODE_PACKS on model-access). */-export const H3_NODE_PACKS = CHARACTER_LICENCES.filter((l) => l.item.includes("node pack")).map((l) => ({- name: l.item.startsWith("h3_character_swap") ? "h3_character_swap" : "h3-relay",- repo: l.url,- licence: { name: l.name, class: l.class, url: l.url, note: l.note },-}));+/** Turbo's licence at the pinned revision (Apache-2.0; the current card dropped the tag). */+const TURBO_LICENCE = CHARACTER_LICENCES.find((l) => l.item.startsWith("FL2V Turbo"))!;++/**+ * The LoRA files the Character swap loads, with their licence, for Settings → Models & licences (the LoRA rows and+ * the run-time class check): the swap LoRA's releases are MiniMax H3 Community License work, Turbo is Apache-2.0.+ */+export const CHARACTER_LORAS: { file: string; name: string; url: string; licence: CharacterLicence }[] = [+ { file: SWAP_LORAS["v1.5"].file, name: "H3 Character Swap LoRA V1.5 (Akatz Labs)", url: SWAP_LORAS["v1.5"].url, licence: MINIMAX_H3_LICENCE },+ { file: SWAP_LORAS.v1.file, name: "H3 Character Swap LoRA V1 (Akatz Labs)", url: SWAP_LORAS.v1.url, licence: MINIMAX_H3_LICENCE },+ { file: TURBO_LORA.file, name: "MiniMax H3 FL2V Turbo 8-step (lightx2v)", url: TURBO_LORA.url!, licence: TURBO_LICENCE },+];++export const characterLora = (file: string) => CHARACTER_LORAS.find((l) => l.file === file);/** One line for a model picker: the licence that matters most for the route, as information. */export function characterLicenceLine(engine: Engine, modelId: string): string {diff --git a/src/lib/catalog/genjutsu.ts b/src/lib/catalog/genjutsu.tsindex 73e70ab1..8fbd9a85 100644--- a/src/lib/catalog/genjutsu.ts+++ b/src/lib/catalog/genjutsu.ts@@ -17,11 +17,14 @@* comfyui-oss-4.md §c.*/import { keepOffered } from "@/lib/model-access";+import { silenceRef } from "./canvas";import {+ anchorAspect,anchorModel,anchorPrompt,ANCHOR_FALLBACK,CHARACTER_SWAP,+ CLOUD_NO_LORA,characterLicenceLine,characterQuality,cutsInPart,@@ -30,6 +33,7 @@ import {swapLoraRef,swapPrompt,whoWords,+ windowProblem,type CharacterOptions,type SwapLora,type SwapSpeech,@@ -52,6 +56,7 @@ import {type RemoveSource,} from "./remove-object";import { firstFramePrompt, getShortsPreset, lookFromPreset, planShorts, segmentPrompt, type PlanStep, type ShortsLook } from "./shorts";+import { getModel } from "./index";import { soulLook } from "./soul";import type { ChainSlot, Engine, GenerationRequest, PixelPoint } from "./types";@@ -167,8 +172,11 @@ export interface Maker {billFps?: number;/** params.extra its open route gets (Lite: Wan Animate 2 in 4 steps). */extra?: Record<string, unknown>;- /** Character swap on MiniMax H3: who to swap, the anchor first frame and the H3 settings apply. */- h3?: { anchor: boolean };+ /**+ * Character swap on MiniMax H3: who to swap, the anchor first frame and the H3 settings apply. `maskSwitch`: its graph+ * can regenerate the whole frame instead of only the person (Openjutsu's use_mask; H3 Relay's graph has no switch).+ */+ h3?: { anchor: boolean; maskSwitch?: boolean };}/** fal's hosted Wan VACE (2.1 14B and 2.2 Fun): 17–241 frames (4n+1, the clip's own count and rate), at most 30 fps. */@@ -355,7 +363,7 @@ export const MAKERS: Maker[] = [refs: { min: 1, max: 1 },keepsSound: true,qualities: ["480p", "768p"],- h3: { anchor: true },+ h3: { anchor: true, maskSwitch: true },promptOptional: true,},{@@ -606,6 +614,12 @@ export function makerLicence(m: Maker): string {return WEIGHTS[m.id] ? `${WEIGHTS[m.id]} · ${where}` : `Open weights · ${where}`;}+/**+ * Whether Settings → Models & licences offers a picker entry: Lite and the full Original are one entry, offered while+ * either tier is on.+ */+export const makerOffered = (m: Maker, on: (id: string) => boolean) => on(m.id) || (!!m.pair && on(m.pair));+/** The models you can pick for this engine, mode and way of pointing: Fuobe's Original first, then open weights, then partners. */export function makersFor(engine: Engine, mode: GenjutsuMode, target?: GenjutsuTarget): Maker[] {return MAKERS.filter((m) => {@@ -646,18 +660,24 @@ export function chooseMaker(o: {if (target && !MODE_TARGETS[o.mode].includes(target)) return { problem: `${getMode(o.mode).label} doesn't take ${target === "click" ? "clicks" : target === "paint" ? "paint" : "that"} — pick another way` };const on = o.offered;const all = makersFor(o.engine, o.mode, target);- const options = on ? keepOffered(all, (m) => on(m.id)) : all;+ const options = on ? keepOffered(all, (m) => makerOffered(m, on)) : all;if (!options.length) {if (o.engine === "cloud" && o.mode === "character" && target === "click") return { problem: CLOUD_CLICK_PROBLEM };return { problem: (o.engine === "open" && OPEN_TARGET_PROBLEM[o.mode]) || "Nothing on this engine does that yet" };}- const withTier = (m: Maker) => (m.pair && o.tier && m.tier !== o.tier ? (getMaker(m.pair, m.engine) ?? m) : m);+ // A tier switched off while the other one is on: the one that is on.+ const usable = (m: Maker) => {+ if (!on || on(m.id)) return m;+ const other = m.pair ? getMaker(m.pair, m.engine) : undefined;+ return other && on(other.id) ? other : m;+ };+ const withTier = (m: Maker) => usable(m.pair && o.tier && m.tier !== o.tier ? (getMaker(m.pair, m.engine) ?? m) : m);const id = o.modelId && (LEGACY_MAKERS[o.modelId] ?? o.modelId);const picked = getMaker(id, o.engine);if (picked) {// The picker lists Lite; a High pick (or a setup naming the full Original) is the same choice.const lite = picked.tier === "high" && picked.pair ? getMaker(picked.pair, picked.engine)! : picked;- if (options.includes(lite)) return { maker: o.tier ? withTier(lite) : picked };+ if (options.includes(lite)) return { maker: o.tier ? withTier(lite) : usable(picked) };}const first = [...options].sort((a, b) => SOURCE_RANK[a.source] - SOURCE_RANK[b.source])[0];// Restyle with your own look's images on a partner list: a model that reads them.@@ -844,6 +864,8 @@ export interface GenjutsuCheck {mask?: boolean;look?: GenjutsuLook;seed?: number;+ /** Character swap's settings (the LoRA and the window plan are checked). */+ character?: CharacterOptions;}/** What's wrong with the selection whatever the model, or null. */@@ -894,6 +916,9 @@ export function genjutsuProblem(c: GenjutsuCheck): string | null {if (c.mode === "character") {const seed = seedProblem(c.seed);if (seed) return seed;+ if (m.h3 && m.engine === "cloud" && c.character?.lora === "none") return CLOUD_NO_LORA;+ const windows = m.h3 && m.engine === "open" ? windowProblem(c.character ?? {}) : null;+ if (windows) return windows;if (target === "click" && !c.points) return "Click the person to swap on the first frame";return null;}@@ -1181,6 +1206,8 @@ function planCharacterSwap(input: GenjutsuPlanInput): GenjutsuPlan {const seed = input.seed !== undefined ? { seed: input.seed } : {};const anchorOn = !!m.h3?.anchor && c.anchor !== false;const am = anchorModel(m.engine, c.anchorModel);+ // The first frame keeps the part's shape ("auto", or the clip's nearest ratio): the model's default is square.+ const aspect = anchorAspect(getModel(am.id)?.options.aspectRatios, input.source);const steps: PlanStep[] = [];const promptWith = (anchor: boolean) => makerPrompt({ mode: "character", maker: m, prompt: input.prompt, refs: 1, character: c, anchor })!;const anchorStep = (key: string, frameKey: string, label: { label: string; index: number; of: number }): PlanStep => ({@@ -1191,7 +1218,7 @@ function planCharacterSwap(input: GenjutsuPlanInput): GenjutsuPlan {op: "edit",prompt: anchorPrompt(c),inputs: { images: character },- params: { ...(am.extra ? { extra: { ...am.extra } } : {}), ...seed },+ params: { ...(aspect ? { aspectRatio: aspect } : {}), ...(am.extra ? { extra: { ...am.extra } } : {}), ...seed },step: label,},after: [frameKey],@@ -1224,7 +1251,8 @@ function planCharacterSwap(input: GenjutsuPlanInput): GenjutsuPlan {resolution: quality,...(input.points?.length ? { points: input.points } : {}),...seed,- extra: h3Extra(c),+ // Clicked: SAM 3.1's point mask comes first among its detections (the text ones follow), so take that one.+ extra: { ...h3Extra(c), ...(input.points?.length ? { selection: "index", subjectIndex: 0 } : {}) },},step: { label: "Swap the character (MiniMax H3)", index: 0, of: 1 },},@@ -1233,7 +1261,8 @@ function planCharacterSwap(input: GenjutsuPlanInput): GenjutsuPlan {return { steps, final: "swap", pieces: 1, sound: false, tracked: false, anchors: anchorOn ? 1 : 0 };}- // Cloud: fal's H3 takes 5–15 s of reference video and whole seconds of output.+ // Cloud: fal's H3 takes 5–15 s of reference video and whole seconds of output, and needs a swap LoRA.+ if (c.lora === "none") throw new Error(CLOUD_NO_LORA);const pieces = planCloudPieces(input.range, CHARACTER_SWAP.maxSeconds, input.source.fps);const n = pieces.length;const sound = !!input.source.hasAudio;@@ -1253,11 +1282,11 @@ function planCharacterSwap(input: GenjutsuPlanInput): GenjutsuPlan {chain.push(anchorSlot());}const fit = callSecs - secs > 0.05;- const own = n === 1 && !sound && !fit;+ // The pieces are steps: the finished video is the join with the clip's sound, or its silence (below).steps.push({key: `swap${i}`,request: {- ...(own ? { ...base, title: input.title } : helper),+ ...helper,modelId: m.id,op: "video-swap",prompt: promptWith(anchorOn),@@ -1271,12 +1300,24 @@ function planCharacterSwap(input: GenjutsuPlanInput): GenjutsuPlan {});if (fit) {// H3 makes whole seconds: the extra is cut off, so the pieces stay on the clip's sound.- steps.push({ key: `fit${i}`, request: { ...(n === 1 && !sound ? { ...base, title: input.title } : helper), modelId: REMOVE_TOOLS.cloud.cut, op: "trim", params: { startTime: 0, endTime: secs }, step: label("trim to the part") }, after: [`swap${i}`], chain: [{ slot: "video" }] });+ steps.push({ key: `fit${i}`, request: { ...helper, modelId: REMOVE_TOOLS.cloud.cut, op: "trim", params: { startTime: 0, endTime: secs }, step: label("trim to the part") }, after: [`swap${i}`], chain: [{ slot: "video" }] });keys.push(`fit${i}`);} else keys.push(`swap${i}`);});- const final = n === 1 && !sound ? keys[0] : joinWithSound(steps, { engine: "cloud", title: input.title, base, helper, source: input.source, range: input.range, pieces: keys, sound });- return { steps, final, pieces: n, sound, tracked: false, anchors: anchorOn ? n : 0 };+ if (sound) {+ const final = joinWithSound(steps, { engine: "cloud", title: input.title, base, helper, source: input.source, range: input.range, pieces: keys, sound });+ return { steps, final, pieces: n, sound, tracked: false, anchors: anchorOn ? n : 0 };+ }+ // A silent clip: fal's H3 (reference to video and audio) makes a soundtrack of its own, so the result gets the clip's+ // silence instead (a silent track the server writes as the run starts, as Canvas mutes a clip).+ const picture = n === 1 ? keys[0] : joinWithSound(steps, { engine: "cloud", title: input.title, base: helper, helper, source: input.source, range: input.range, pieces: keys, sound: false });+ steps.push({+ key: "mute",+ request: { ...base, title: input.title, modelId: REMOVE_TOOLS.cloud.mux, op: "mux", inputs: { audio: silenceRef(r3(input.range.end - input.range.start)) }, step: { label: "Keep it silent, like the clip", index: 1200, of: 1000 } },+ after: [picture],+ chain: [{ slot: "video" }],+ });+ return { steps, final: "mute", pieces: n, sound, tracked: false, anchors: anchorOn ? n : 0 };}// ---------------------------------------------------------------------------diff --git a/src/server/canvas.ts b/src/server/canvas.tsindex c30e401b..6a07db8e 100644--- a/src/server/canvas.ts+++ b/src/server/canvas.ts@@ -528,7 +528,7 @@ function oversizedClip(graph: CanvasGraph, nodeId: string): string | null {* The silent tracks a run's steps name (silenceRef: a muted or soundless clip of the cloud concatenator), written* as WAV files when the run starts; one file per length.*/-function silenceWriter(): (req: GenerationRequest) => GenerationRequest {+export function silenceWriter(): (req: GenerationRequest) => GenerationRequest {const files = new Map<number, string>();return (req) => {const seconds = silenceSeconds(req.inputs?.audio);diff --git a/src/server/enhance.ts b/src/server/enhance.tsindex 21614ecb..1a4552d1 100644--- a/src/server/enhance.ts+++ b/src/server/enhance.ts@@ -94,8 +94,9 @@ export function llmTextBackend(): "claude" | "ollama" | null {* on "open source only" installs unless picked explicitly), else a local Ollama. Null when none.* `images` go along for a model that can see them (Content Factory's reference frames).*/-export async function llmText(system: string, user: string, images: LlmImage[] = []): Promise<string | null> {- const backend = llmTextBackend();+export async function llmText(system: string, user: string, images: LlmImage[] = [], o: { ollamaOnly?: boolean } = {}): Promise<string | null> {+ // The open engine never calls a paid API: Ollama, unless the AI helper is off.+ const backend = o.ollamaOnly && llmTextBackend() === "claude" ? "ollama" : llmTextBackend();if (backend === "claude") return viaClaude(system, user, images).catch(() => null);if (backend === "ollama") return viaOllama(system, user, images).catch(() => null);return null;diff --git a/src/server/genjutsu.ts b/src/server/genjutsu.tsindex e231d0ba..a42a3158 100644--- a/src/server/genjutsu.ts+++ b/src/server/genjutsu.ts@@ -2,7 +2,22 @@ import "server-only";import { z } from "zod";import { getModel } from "@/lib/catalog";import { onEngine } from "@/lib/catalog/engines";-import { ANCHOR_MODELS, anchorModel, CHARACTER_GPU, CHARACTER_LIMITS, CHARACTER_SWAP, characterLicenceLine, cutWarning, h3Windows, type CharacterOptions } from "@/lib/catalog/character-swap";+import {+ ANCHOR_MODELS,+ anchorModel,+ CHARACTER_GPU,+ CHARACTER_LIMITS,+ CHARACTER_SWAP,+ characterLicenceLine,+ cutWarning,+ h3Windows,+ swapLoraRef,+ SWAP_LORAS,+ TURBO_LORA,+ windowPlan,+ type CharacterOptions,+} from "@/lib/catalog/character-swap";+import { ACCESS_PLACE } from "@/lib/model-access";import {chooseMaker,cutsInPart,@@ -28,13 +43,17 @@ import {import { MASK_TRACKER, REMOVE_TOOLS, scalePoints, wholeClip, type RemoveRange, type RemoveSource } from "@/lib/catalog/remove-object";import { planSegments, type PlanStep } from "@/lib/catalog/shorts";import type { Engine, Generation, PixelPoint, ProviderId } from "@/lib/catalog/types";+import { silenceWriter } from "./canvas";import { createPipeline } from "./chains";-import { previewChained } from "./generations";-import { isOffered } from "./model-access";+import { llmText, llmTextBackend } from "./enhance";+import { createGenerations, previewChained } from "./generations";+import { isOffered, offeredLoras, offeredModel } from "./model-access";import { provider } from "./providers";+import { probeOllama } from "./providers/llm";import { pointsFromPaint } from "./remove-object";-import { engineMode } from "./settings";+import { engineMode, getSetting } from "./settings";import { probeSource, ShortsError } from "./shorts";+import { readRef } from "./storage";/*** Fuobe Genjutsu (/genjutsu): plans, prices and starts a Motion transfer, Character swap, Object swap, Restyle or Insert@@ -181,8 +200,9 @@ async function planInput(body: GenjutsuBody, opts: { probe: boolean }): Promise<const target = MODE_TARGETS[body.mode].length ? (body.target ?? MODE_TARGETS[body.mode][0]) : undefined;const references = body.references ?? [];const clicks = (body.points ?? []).filter((p) => p.label !== "negative").length;- const problem = genjutsuProblem({ mode: body.mode, maker, source, range, references: references.length, target, subject: body.subject, prompt: body.prompt, points: clicks, mask: !!body.mask, look: body.look, seed: body.seed });+ const problem = genjutsuProblem({ mode: body.mode, maker, source, range, references: references.length, target, subject: body.subject, prompt: body.prompt, points: clicks, mask: !!body.mask, look: body.look, seed: body.seed, character: body.character });if (problem) throw new ShortsError(problem, 422);+ const switched = body.mode === "character" && maker.h3 ? characterSwitches(maker, body.character ?? {}) : { character: body.character, notes: [] };// Clicks on the first frame, in the clip's pixels; paint is followed from its deepest points (SAM 3.1 on fal).let points: PixelPoint[] | undefined;@@ -195,7 +215,7 @@ async function planInput(body: GenjutsuBody, opts: { probe: boolean }): Promise<const tracksPaint = maker.engine === "cloud" && body.mode === "swap" && target === "paint" && (maker.source === "original" || n > 1);if (tracksPaint) points = opts.probe ? await pointsFromPaint(body.mask!, source, "Paint over what to swap first") : [{ x: 1, y: 1, label: "positive" }];- const notes = notesFor(body, maker, source, range, n, references.length);+ const notes = [...switched.notes, ...notesFor({ ...body, character: switched.character }, maker, source, range, n, references.length)];const name = (body.source.name ?? "").replace(/\.[a-z0-9]{2,4}$/i, "").trim().slice(0, 40);const title = genjutsuTitle({ mode: body.mode, subject: body.subject, look: body.look });return {@@ -217,11 +237,37 @@ async function planInput(body: GenjutsuBody, opts: { probe: boolean }): Promise<mask: target === "paint" ? body.mask : undefined,look: body.look,...(body.seed !== undefined ? { seed: body.seed } : {}),- ...(body.mode === "character" ? { character: body.character ?? {} } : {}),+ ...(body.mode === "character" ? { character: switched.character ?? {} } : {}),},};}+/**+ * The Character swap with what Settings → Models & licences switched off taken out: the first-frame model (the next one+ * that is on, else no first frame) and the swap LoRA (on your GPU H3 runs without it; fal's route needs one). Turbo off+ * on the open engine stops the run: the 8-step graph can't go without it.+ */+function characterSwitches(m: Maker, c: CharacterOptions): { character: CharacterOptions; notes: string[] } {+ const notes: string[] = [];+ let out = c;+ if (m.h3?.anchor && c.anchor !== false) {+ const wanted = anchorModel(m.engine, c.anchorModel);+ if (!isOffered(wanted.id, m.engine)) {+ const next = ANCHOR_MODELS[m.engine].find((a) => isOffered(a.id, m.engine));+ out = next ? { ...out, anchorModel: next.id } : { ...out, anchor: false };+ notes.push(next ? `${wanted.label} is switched off in ${ACCESS_PLACE}: ${next.label} makes the first frame` : `The first-frame models are switched off in ${ACCESS_PLACE}: the swap runs without a first frame`);+ }+ }+ const lora = c.lora ?? "v1.5";+ if (lora !== "none" && offeredLoras([swapLoraRef(lora)]).dropped.length) {+ if (m.engine === "cloud") throw new ShortsError(`The swap LoRA (${SWAP_LORAS[lora].label}) is switched off in ${ACCESS_PLACE}, and fal's H3 route needs one — turn it on, or pick the other release`, 422);+ out = { ...out, lora: "none" };+ notes.push(`The swap LoRA is switched off in ${ACCESS_PLACE}: H3 runs with the Turbo LoRA alone`);+ }+ if (m.engine === "open" && offeredLoras([TURBO_LORA]).dropped.length) throw new ShortsError(`The H3 Turbo LoRA is switched off in ${ACCESS_PLACE}, and the Character swap's 8-step graph needs it — turn it on to run it on your GPU`, 422);+ return { character: out, notes };+}+function notesFor(body: GenjutsuBody, m: Maker, source: RemoveSource, range: RemoveRange, n: number, refs: number): string[] {const notes: string[] = [];const name = getModel(m.id)?.name ?? m.label;@@ -231,16 +277,24 @@ function notesFor(body: GenjutsuBody, m: Maker, source: RemoveSource, range: Remif (body.mode === "character" && m.h3) {const c = body.character ?? {};if (m.engine === "open") {- const windows = h3Windows(len, c.windowFrames);- notes.push(`MiniMax H3 swaps it in ${windows} window${windows > 1 ? "s" : ""} of ${c.windowFrames ?? CHARACTER_SWAP.window} frames at 24 fps, each continuing the one before; the clip's sound stays`);- } else if (n > 1) notes.push(`fal's H3 takes up to 15 s a call: the part runs as ${n} pieces, joined with the clip's own sound. Each piece starts fresh (no history between them)`);- if (len > CHARACTER_SWAP.maxSeconds + 0.05) notes.push("Past 15 s is beyond what H3 was trained on: quality there is unverified");+ const plan = windowPlan(c.windowFrames, c.historyFrames);+ const windows = h3Windows(len, plan.window, plan.history);+ notes.push(+ windows > 1+ ? `MiniMax H3 swaps it in ${windows} windows of up to ${plan.window} frames at 24 fps, each continuing from the ${plan.history} frames before it; the clip's sound stays`+ : `MiniMax H3 swaps it in one window of up to ${plan.window} frames at 24 fps; the clip's sound stays`,+ );+ // One prompt for the whole part: past H3's trained range (~362 frames) the pack itself says quality is unverified.+ if (len > CHARACTER_SWAP.maxSeconds + 0.05) notes.push("Past 15 s is beyond what H3 was trained on: quality there is unverified");+ } else if (n > 1) notes.push(`fal's H3 takes up to 15 s a call: the part runs as ${n} pieces, joined with the clip's own sound. Each piece starts fresh (no history between them), so a seam can show where they meet`);+ if (m.engine === "cloud" && !source.hasAudio) notes.push("Your clip has no sound, and neither will the result: fal's H3 makes a soundtrack of its own, which is replaced with silence");if (m.h3.anchor && c.anchor !== false) {const am = anchorModel(m.engine, c.anchorModel);notes.push(`${am.label} first puts your character into the part's first frame${m.engine === "cloud" && n > 1 ? " (one per piece)" : ""}; if that fails the swap runs without it`);} else if (!m.h3.anchor) notes.push(`${name} runs without an anchor frame`);if (m.engine === "cloud") notes.push("On fal, H3 has no mask: who to swap is said in words, and the whole frame is regenerated around them");- if (body.points?.length && body.quality === "480p" && m.engine === "open") notes.push("Clicks are placed in H3's 480p frame by estimate: if the wrong person is picked, choose them by position instead");+ if (m.engine === "open" && c.who === "index" && !body.points?.length) notes.push("Person numbers follow SAM 3.1's detections, the one it is surest of first — not left to right");+ if (m.engine === "open" && !m.h3.maskSwitch && c.useMask === false) notes.push(`${name} always regenerates only the person: its graph has no switch for the whole frame`);const warn = cutWarning(cutsInPart(body.cuts, range));if (warn) notes.push(warn);notes.push(characterLicenceLine(m.engine, m.id));@@ -447,10 +501,87 @@ export async function createGenjutsu(body: GenjutsuBody): Promise<{ final: Generconst plan = planGenjutsu(input);// The same check as the estimate: nothing starts when only some of the steps have a provider.price(plan.steps, input);- const p = createPipeline(plan.steps);+ // A silent clip's cloud swap ends on silence: its WAV is written now (silenceRef, as Canvas mutes a clip).+ const withSilence = silenceWriter();+ const p = createPipeline(plan.steps.map((s) => ({ ...s, request: withSilence(s.request) })));return { final: p.byKey[plan.final], items: p.items };} catch (e) {if (e instanceof ShortsError) throw e;throw new ShortsError((e as Error).message, 422);}}++// ---------------------------------------------------------------------------+// Character swap helpers: "Describe my character" and the part's words (Akatz Labs' description and transcript)++const DESCRIBE_SYSTEM =+ "You describe a character from one reference picture for a video model that will put them into a scene. Say only who they are and what they wear: " ++ "apparent age range, build, face, hair, skin tone, clothing, shoes, accessories and their colours. No pose, background, lighting, camera or art style, " ++ "no names, no guesses about personality. One plain sentence under 60 words, starting with \"a\" or \"an\", no quotes, no preamble.";++export const DescribeSchema = z.object({ engine: z.enum(["cloud", "open"]), image: z.string().startsWith("/api/files/").max(500) });++/**+ * "Describe my character": the engine's text model looks at the character picture and writes the description the+ * prompt and the anchor brief carry (Akatz Labs found generic prompts weak). Cloud: Claude, else Ollama; your GPU:+ * Ollama with a vision model. A text model switched off in Settings → Models & licences doesn't answer.+ */+export async function describeCharacter(body: z.infer<typeof DescribeSchema>): Promise<{ description: string }> {+ mustMatchMode(body.engine);+ const textModel = getModel(body.engine === "open" ? "oss-text-llm" : "text-llm");+ if (!textModel || !offeredModel(textModel)) throw new ShortsError(`The text model is switched off in ${ACCESS_PLACE} — describe your character in your own words`, 422);+ // Ollama is asked on your GPU's engine (and when no Anthropic key is set): it has to be running.+ const backend = llmTextBackend();+ const ollama = backend === "ollama" || (backend === "claude" && body.engine === "open");+ if (getSetting("demoMode") === "on" || !backend || (ollama && !(await probeOllama()))) {+ throw new ShortsError("Describing needs a text model: add an Anthropic key, or run Ollama with a vision model (Settings → AI helper)", 422);+ }+ let file: Awaited<ReturnType<typeof readRef>>;+ try {+ file = await readRef(body.image);+ } catch {+ throw new ShortsError("Couldn't read the character picture — add it again", 422);+ }+ if (!/^image\/(png|jpeg|webp|gif)$/.test(file.contentType)) throw new ShortsError("Describe works on a PNG, JPEG or WebP picture", 422);+ const answer = await llmText(DESCRIBE_SYSTEM, "Describe the character in this picture.", [{ data: file.data, contentType: file.contentType }], { ollamaOnly: body.engine === "open" });+ const description = answer+ ?.replace(/^["“'\s]+|["”'\s]+$/g, "")+ .replace(/\s+/g, " ")+ .replace(/[.\s]+$/, "")+ .slice(0, CHARACTER_SWAP.maxDescriptionChars);+ if (!description) throw new ShortsError(body.engine === "open" ? "Ollama didn't describe the picture — it needs a vision model (qwen3-vl, gemma3…)" : "The text model didn't answer — try again, or describe your character in your own words", 422);+ return { description };+}++/** The transcriber per engine (Fuobe's Transcribe studio's defaults). */+export const TRANSCRIBERS: Record<Engine, string> = { cloud: "scribe-v2", open: "oss-qwen3-asr" };++export const TranscribeSchema = z.object({+ engine: z.enum(["cloud", "open"]),+ source: z.object({ url: z.string().startsWith("/api/files/").max(500), duration: z.number().finite().positive().max(3600).optional() }),+});++/**+ * The clip's words, for "What's said": one transcription of the whole clip (word-timed cues), so any part picked+ * afterwards takes its own lines from it in the browser (partWords). A Genjutsu step: it stays out of the page's feed.+ */+export function transcribeClip(body: z.infer<typeof TranscribeSchema>): { id: string; modelId: string } {+ mustMatchMode(body.engine);+ const modelId = TRANSCRIBERS[body.engine];+ if (!isOffered(modelId, body.engine)) throw new ShortsError(`${getModel(modelId)?.name ?? modelId} is switched off in ${ACCESS_PLACE} — type the words instead`, 422);+ const seconds = body.source.duration;+ try {+ const [g] = createGenerations({+ feature: GENJUTSU.stepFeature,+ batchTitle: "Genjutsu · the clip's words",+ modelId,+ op: "transcribe",+ inputs: { video: body.source.url },+ ...(seconds ? { params: { duration: seconds, sourceDuration: seconds } } : {}),+ step: { label: "The clip's words", index: 0, of: 1 },+ });+ return { id: g.id, modelId };+ } catch (e) {+ throw new ShortsError((e as Error).message, 422);+ }+}diff --git a/src/server/model-access.ts b/src/server/model-access.tsindex e970e463..e64753b4 100644--- a/src/server/model-access.ts+++ b/src/server/model-access.ts@@ -1,5 +1,6 @@import "server-only";import { getPreset, MODELS } from "@/lib/catalog";+import { CHARACTER_LORAS, characterLora } from "@/lib/catalog/character-swap";import { onEngine, providerEngine } from "@/lib/catalog/engines";import { LORA_LIBRARY, MOTION_EFFECT_LORAS } from "@/lib/catalog/lora-library.generated";import { libraryEntry, loraName } from "@/lib/catalog/loras";@@ -195,10 +196,19 @@ export function offeredSummary(): AccessSummary | undefined {/** A LoRA's licence: the ref's snapshot, else the library's; a LoRA with neither is the user's own. */export function loraLicence(l: Pick<LoraRef, "file" | "url" | "licence">): LicenceInfo {+ // The Character swap's LoRAs carry MiniMax H3's own terms (restricted regions), or Turbo's Apache-2.0.+ const h3 = characterLora(l.file);+ if (h3) return characterLoraLicence(h3);const e = libraryEntry(l);return loraLicenceInfo(l.licence ?? e?.licence, e?.page);}+/** A Character swap LoRA's licence as the list shows it (its own recorded terms, its pinned model card). */+function characterLoraLicence(l: (typeof CHARACTER_LORAS)[number]): LicenceInfo {+ const { name, class: cls, url, excludes, notices, note } = l.licence;+ return { name, class: cls, url: modelCardOf(l.url) ?? url, note, ...(excludes && { excludes }), ...(notices?.length && { notices }) };+}+/*** The LoRAs a run may load: one switched off, or whose licence class is, is left out (the plan's notes say* which switch). With "keep GPU-only LoRAs on your GPU" on, each LoRA is marked so a cloud route leaves the ones@@ -270,6 +280,8 @@ function loraRows(access: ModelAccess): LoraInfo[] {const used = presets.length ? `In the preset LoRA map: ${presets.map((p) => p.name).join(", ")}` : "In the preset LoRA map";rows.push({ file, name: mapLoraName(ref), group: motion ? "motion" : "effect", base: ref.base, licence: loraLicenceInfo(ref.licence, modelCardOf(ref.url), used), on: !access.loras.includes(file) });}+ // The LoRAs the Character swap's graphs load (and fal's route takes): Akatz Labs' swap LoRA and lightx2v's Turbo.+ for (const l of CHARACTER_LORAS) rows.push({ file: l.file, name: l.name, group: "adapter", base: "MiniMax H3", licence: characterLoraLicence(l), on: !access.loras.includes(l.file) });return rows;}@@ -286,7 +298,7 @@ export function knownSwitch(kind: "model" | "provider" | "pack" | "lora", id: stcase "pack":return NODE_PACKS.some((p) => p.name === id);case "lora":- return LORA_LIBRARY.some((e) => e.file === id) || Object.values(OSS_LORAS).some((refs) => refs.some((r) => r.file === id));+ return LORA_LIBRARY.some((e) => e.file === id) || Object.values(OSS_LORAS).some((refs) => refs.some((r) => r.file === id)) || !!characterLora(id);}}diff --git a/src/server/providers/comfyui.ts b/src/server/providers/comfyui.tsindex c430ee22..222b0c1a 100644--- a/src/server/providers/comfyui.ts+++ b/src/server/providers/comfyui.ts@@ -42,7 +42,7 @@ import { expandTimelineWorkflow, readTimeline } from "@/lib/av/timeline";import { exportValues, exrWorkflow, framesPerPass, hdrColorSpace, upscaleShortSide, wholeClipProblem, wholeClipTool } from "@/lib/av/video-finish";import { guessKind } from "@/lib/catalog/payload";import { loraByFile, needsToken } from "@/lib/catalog/loras";-import { packResolution, samCoords, SWAP_LORAS, windowFrames as h3WindowFrames, historyFrames as h3HistoryFrames } from "@/lib/catalog/character-swap";+import { CHARACTER_SWAP, packResolution, samCoords, swapPrompt, SWAP_LORAS, windowPlan } from "@/lib/catalog/character-swap";import { getMaker, makerPrompt, OPEN_TARGET_PROBLEM, ORIGINALS, swapTarget } from "@/lib/catalog/genjutsu";import { CLICK_OPEN_PROBLEM, HAND_OFF, REMOVE_SCENE, targetPhrase } from "@/lib/catalog/remove-object";import type { GenInput, MediaKind, ModelRoute, Operation } from "@/lib/catalog/types";@@ -915,8 +915,12 @@ export async function prepareWorkflow(endpointTemplate: string, input: GenInput,let dropSwapLora = false;if (characterSwap) {values.quality = packResolution(input.resolution);- if (extra.windowFrames !== undefined) extra.windowFrames = h3WindowFrames(Number(extra.windowFrames));- if (extra.historyFrames !== undefined) extra.historyFrames = h3HistoryFrames(Number(extra.historyFrames));+ // The pack's planning.validate_settings: windows 17n + 5, history 0, 1 or 17n + 1 and shorter than the window.+ if (extra.windowFrames !== undefined || extra.historyFrames !== undefined) {+ const plan = windowPlan(Number(extra.windowFrames ?? d.windowFrames ?? CHARACTER_SWAP.window), Number(extra.historyFrames ?? d.historyFrames ?? CHARACTER_SWAP.history));+ extra.windowFrames = String(plan.window);+ extra.historyFrames = String(plan.history);+ }const lora = typeof extra.lora === "string" ? extra.lora : undefined;delete extra.lora;if (lora === "none") dropSwapLora = true;@@ -926,9 +930,14 @@ export async function prepareWorkflow(endpointTemplate: string, input: GenInput,const [pos, neg] = samCoords(input.points, { width: clip.width, height: clip.height }, input.resolution);values.positiveCoords = pos;values.negativeCoords = neg;+ // SAM3_Detect puts the clicked mask first and the "person" detections after it: SelectSubject takes that first one+ // ("largest" would take whoever is biggest).+ extra.selection = "index";+ extra.subjectIndex = 0;}if (b.image2 && !values.image2) dropAnchor = true;- if (!values.prompt && typeof d.prompt === "string") values.prompt = d.prompt;+ // No words: Openjutsu's instruction, with the anchor sentence only when the anchor goes in (the graph's own text names it).+ if (!(typeof values.prompt === "string" && values.prompt.trim())) values.prompt = swapPrompt({ engine: "open", anchor: !!b.image2 && !dropAnchor });}// Genjutsu's Object swap: SAM 3.1 follows what goes (params.extra.maskPrompt, or the "replace … with" part of the prompt,// as Genjutsu sends it), the reference comes in, the prompt describes the result. Insert: the painted spot and thediff --git a/tests/character-swap.test.ts b/tests/character-swap.test.tsindex 382c5f9d..0e9b4950 100644--- a/tests/character-swap.test.ts+++ b/tests/character-swap.test.ts@@ -13,7 +13,7 @@ import {graphLoras,h3Canvas,h3Windows,- H3_NODE_PACKS,+ historyChoicesFor,historyFrames,MINIMAX_H3_LICENCE,packResolution,@@ -24,10 +24,16 @@ import {swapLoraRef,swapPrompt,TURBO_LORA,+ anchorAspect,+ CHARACTER_LORAS,+ partWords,+ toH3Canvas,whoWords,windowFrames,+ windowPlan,+ windowProblem,} from "@/lib/catalog/character-swap";-import { licenceTerms } from "@/lib/licences";+import { licenceInfo, licenceTerms, NODE_PACKS } from "@/lib/licences";// Genjutsu's Character swap (docs/research/openjutsu-6.md): Openjutsu's prompt and limits, H3's windows and canvas,// who to swap, the anchor frame, and the licences as information.@@ -120,7 +126,7 @@ describe("Character swap: limits", () => {expect(falResolution("1080p")).toBe("768P");});- it("H3's windows: 5 s → 1, 7.5 and 10 s → 2, 12.5 and 15 s → 3 (124 frames, padded to 17n+5)", () => {+ it("H3's windows: the pack's plan_windows (5 s → 1, 7.5 and 10 s → 2, 12.5 and 15 s → 3)", () => {expect(alignFrames(120)).toBe(124);expect(alignFrames(240)).toBe(243);expect(alignFrames(360)).toBe(362);@@ -130,8 +136,12 @@ describe("Character swap: limits", () => {expect(h3Windows(12.5)).toBe(3);expect(h3Windows(15)).toBe(3);expect(h3Windows(30)).toBe(6);- // A longer window means fewer.+ // Later windows start on the last frame made: 247 frames (10.29 s) fit two windows of 124, not three.+ expect(h3Windows(247 / 24)).toBe(2);+ expect(h3Windows(248 / 24)).toBe(3);+ // A longer window means fewer; no history means each later window delivers its whole length.expect(h3Windows(15, 362)).toBe(1);+ expect(h3Windows(10.25, 124, 0)).toBe(2);// Window sizes are the pack's combo strings (17n+5 and 0, 1, 17n+1).expect(windowFrames(124)).toBe("124");expect(windowFrames(130)).toBe("124");@@ -141,12 +151,42 @@ describe("Character swap: limits", () => {expect(historyFrames(40)).toBe("35");});- it("H3's canvas and clicks moved into it", () => {- // ComfyUI's adapt_canvas: a 768 short edge, capped at 768 × 1344, each side on the 32 grid.- expect(h3Canvas(1920, 1080, "768p")).toEqual({ width: 1344, height: 768 });- expect(h3Canvas(1080, 1920, "768p")).toEqual({ width: 768, height: 1344 });- expect(h3Canvas(1024, 1024, "768p")).toEqual({ width: 768, height: 768 });- expect(h3Canvas(1280, 720, "480p")).toEqual({ width: 832, height: 480 });+ it("refuses a history as long as the window, as the pack's validate_settings does", () => {+ expect(windowProblem({})).toBeNull();+ expect(windowProblem({ windowFrames: 124, historyFrames: 18 })).toBeNull();+ expect(windowProblem({ windowFrames: 22, historyFrames: 35 })).toBe("History (35 frames) must be shorter than the window (22 frames)");+ expect(windowProblem({ windowFrames: 39, historyFrames: 52 })).toMatch(/must be shorter/);+ expect(historyChoicesFor(22)).toEqual([0, 1, 18]);+ expect(historyChoicesFor(124).at(-1)).toBe(120);+ // The provider's last guard: snapped to the grid, the history comes down below the window.+ expect(windowPlan(22, 35)).toEqual({ window: 22, history: 18 });+ expect(windowPlan(undefined, undefined)).toEqual({ window: 124, history: 18 });+ });++ it("H3's canvas is the pack's canvas_dimensions (0.5 / 1.0 MP budgets on the 32 grid)", () => {+ // Values from the pinned pack's own function (video.py at 0670e4f), run in Python.+ expect(h3Canvas(1920, 1080, "768p")).toEqual({ width: 1344, height: 736 });+ expect(h3Canvas(1080, 1920, "768p")).toEqual({ width: 736, height: 1344 });+ expect(h3Canvas(1024, 1024, "768p")).toEqual({ width: 992, height: 992 });+ expect(h3Canvas(1080, 1080, "768p")).toEqual({ width: 992, height: 992 });+ expect(h3Canvas(1280, 720, "480p")).toEqual({ width: 928, height: 512 });+ expect(h3Canvas(1280, 720, "768p")).toEqual({ width: 1344, height: 736 });+ expect(h3Canvas(720, 1280, "480p")).toEqual({ width: 512, height: 928 });+ // A clip already on the grid and within the budget keeps its size.+ expect(h3Canvas(1024, 576, "768p")).toEqual({ width: 1024, height: 576 });+ expect(h3Canvas(640, 480, "480p")).toEqual({ width: 640, height: 480 });+ });++ it("moves clicks into the prepared frame: scaled to cover, the middle cropped", () => {+ // 1920×1080 at 768: scaled to 1344×756, 10 rows cropped off the top and bottom.+ expect(toH3Canvas({ x: 960, y: 540 }, { width: 1920, height: 1080 }, "768p")).toEqual({ x: 672, y: 368 });+ expect(toH3Canvas({ x: 100, y: 100 }, { width: 1920, height: 1080 }, "768p")).toEqual({ x: 70, y: 60 });+ // A square clip at 768 is 992×992 (not 768×768): a click 80 % across stays 80 % across.+ expect(toH3Canvas({ x: 864, y: 540 }, { width: 1080, height: 1080 }, "768p")).toEqual({ x: 794, y: 496 });+ expect(toH3Canvas({ x: 1024, y: 360 }, { width: 1280, height: 720 }, "480p")).toEqual({ x: 742, y: 256 });+ expect(toH3Canvas({ x: 864, y: 960 }, { width: 1080, height: 1920 }, "768p")).toEqual({ x: 595, y: 672 });+ // In the cropped margin: the nearest edge.+ expect(toH3Canvas({ x: 1079, y: 0 }, { width: 1080, height: 1920 }, "768p")).toEqual({ x: 735, y: 0 });const [pos, neg] = samCoords([{ x: 960, y: 540, label: "positive" },@@ -155,11 +195,32 @@ describe("Character swap: limits", () => {{ width: 1920, height: 1080 },"768p",);- expect(JSON.parse(pos)).toEqual([{ x: 672, y: 384 }]);- expect(JSON.parse(neg)).toEqual([{ x: 70, y: 71 }]);+ expect(JSON.parse(pos)).toEqual([{ x: 672, y: 368 }]);+ expect(JSON.parse(neg)).toEqual([{ x: 70, y: 60 }]);expect(samCoords(undefined, { width: 10, height: 10 }, "768p")).toEqual(["", ""]);});+ it("the first frame keeps the part's shape: auto when the model takes it, else the nearest ratio", () => {+ expect(anchorAspect(["auto", "16:9", "1:1"], { width: 1280, height: 720 })).toBe("auto");+ expect(anchorAspect(["1:1", "4:3", "3:4", "16:9", "9:16"], { width: 1280, height: 720 })).toBe("16:9");+ expect(anchorAspect(["1:1", "4:3", "3:4", "16:9", "9:16"], { width: 1080, height: 1920 })).toBe("9:16");+ expect(anchorAspect(["1:1", "4:3", "3:4", "16:9", "9:16"], { width: 1440, height: 1080 })).toBe("4:3");+ expect(anchorAspect(["1:1", "16:9"], {})).toBeUndefined();+ expect(anchorAspect(undefined, { width: 1, height: 1 })).toBeUndefined();+ });++ it("the part's words from a transcription of the whole clip", () => {+ const cues = [+ { start: 0, end: 2, text: "Before the part." },+ { start: 4.5, end: 6, text: "Hello there," },+ { start: 6, end: 8, text: "how are you?" },+ { start: 12, end: 14, text: "After it." },+ ];+ expect(partWords(cues, { start: 5, end: 10 })).toBe("Hello there, how are you?");+ expect(partWords(cues, { start: 2, end: 4 })).toBe("");+ expect(partWords(undefined, { start: 0, end: 5 })).toBe("");+ });+it("warns about a hard cut inside the part, not at its edges", () => {expect(cutsInPart([1, 7.2, 15], { start: 2, end: 12 })).toEqual([7.2]);expect(cutsInPart([2.1, 11.9], { start: 2, end: 12 })).toEqual([]);@@ -201,8 +262,30 @@ describe("Character swap: licences are information", () => {expect(by["H3 Relay 2.0 node pack"]).toMatchObject({ name: "GPL-3.0" });expect(CHARACTER_LICENCES.find((l) => l.class === "paid-api")?.item).toMatch(/fal/);expect(CHARACTER_LICENCES.every((l) => l.url.startsWith("https://"))).toBe(true);- expect(H3_NODE_PACKS.map((p) => p.name)).toEqual(["h3_character_swap", "h3-relay"]);- expect(H3_NODE_PACKS[0].licence).toMatchObject({ name: "GPL-3.0" });+ });++ it("Settings → Models & licences knows the packs, the LoRAs and the H3 licence by name", () => {+ const packs = NODE_PACKS.filter((p) => p.name === "h3_character_swap" || p.name === "h3-relay");+ expect(packs.map((p) => [p.name, p.licence.name])).toEqual([+ ["h3_character_swap", "GPL-3.0"],+ ["h3-relay", "GPL-3.0"],+ ]);+ expect(packs[0].repo).toContain("/tree/0670e4fdf95adf2262caa4b81afed2a9c4ae4b7b/");+ expect(packs[1].repo).toContain("/tree/e2a7665b6eb8ea37a88c0de2c9c6b69a8f7c9220");+ // The swap LoRA's releases are MiniMax H3 work (restricted regions); Turbo is Apache-2.0.+ expect(CHARACTER_LORAS.map((l) => [l.file, l.licence.class])).toEqual([+ ["h3_character_swap_v1.5.safetensors", "regions"],+ ["h3_character_swap_pro4500_1000.safetensors", "regions"],+ [TURBO_LORA.file, "commercial"],+ ]);+ });++ it("the H3 workflows' licence text reads as the MiniMax H3 Community License, not SAM's", async () => {+ const { default: manifest } = await import("../workflows/comfyui/manifest.json");+ for (const id of ["video-character-swap-h3", "video-character-swap-h3-relay"]) {+ const wf = (manifest as { workflows: { id: string; license?: string }[] }).workflows.find((w) => w.id === id)!;+ expect(licenceInfo(wf.license!)).toMatchObject({ name: "MiniMax H3 Community License", class: "regions", excludes: "the US, the EU, the UK and South Korea", notices: ["MiniMax H3"] });+ }});it("the model picker's line says it, as information", () => {diff --git a/tests/comfy-character-swap.test.ts b/tests/comfy-character-swap.test.tsindex a93c84eb..479ba235 100644--- a/tests/comfy-character-swap.test.ts+++ b/tests/comfy-character-swap.test.ts@@ -2,7 +2,8 @@ import fs from "node:fs";import path from "node:path";import { describe, expect, it } from "vitest";import type { ComfyWorkflow, Manifest } from "@/lib/comfy";-import { H3_NODE_PACKS, H3_WORKFLOWS, SWAP_LORAS, TURBO_LORA } from "@/lib/catalog/character-swap";+import { H3_WORKFLOWS, SWAP_LORAS, TURBO_LORA } from "@/lib/catalog/character-swap";+import { nodePack } from "@/lib/licences";import { getModel } from "@/lib/catalog";// Genjutsu's Character swap in the ComfyUI library (docs/research/openjutsu-6.md): the two MiniMax H3 graphs, their@@ -52,16 +53,20 @@ describe("Character swap's ComfyUI graphs", () => {expect(l).toMatch(/SAM License/);expect(l).toMatch(/GPL-3\.0/);}- expect(H3_NODE_PACKS.map((p) => [p.name, p.licence.name])).toEqual([["h3_character_swap", "GPL-3.0"], ["h3-relay", "GPL-3.0"]]);+ // Settings → Models & licences knows each pack a graph loads (and its licence).+ for (const id of IDS) for (const n of entry(id).customNodes) expect(nodePack(n.name)?.licence.name, n.name).toBe("GPL-3.0");});it("name their node packs, pinned the same in install-comfyui.sh", () => {expect(entry(SWAP).customNodes).toEqual([expect.objectContaining({ name: "h3_character_swap", repo: expect.stringContaining("0670e4fdf95adf2262caa4b81afed2a9c4ae4b7b") })]);- expect(entry(RELAY).customNodes).toEqual([expect.objectContaining({ name: "h3-relay", repo: "https://github.com/akatz-ai/h3-relay" })]);+ expect(entry(RELAY).customNodes).toEqual([expect.objectContaining({ name: "h3-relay", repo: "https://github.com/akatz-ai/h3-relay/tree/e2a7665b6eb8ea37a88c0de2c9c6b69a8f7c9220" })]);expect(install).toContain('H3_TOOL_REF="${H3_TOOL_REF:-0670e4fdf95adf2262caa4b81afed2a9c4ae4b7b}"');expect(install).toContain('H3_RELAY_REF="${H3_RELAY_REF:-e2a7665b6eb8ea37a88c0de2c9c6b69a8f7c9220}"');// The Relay changes the server's routes when it loads: opt-in.expect(install).toMatch(/H3_RELAY:-0\}" = "1"/);+ // A failed fetch warns and the install goes on (set -e): each git step is inside an if.+ expect(install).toMatch(/if git clone -q --filter=blob:none --no-checkout https:\/\/github\.com\/akatz-labs\/h3-character-swap-tool/);+ expect(install).toMatch(/if \[ -d "\$dest\/\.git" \] \|\| git clone -q https:\/\/github\.com\/akatz-ai\/h3-relay "\$dest"; then/);});it("their core nodes are on this server; the pack's are not, so /prompt names one of them", () => {diff --git a/tests/e2e/genjutsu-original.mjs b/tests/e2e/genjutsu-original.mjsindex 9c0fb860..a54a983e 100644--- a/tests/e2e/genjutsu-original.mjs+++ b/tests/e2e/genjutsu-original.mjs@@ -1,8 +1,10 @@// Fuobe Genjutsu on the Originals, browser check (build plan O5 + Openjutsu): /genjutsu runs Fuobe's Originals by// default on both engines, with open weights and partners as labelled alternatives, and a Character swap mode// (MiniMax H3). At 1440 and 390 px, light and dark: the Character swap mode shows who to swap, the quality, the first-// frame switch, the limits and the licence line; the model list badges each model's source; a run is made in demo mode-// and finishes; the open engine allows clicking the person and shows the GPU line; Motion and Restyle list the+// frame switch, the limits and the licence line; Describe my character and the clip's words; the swap LoRA's choices+// per engine; partners' resolutions; the model list badges each model's source; a run is made in demo mode and+// finishes; the open engine allows clicking the person, shows the GPU line, SAM's detection numbers, the History list+// under the window and the mask switch on the Original's graph only; Motion and Restyle list the// Originals first and Restyle has Soul looks; no Higgsfield anywhere; nothing scrolls sideways.// Usage: node tests/e2e/genjutsu-original.mjs [appUrl] [--shots <dir>] (app running in demo mode, ComfyUI unreachable).// Exits 1 on a failed check.@@ -79,6 +81,36 @@ try {check(`${tag}: the limits are shown`, /One continuous shot: a hard cut breaks the swap/.test(body) && /The person must be visible in the part's first frame/.test(body));check(`${tag}: no Higgsfield anywhere`, !/higgsfield/i.test(body));check(`${tag}: no sideways scroll (Character swap)`, (await sideways()) <= 1, `${await sideways()} px`);+ // Describe my character (no text model in demo mode: said in words); the clip's words fill "What's said".+ const describe = page.getByRole("button", { name: "Describe my character" });+ check(`${tag}: "Describe my character" is offered with the picture in`, (await describe.count()) === 1 && !(await describe.isDisabled()));+ await describe.click();+ check(+ `${tag}: describing without a text model says so`,+ await page+ .getByText(/Describing needs a text model/)+ .first()+ .waitFor({ timeout: 20_000 })+ .then(() => true)+ .catch(() => false),+ );+ await page.getByText("Advanced").first().click();+ const loras = (await page.getByRole("radiogroup", { name: "Swap LoRA" }).getByRole("radio").allInnerTexts()).join("|");+ check(`${tag}: cloud: the swap LoRA is V1.5 or V1 (fal's route needs one)`, loras === "V1.5|V1", loras);+ await page.getByRole("button", { name: "Use the clip's words" }).click();+ const said = page.locator("#gj-dialogue");+ const filled = await page+ .waitForFunction(() => /demo transcript/.test(document.querySelector("#gj-dialogue")?.value ?? ""), null, { timeout: 60_000 })+ .then(() => true)+ .catch(() => false);+ check(`${tag}: "Use the clip's words" fills What's said with the part's lines`, filled, JSON.stringify((await said.inputValue()).slice(0, 60)));+ // A partner in Character swap takes Genjutsu's resolutions (Recast renders 768p or 1080p).+ await models.getByRole("radio", { name: /H3 Max Recast/ }).click();+ await page.waitForTimeout(300);+ const res = (await page.getByRole("radiogroup", { name: "Resolution" }).getByRole("radio").allInnerTexts()).join("|");+ check(`${tag}: partners: the resolutions to pick from (1080p for Recast)`, res === "480p|720p|1080p", res);+ await models.getByRole("radio").first().click();+ await page.waitForTimeout(300);await shot("genjutsu-character-cloud");// A demo run: the steps run through and the result comes back.@@ -100,8 +132,28 @@ try {const openBody = await text();check(`${tag}: open: the GPU it was tested on`, /Tested by its authors on a 96 GB RTX PRO 6000/.test(openBody));check(`${tag}: open: the H3 Relay is an open alternative`, /H3 Relay/.test(openBody));- await page.getByText("Advanced").first().click();+ // Advanced is still open from the cloud: on your GPU "None" is a choice, and the mask switch is the Original's.+ if (!(await page.getByRole("radiogroup", { name: "Swap LoRA" }).isVisible().catch(() => false))) await page.getByText("Advanced").first().click();check(`${tag}: open: Advanced has the LoRA release and the window`, (await page.getByRole("radiogroup", { name: "Swap LoRA" }).count()) === 1 && (await page.getByText("Window", { exact: true }).count()) >= 1);+ check(`${tag}: open: no swap LoRA is a choice on your GPU`, (await page.getByRole("radiogroup", { name: "Swap LoRA" }).getByRole("radio", { name: "None" }).count()) === 1);+ check(`${tag}: open: Masked generation on the Original's graph`, (await page.getByRole("switch", { name: "Masked generation" }).count()) === 1);+ await page.getByRole("radiogroup", { name: "Who to swap" }).getByRole("radio", { name: "Person #" }).click();+ check(`${tag}: open: person numbers are SAM's detections, said so`, (await page.getByText("Detection number", { exact: true }).count()) === 1 && /not left to right/.test(await text()));+ // The History list stops below the window (the pack refuses a history as long as it).+ await page.locator("#gj-window").click();+ await page.getByRole("option", { name: "22 frames" }).click();+ await page.locator("#gj-history").click();+ const histories = (await page.getByRole("option").allInnerTexts()).join("|");+ await page.keyboard.press("Escape");+ check(`${tag}: open: History under a 22-frame window is 0, 1 or 18`, histories === "0 frames|1 frames|18 frames", histories);+ await page.locator("#gj-window").click();+ await page.getByRole("option", { name: "124 frames" }).click();+ // H3 Relay has no switch for the whole frame.+ await page.getByRole("radiogroup", { name: "Model", exact: true }).getByRole("radio", { name: /H3 Relay/ }).click();+ await page.waitForTimeout(300);+ check(`${tag}: open: the Relay graph has no mask switch`, (await page.getByRole("switch", { name: "Masked generation" }).count()) === 0);+ await page.getByRole("radiogroup", { name: "Model", exact: true }).getByRole("radio").first().click();+ await page.getByRole("radiogroup", { name: "Who to swap" }).getByRole("radio", { name: "Largest" }).click();check(`${tag}: no sideways scroll (open)`, (await sideways()) <= 1, `${await sideways()} px`);await shot("genjutsu-character-open");diff --git a/tests/genjutsu-api.test.ts b/tests/genjutsu-api.test.tsindex 786b8306..89938ba4 100644--- a/tests/genjutsu-api.test.ts+++ b/tests/genjutsu-api.test.ts@@ -2,6 +2,8 @@ import fs from "node:fs";import os from "node:os";import path from "node:path";import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";+import http from "node:http";+import { CLOUD_NO_LORA } from "@/lib/catalog/character-swap";import { CLOUD_CLICK_PROBLEM } from "@/lib/catalog/genjutsu";import type { Generation } from "@/lib/catalog/types";@@ -21,6 +23,9 @@ const { encodePng } = await import("@/server/png");const { db } = await import("@/server/db");const createRoute = await import("@/app/api/genjutsu/route");const estimateRoute = await import("@/app/api/genjutsu/estimate/route");+const describeRoute = await import("@/app/api/genjutsu/describe/route");+const transcribeRoute = await import("@/app/api/genjutsu/transcribe/route");+const { changeAccess } = await import("@/server/model-access");const json = (body?: unknown) => new Request("http://x/api", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) });@@ -132,7 +137,7 @@ describe("Genjutsu: estimates", () => {it("Character swap on the open engine: free on your GPU, the windows, the GPU it was tested on and the licences", async () => {const e = await (await estimateRoute.POST(json(body({ engine: "open", mode: "character", source: { url: clip, ...src }, range: { start: 2, end: 9 } })))).json();expect(e).toMatchObject({ modelId: "fuobe-character-swap", source: "original", costUsd: 0, anchors: 1, gpu: { weightsGb: 46.33 } });- expect(e.notes.join(" ")).toMatch(/2 windows of 124 frames at 24 fps/);+ expect(e.notes.join(" ")).toMatch(/2 windows of up to 124 frames at 24 fps, each continuing from the 18 frames before it/);expect(e.notes.join(" ")).toMatch(/nodes GPL-3\.0 · SAM License/);expect(e.notes.join(" ")).toMatch(/Qwen-Image-Edit 2511 first puts your character into the part's first frame/);});@@ -184,12 +189,110 @@ describe("Genjutsu: estimates", () => {expect(await say(body({ mode: "character", source: { url: clip, ...src }, range: { start: 0, end: 4.5 } }))).toMatch(/Pick a part of 5–15 seconds/);expect(await say(body({ mode: "character", target: "click", source: { url: clip, ...src }, range: { start: 0, end: 6 } }))).toBe(CLOUD_CLICK_PROBLEM);expect(await say(body({ engine: "open", mode: "character", target: "click", source: { url: clip, ...src }, range: { start: 0, end: 6 } }))).toBe("Click the person to swap on the first frame");+ // fal's H3 route needs a swap LoRA; the pack refuses a history as long as the window.+ expect(await say(body({ mode: "character", source: { url: clip, ...src }, range: { start: 0, end: 6 }, character: { lora: "none" } }))).toBe(CLOUD_NO_LORA);+ expect(await say(body({ engine: "open", mode: "character", source: { url: clip, ...src }, range: { start: 0, end: 6 }, character: { windowFrames: 22, historyFrames: 35 } }))).toBe(+ "History (35 frames) must be shorter than the window (22 frames)",+ );setSetting("engineMode", "open");expect(await say(body({ source: { url: clip, ...src } }))).toMatch(/open-source models only/);setSetting("engineMode", "both");});});+describe("Character swap and Settings → Models & licences", () => {+ afterAll(() => changeAccess([{ kind: "reset" }]));+ const estimate = async (b: Record<string, unknown>) => {+ const res = await estimateRoute.POST(json(body({ mode: "character", source: { url: clip, ...src }, range: { start: 0, end: 6 }, ...b })));+ const out = await res.json();+ return { status: res.status, ...out } as { status: number; error?: string; notes: string[]; anchors?: number };+ };++ it("a first-frame model switched off gives way to the next one that is on, else no first frame", async () => {+ changeAccess([{ kind: "model", id: "gpt-image-2-5-sunburst", on: false }]);+ const next = await estimate({});+ expect(next.status).toBe(200);+ expect(next.notes).toContain("GPT Image 2.5 Sunburst is switched off in Settings → Models & licences: Nano Banana Pro makes the first frame");+ expect(next.anchors).toBe(1);+ changeAccess([{ kind: "model", id: "nano-banana-pro", on: false }]);+ const none = await estimate({});+ expect(none.notes).toContain("The first-frame models are switched off in Settings → Models & licences: the swap runs without a first frame");+ expect(none.anchors).toBe(0);+ changeAccess([{ kind: "reset" }]);+ });++ it("the swap LoRA switched off: H3 alone on your GPU; refused on fal, which needs one", async () => {+ changeAccess([{ kind: "lora", id: "h3_character_swap_v1.5.safetensors", on: false }]);+ const open = await estimate({ engine: "open" });+ expect(open.status).toBe(200);+ expect(open.notes).toContain("The swap LoRA is switched off in Settings → Models & licences: H3 runs with the Turbo LoRA alone");+ const cloud = await estimate({});+ expect(cloud.status).toBe(422);+ expect(cloud.error).toMatch(/V1\.5 \(recommended\)\) is switched off in Settings → Models & licences, and fal's H3 route needs one/);+ // The other release is on: picking it runs.+ expect((await estimate({ character: { lora: "v1" } })).status).toBe(200);+ changeAccess([{ kind: "lora", id: "minimax_h3_fl2v_turbo_8step_v1.0_768p_comfyui_bf16.safetensors", on: false }]);+ expect((await estimate({ engine: "open", character: { lora: "v1" } })).error).toMatch(/Turbo LoRA is switched off/);+ changeAccess([{ kind: "reset" }]);+ });+});++describe("Character swap helpers: Describe my character and the clip's words", () => {+ let server: http.Server;+ let seen: { images?: string[]; system?: string } = {};+ beforeAll(async () => {+ // A stand-in Ollama with a vision model: it answers /api/chat with a description.+ server = http.createServer((req, res) => {+ let raw = "";+ req.on("data", (c) => (raw += c));+ req.on("end", () => {+ const b = JSON.parse(raw || "{}") as { messages?: { role: string; content: string; images?: string[] }[] };+ seen = { images: b.messages?.find((m) => m.role === "user")?.images, system: b.messages?.find((m) => m.role === "system")?.content };+ res.setHeader("Content-Type", "application/json");+ res.end(JSON.stringify({ message: { content: '"A tall knight in silver armour with a red cape."' } }));+ });+ });+ await new Promise<void>((r) => server.listen(0, "127.0.0.1", () => r()));+ setSetting("ollamaUrl", `http://127.0.0.1:${(server.address() as { port: number }).port}`);+ });+ afterAll(async () => {+ setSetting("ollamaUrl", "http://127.0.0.1:9");+ await new Promise((r) => server.close(r));+ });++ it("describes the character from their picture with the engine's text model (Ollama sees the picture)", async () => {+ const res = await describeRoute.POST(json({ engine: "open", image: hero }));+ expect(res.status).toBe(200);+ expect(await res.json()).toEqual({ description: "A tall knight in silver armour with a red cape" });+ expect(seen.images).toHaveLength(1);+ expect(seen.system).toMatch(/who they are and what they wear/);+ });++ it("says why it can't: demo mode, a switched-off text model, a picture that isn't one", async () => {+ setSetting("demoMode", "on");+ expect(await (await describeRoute.POST(json({ engine: "cloud", image: hero }))).json()).toMatchObject({ error: expect.stringMatching(/needs a text model/) });+ setSetting("demoMode", "auto");+ changeAccess([{ kind: "model", id: "oss-text-llm", on: false }]);+ expect(await (await describeRoute.POST(json({ engine: "open", image: hero }))).json()).toMatchObject({ error: expect.stringMatching(/text model is switched off/) });+ changeAccess([{ kind: "reset" }]);+ expect((await describeRoute.POST(json({ engine: "open", image: clip }))).status).toBe(422);+ expect((await describeRoute.POST(json({ engine: "open", image: "https://example.com/x.png" }))).status).toBe(400);+ });++ it("transcribes the clip once, as a Genjutsu step, on the engine's transcriber (timed lines for any part)", async () => {+ const res = await transcribeRoute.POST(json({ engine: "cloud", source: { url: clip, duration: 12 } }));+ expect(res.status).toBe(201);+ const out = (await res.json()) as { id: string; modelId: string };+ expect(out.modelId).toBe("scribe-v2");+ const g = await settle(out.id);+ expect(g).toMatchObject({ status: "succeeded", feature: "genjutsu-step", modelId: "scribe-v2" });+ const text = g.outputs.find((o) => o.kind === "text")!;+ expect(Array.isArray(text.meta?.cues)).toBe(true);+ const open = (await (await transcribeRoute.POST(json({ engine: "open", source: { url: clip } }))).json()) as { modelId: string };+ expect(open.modelId).toBe("oss-qwen3-asr");+ });+});+describe("Genjutsu: runs (demo)", () => {const run = async (b: Record<string, unknown>) => {const res = await createRoute.POST(json(b));@@ -266,6 +369,19 @@ describe("Genjutsu: runs (demo)", () => {expect(swap.request.inputs?.images).toEqual([hero, anchor.outputs[0].url]);});+ it("Character swap on fal of a silent clip: silent too (H3's own soundtrack replaced with the clip's silence)", async () => {+ const silent = saveFile({ data: fs.readFileSync(path.join(__dirname, "fixtures/shorts-silent.webm")), contentType: "video/webm", source: "upload", name: "silent.webm" }).url;+ const { final } = await run(body({ mode: "character", source: { url: silent, name: "silent.webm" }, range: { start: 0, end: 5 }, character: { anchor: false } }));+ expect(final).toMatchObject({ modelId: "merge-audio-video", op: "mux", feature: "genjutsu" });+ // The silent track is a real WAV the run wrote, as long as the part.+ const audio = final.request.inputs?.audio ?? "";+ expect(audio).toMatch(/^\/api\/files\//);+ expect((await settle(final.id)).status).toBe("succeeded");+ const rows = batchOf(final.id);+ expect(rows.map((r) => `${r.model_id}:${r.op}`)).toEqual(expect.arrayContaining(["fuobe-character-swap:video-swap", "merge-audio-video:mux"]));+ expect(rows.filter((r) => r.feature === "genjutsu")).toHaveLength(1);+ });+it("Character swap on the open engine: the first frame, the anchor on Qwen-Image-Edit, one H3 job on the upload", async () => {const { final } = await run(body({ engine: "open", mode: "character", range: { start: 2, end: 9 }, character: { who: "index", index: 1, subject: "the drummer", lora: "v1" } }));const rows = batchOf(final.id);diff --git a/tests/genjutsu-comfy.test.ts b/tests/genjutsu-comfy.test.tsindex 1da6f880..9122e115 100644--- a/tests/genjutsu-comfy.test.ts+++ b/tests/genjutsu-comfy.test.ts@@ -120,16 +120,30 @@ describe("Character swap's open graphs through the provider (MiniMax H3)", () =>expect(at(wf, "801", "audio_guide")).toBe(false);});- it("clicks are moved into H3's canvas for SAM 3.1 (positive and negative)", async () => {- const wf = await h3({ images: ["hero.png"], startTime: 0, endTime: 6, resolution: "768p", points: [{ x: 640, y: 360, label: "positive" }, { x: 10, y: 10, label: "negative" }] });- // 1280×720 → 1344×768 at 768p: the clip's middle stays the canvas's middle.- expect(JSON.parse(String(at(wf, "103", "positive_coords")))).toEqual([{ x: 672, y: 384 }]);- expect(JSON.parse(String(at(wf, "103", "negative_coords")))).toHaveLength(1);+ it("clicks are moved into the pack's prepared frame for SAM 3.1, and the clicked mask is the one taken", async () => {+ const wf = await h3({ images: ["hero.png"], startTime: 0, endTime: 6, resolution: "768p", points: [{ x: 640, y: 360, label: "positive" }, { x: 20, y: 20, label: "negative" }], extra: { selection: "largest", subjectIndex: 0 } });+ // 1280×720 at "768": the pack's canvas is 1344×736 (scaled to 1344×756, 10 rows cropped top and bottom).+ expect(JSON.parse(String(at(wf, "103", "positive_coords")))).toEqual([{ x: 672, y: 368 }]);+ expect(JSON.parse(String(at(wf, "103", "negative_coords")))).toEqual([{ x: 21, y: 11 }]);+ // SAM3_Detect returns the point mask first, then the "person" detections: SelectSubject takes index 0, not "largest".+ expect([at(wf, "104", "selection"), at(wf, "104", "index")]).toEqual(["index", 0]);+ const relayWf = await relay({ images: ["hero.png"], startTime: 0, endTime: 6, resolution: "480p", points: [{ x: 1024, y: 360 }] });+ // 1280×720 at "480": 928×512 (scaled to 928×522).+ expect(JSON.parse(String(at(relayWf, "detect", "positive_coords")))).toEqual([{ x: 742, y: 256 }]);+ expect([at(relayWf, "select", "selection"), at(relayWf, "select", "index")]).toEqual(["index", 0]);+ // Without clicks, the choice made stays.+ const words = await h3({ images: ["hero.png"], startTime: 0, endTime: 6, extra: { selection: "largest" } });+ expect([at(words, "103", "positive_coords"), at(words, "104", "selection")]).toEqual(["", "largest"]);});it("the window plan as the pack's choices, and the LoRA's release (v1, or none: the Turbo LoRA alone)", async () => {const wf = await h3({ images: ["hero.png"], startTime: 0, endTime: 6, extra: { windowFrames: 120, historyFrames: 20, lora: "v1" } });expect([at(wf, "805", "window_frames"), at(wf, "805", "history_frames")]).toEqual(["124", "18"]);+ // A history as long as the window would stop the pack's WindowPlan: it comes down below the window.+ const short = await h3({ images: ["hero.png"], startTime: 0, endTime: 6, extra: { windowFrames: 22, historyFrames: 35 } });+ expect([at(short, "805", "window_frames"), at(short, "805", "history_frames")]).toEqual(["22", "18"]);+ const onlyHistory = await relay({ images: ["hero.png"], startTime: 0, endTime: 6, extra: { historyFrames: 137 } });+ expect([at(onlyHistory, "plan", "window_frames"), at(onlyHistory, "plan", "history_frames")]).toEqual(["124", "120"]);expect(at(wf, "850", "lora_name")).toBe("h3_character_swap_pro4500_1000.safetensors");const bare = await h3({ images: ["hero.png"], startTime: 0, endTime: 6, extra: { lora: "none" } });expect(bare["850"]).toBeUndefined();@@ -147,6 +161,12 @@ describe("Character swap's open graphs through the provider (MiniMax H3)", () =>const ids = new Set(Object.keys(wf));for (const n of Object.values(wf)) for (const v of Object.values(n.inputs)) if (Array.isArray(v) && typeof v[0] === "string") expect(ids.has(v[0])).toBe(true);expect(withoutAnchor({ a: { class_type: "LoadImage", inputs: { image: "x" } }, b: { class_type: "Shot", inputs: { anchor: ["a", 0], use_anchor: true } } }, "a")).toEqual({ b: { class_type: "Shot", inputs: { use_anchor: false } } });+ // No words given: Openjutsu's instruction without the anchor sentence (the graph's own text names <Picture 2>).+ expect(at(wf, "801", "prompt")).toBe("Replace the selected person in <Video 1> with the character in <Picture 1>. Preserve the source performance, scene and audio timing.");+ const anchored = await h3({ images: ["hero.png", "anchor.png"], startTime: 0, endTime: 6 });+ expect(at(anchored, "801", "prompt")).toMatch(/Start from the first frame in <Picture 2>\.$/);+ const relayed = await relay({ images: ["hero.png"], startTime: 0, endTime: 6 });+ expect(at(relayed, "reference_conditioning", "prompt")).not.toMatch(/Picture 2/);});it("H3 Relay: the same part, quality, words, seed and who, on Akatz's relay graph", async () => {diff --git a/tests/genjutsu.test.ts b/tests/genjutsu.test.tsindex 95b94c5d..2eb2d01a 100644--- a/tests/genjutsu.test.ts+++ b/tests/genjutsu.test.ts@@ -24,7 +24,8 @@ import {type GenjutsuPlanInput,type Maker,} from "@/lib/catalog/genjutsu";-import { ANCHOR_FALLBACK } from "@/lib/catalog/character-swap";+import { ANCHOR_FALLBACK, CLOUD_NO_LORA } from "@/lib/catalog/character-swap";+import { buildPayload } from "@/lib/catalog/payload";import { estimateCost, planGeneration } from "@/lib/catalog/plan";import { getModel, getPreset } from "@/lib/catalog";import { onEngine } from "@/lib/catalog/engines";@@ -335,6 +336,69 @@ describe("Genjutsu: Character swap", () => {expect(step(p, "join").after).toEqual(["swap0", "swap1"]);});+ it("open: a click selects the clicked person (SAM 3.1's point mask, first among its detections)", () => {+ const p = ch({ maker: maker(ORIGINALS.character, "open"), target: "click", character: { who: "largest" }, points: [{ x: 900, y: 300, label: "positive" }] });+ expect(step(p, "swap").request.params?.extra).toMatchObject({ selection: "index", subjectIndex: 0 });+ const relay = ch({ maker: maker("oss-h3-character-swap-relay", "open"), target: "click", points: [{ x: 900, y: 300, label: "positive" }] });+ expect(step(relay, "swap").request.params?.extra).toMatchObject({ selection: "index", subjectIndex: 0 });+ // Without clicks, who you picked stays.+ expect(step(ch({ maker: maker(ORIGINALS.character, "open"), character: { who: "rightmost" } }), "swap").request.params?.extra).toMatchObject({ selection: "rightmost" });+ });++ it("cloud: the first frame keeps the part's shape (Sunburst's nearest size, Nano Banana Pro's auto), not the square default", () => {+ const wide = ch({ maker: maker(ORIGINALS.character) });+ const sunburst = step(wide, "anchor0").request;+ expect(sunburst.params).toMatchObject({ aspectRatio: "16:9" });+ const route = onEngine(getModel("gpt-image-2-5-sunburst")!, "cloud").routes.find((r) => r.op === "edit")!;+ expect(buildPayload(route.map!, { prompt: sunburst.prompt, images: [ref, ref], aspectRatio: "16:9", extra: { quality: "low" } })).toMatchObject({ image_size: "landscape_16_9", quality: "low" });+ const tall = ch({ maker: maker(ORIGINALS.character), source: { ...clip, width: 1080, height: 1920 } });+ expect(step(tall, "anchor0").request.params).toMatchObject({ aspectRatio: "9:16" });+ const nano = ch({ maker: maker(ORIGINALS.character), character: { anchorModel: "nano-banana-pro" } });+ expect(step(nano, "anchor0").request.params).toMatchObject({ aspectRatio: "auto" });+ const nanoRoute = onEngine(getModel("nano-banana-pro")!, "cloud").routes.find((r) => r.op === "edit" && r.provider === "fal")!;+ expect(buildPayload(nanoRoute.map!, { prompt: "p", images: [ref, ref], aspectRatio: "auto" })).toMatchObject({ aspect_ratio: "auto" });+ // Through the catalog the ratio stays (no square default merged over it).+ const planned = planGeneration({ ...sunburst, inputs: { images: ["/api/files/f.png", ref] } }, getModel, getPreset);+ expect(planned.params.aspectRatio).toBe("16:9");+ // The open first frame is Qwen-Image-Edit's own size (the graph fits it to the clip): no ratio is asked.+ expect(step(ch({ maker: maker(ORIGINALS.character, "open") }), "anchor").request.params?.aspectRatio).toBeUndefined();+ });++ it("cloud: a silent clip's result is silent too (H3's own soundtrack is replaced with silence)", () => {+ const p = ch({ maker: maker(ORIGINALS.character), source: { ...clip, hasAudio: false }, range: { start: 2, end: 9.4 } });+ expect(p.steps.map((s) => s.key)).toEqual(["cut0", "frame0", "anchor0", "swap0", "fit0", "mute"]);+ expect(step(p, "fit0").request.feature).toBe("genjutsu-step");+ expect(step(p, "mute").request).toMatchObject({ op: "mux", modelId: "merge-audio-video", feature: "genjutsu", inputs: { audio: "silence:7.4" } });+ expect(step(p, "mute").after).toEqual(["fit0"]);+ expect(p.final).toBe("mute");+ const pieces = ch({ maker: maker(ORIGINALS.character), source: { ...clip, hasAudio: false }, range: { start: 0, end: 20 } });+ expect(step(pieces, "join").request.feature).toBe("genjutsu-step");+ expect(step(pieces, "mute").after).toEqual(["join"]);+ });++ it("cloud: fal's route needs a swap LoRA, so \"None\" is refused there (it runs on your GPU)", () => {+ expect(() => ch({ maker: maker(ORIGINALS.character), character: { lora: "none" } })).toThrow(CLOUD_NO_LORA);+ const check = { mode: "character" as const, source: clip, range: { start: 2, end: 12 }, references: 1 };+ expect(genjutsuProblem({ ...check, maker: maker(ORIGINALS.character), character: { lora: "none" } })).toBe(CLOUD_NO_LORA);+ expect(genjutsuProblem({ ...check, maker: maker(ORIGINALS.character, "open"), character: { lora: "none" } })).toBeNull();+ expect(step(ch({ maker: maker(ORIGINALS.character, "open"), character: { lora: "none" } }), "swap").request.params?.extra).toMatchObject({ lora: "none" });+ // The window plan the pack would refuse is said before anything runs.+ expect(genjutsuProblem({ ...check, maker: maker(ORIGINALS.character, "open"), character: { windowFrames: 22, historyFrames: 35 } })).toMatch(/must be shorter than the window/);+ });++ it("Settings → Models & licences: a switched-off tier gives way to the other; an entry stays while either is on", () => {+ const off = (ids: string[]) => (id: string) => !ids.includes(id);+ // Lite off, the full Original on: the Original stays the pick (High), not a partner.+ expect(chooseMaker({ engine: "cloud", mode: "motion", offered: off([ORIGINALS.motionLite]) })).toMatchObject({ maker: { id: ORIGINALS.motion } });+ expect(chooseMaker({ engine: "cloud", mode: "motion", tier: "standard", offered: off([ORIGINALS.motionLite]) })).toMatchObject({ maker: { id: ORIGINALS.motion } });+ expect(chooseMaker({ engine: "cloud", mode: "motion", modelId: ORIGINALS.motionLite, offered: off([ORIGINALS.motionLite]) })).toMatchObject({ maker: { id: ORIGINALS.motion } });+ // The full Original off: High falls back to Lite.+ expect(chooseMaker({ engine: "cloud", mode: "motion", tier: "high", offered: off([ORIGINALS.motion]) })).toMatchObject({ maker: { id: ORIGINALS.motionLite } });+ // Both off: the next model that is on.+ const both = chooseMaker({ engine: "cloud", mode: "motion", offered: off([ORIGINALS.motion, ORIGINALS.motionLite]) });+ expect("maker" in both && both.maker.source).not.toBe("original");+ });+it("partners in Character swap: MiniMax's Recast, Wan Animate Replace, Kling O3 with who in words", () => {const r = ch({ maker: maker("h3-max-recast"), range: { start: 2, end: 20 }, quality: "1080p", character: { who: "leftmost", description: "a ronin" } });expect(r.steps.map((s) => s.key)).toEqual(["cut0", "make0"]);@@ -392,6 +456,7 @@ describe("Genjutsu: the steps plan as catalog generations", () => {plan({ mode: "character", maker: maker("h3-max-recast"), range: { start: 0, end: 12 } }),plan({ mode: "character", maker: maker("scail-2"), range: { start: 0, end: 8 } }),plan({ mode: "character", maker: maker("oss-h3-character-swap-relay", "open"), range: { start: 0, end: 8 } }),+ plan({ mode: "character", maker: maker(ORIGINALS.character), source: { ...clip, hasAudio: false }, range: { start: 0, end: 20 }, character: { anchorModel: "nano-banana-pro" } }),];for (const p of plans) {for (const s of p.steps) {diff --git a/tests/model-access-listings.test.ts b/tests/model-access-listings.test.tsindex 431e073c..17081828 100644--- a/tests/model-access-listings.test.ts+++ b/tests/model-access-listings.test.ts@@ -94,8 +94,11 @@ describe("Models & licences in listings and picks", () => {it("lists every model, LoRA and node pack with its licence, and flips switches through the settings API", async () => {const list = (await (await settingsRoute.GET()).json()) as import("@/lib/model-access").AccessList;expect(list.models.length).toBeGreaterThan(300);- // The library's 114 LoRAs and the preset LoRA map's files that aren't library files, each once.- expect(list.loras.length).toBe(166);+ // The library's 114 LoRAs, the preset LoRA map's files that aren't library files, and the Character swap's three+ // (Akatz Labs' swap LoRA V1.5 and V1, lightx2v's H3 Turbo), each once.+ expect(list.loras.length).toBe(169);+ expect(list.loras.find((l) => l.file === "h3_character_swap_v1.5.safetensors")).toMatchObject({ group: "adapter", base: "MiniMax H3", on: true, licence: { name: "MiniMax H3 Community License", class: "regions" } });+ expect(list.packs.find((p) => p.name === "h3_character_swap")).toMatchObject({ licence: { name: "GPL-3.0" }, on: true });expect(new Set(list.loras.map((l) => l.file)).size).toBe(list.loras.length);expect(list.loras.find((l) => l.file === "crane_up.safetensors")).toMatchObject({name: "Crane up",diff --git a/workflows/comfyui/manifest.json b/workflows/comfyui/manifest.jsonindex f1ec5b98..6b036be7 100644--- a/workflows/comfyui/manifest.json+++ b/workflows/comfyui/manifest.json@@ -1,6 +1,6 @@{"version": 1,- "generatedAt": "2026-10-27T04:10:33.286Z",+ "generatedAt": "2026-10-27T09:15:03.709Z","comfyuiCommit": "fc04da91b2ab12f99e4716371a7e4f98ac982597","comfyuiVersion": "0.41.0","workflowTemplatesVersion": "0.11.86",@@ -13476,7 +13476,7 @@"customNodes": [{"name": "h3-relay",- "repo": "https://github.com/akatz-ai/h3-relay"+ "repo": "https://github.com/akatz-ai/h3-relay/tree/e2a7665b6eb8ea37a88c0de2c9c6b69a8f7c9220"}],"vramGb": 24,