The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(create): K2 vollstaendig, kein Loader-Wert mehr als Literal
purple060f167dafc9
diff --git a/src/api/__tests__/framepack-vae.test.ts b/src/api/__tests__/framepack-vae.test.tsindex d73c35d9..b73f9fae 100644--- a/src/api/__tests__/framepack-vae.test.ts+++ b/src/api/__tests__/framepack-vae.test.ts@@ -60,13 +60,16 @@ const params = {function vaeEnum(list: string[]) {vi.mocked(localFetch).mockResolvedValue({ok: true,- // K2: findMatchingClipVision() now also probes /object_info/CLIPVisionLoader- // (same live-list-first fix as the VAE above, for FramePack's clip_vision- // encoder). The mock answers every /object_info/<node> call with the same- // body regardless of which node was asked for, so it needs both keys.+ // K2: findMatchingClipVision() probes /object_info/CLIPVisionLoader and+ // findFramePackCLIPPair (Punkt 2 of the nachbessert list) probes+ // /object_info/CLIPLoader for the text_encoders folder listing, same+ // live-list-first fix as the VAE above, just for FramePack's other two+ // loader nodes. The mock answers every /object_info/<node> call with the+ // same body regardless of which node was asked for, so it needs all keys.json: async () => ({VAELoader: { input: { required: { vae_name: [list] } } },CLIPVisionLoader: { input: { required: { clip_name: [['sigclip_vision_patch14_384.safetensors']] } } },+ CLIPLoader: { input: { required: { clip_name: [['clip_l.safetensors', 'llava_llama3_fp8_scaled.safetensors']] } } },}),} as never)}@@ -138,4 +141,36 @@ describe('the built FramePack graph', () => {vaeEnum([VAE_15])await expect(buildDynamicWorkflow(params as never)).rejects.toThrow(/No FramePack VAE found.*hunyuan_video_vae_bf16/s)})++ // K2 nachbessert (Punkt 2): DualCLIPLoader's clip_name1/clip_name2 used to+ // be hardcoded literals ('clip_l.safetensors' / 'llava_llama3_fp8_scaled.+ // safetensors') REGARDLESS of the live CLIP enum. This mock answers with+ // DIFFERENT filenames (a plausible post-3.0 folder rename), so the test+ // only passes if the values genuinely came from findFramePackCLIPPair.+ it('DualCLIPLoader uses whatever the live CLIP enum actually names, not the historic literal filenames', async () => {+ vi.mocked(localFetch).mockResolvedValue({+ ok: true,+ json: async () => ({+ VAELoader: { input: { required: { vae_name: [BOTH_VAES] } } },+ CLIPVisionLoader: { input: { required: { clip_name: [['sigclip_vision_patch14_384.safetensors']] } } },+ CLIPLoader: { input: { required: { clip_name: [['text_encoders/clip_l.safetensors', 'text_encoders/llava_llama3_fp8_scaled.safetensors']] } } },+ }),+ } as never)+ const wf = await buildDynamicWorkflow(params as never)+ const [, dualClip] = Object.entries(wf).find(([, v]) => v.class_type === 'DualCLIPLoader')!+ expect(dualClip.inputs?.clip_name1).toBe('text_encoders/clip_l.safetensors')+ expect(dualClip.inputs?.clip_name2).toBe('text_encoders/llava_llama3_fp8_scaled.safetensors')+ })++ it('a disk missing the llava_llama3 encoder fails with the download hint, not a ComfyUI 400', async () => {+ vi.mocked(localFetch).mockResolvedValue({+ ok: true,+ json: async () => ({+ VAELoader: { input: { required: { vae_name: [BOTH_VAES] } } },+ CLIPVisionLoader: { input: { required: { clip_name: [['sigclip_vision_patch14_384.safetensors']] } } },+ CLIPLoader: { input: { required: { clip_name: [['clip_l.safetensors']] } } },+ }),+ } as never)+ await expect(buildDynamicWorkflow(params as never)).rejects.toThrow(/No FramePack llava_llama3 text encoder found/)+ })})diff --git a/src/api/__tests__/no-hardcoded-loader-names-k2.test.ts b/src/api/__tests__/no-hardcoded-loader-names-k2.test.tsnew file mode 100644index 00000000..3800a60e--- /dev/null+++ b/src/api/__tests__/no-hardcoded-loader-names-k2.test.ts@@ -0,0 +1,112 @@+/**+ * K2 nachbessert (review-create.md): "K2 ist erst fertig, wenn KEIN+ * Workflow-Bauer mehr einen Loader-Wert als Literal einsetzt." Punkt 1+ * (buildWan22Workflow) and Punkt 2 (FramePack's DualCLIPLoader) closed the+ * two gaps the review found; this is the systematic check the coordinator+ * asked for on top: grep every workflow-building source file under src/api+ * for a ComfyUI loader node's `*_name` input written as a string literal,+ * so a future builder (or a regression in an existing one) that reintroduces+ * a hardcoded loader value fails a test instead of shipping a "Value not in+ * list" the customer hits.+ *+ * Only fields that name a FILE ON DISK a loader resolves are checked+ * (ckpt_name, unet_name, vae_name, clip_name/clip_name1/clip_name2,+ * lora_name, audio_encoder_name, clip_vision_name, controlnet_name,+ * upscale_model_name, style_model_name, embedding_name, model_name).+ * `sampler_name` is deliberately excluded: it names a SAMPLING ALGORITHM+ * ('euler', 'dpmpp_2m', ...), a fixed enum ComfyUI ships built in, not a+ * file the Model Manager can install or a value that goes missing depending+ * on what the customer downloaded, so it is not K2's bug class at all.+ *+ * Run: npx vitest run src/api/__tests__/no-hardcoded-loader-names-k2.test.ts+ */+import { describe, it, expect } from 'vitest'+import { readFileSync, readdirSync, statSync } from 'node:fs'+import { join, dirname, relative } from 'node:path'+import { fileURLToPath } from 'node:url'++const HERE = dirname(fileURLToPath(import.meta.url))+const API_DIR = join(HERE, '..')++const LOADER_NAME_FIELDS = new Set([+ 'ckpt_name', 'unet_name', 'vae_name',+ 'clip_name', 'clip_name1', 'clip_name2',+ 'lora_name', 'audio_encoder_name', 'clip_vision_name',+ 'controlnet_name', 'upscale_model_name', 'style_model_name',+ 'embedding_name', 'model_name',+])++interface Hit { file: string; line: number; field: string; value: string }++function scanFile(path: string): Hit[] {+ const hits: Hit[] = []+ const lines = readFileSync(path, 'utf-8').split('\n')+ const pattern = /(\w+)\s*:\s*(['"])([^'"]+)\2/g+ lines.forEach((line, i) => {+ const trimmed = line.trim()+ if (trimmed.startsWith('//') || trimmed.startsWith('*') || trimmed.startsWith('/*')) return+ for (const m of line.matchAll(pattern)) {+ const [, field, , value] = m+ if (LOADER_NAME_FIELDS.has(field)) {+ hits.push({ file: relative(API_DIR, path), line: i + 1, field, value })+ }+ }+ })+ return hits+}++function scanDir(dir: string): Hit[] {+ const hits: Hit[] = []+ for (const entry of readdirSync(dir)) {+ if (entry === '__tests__' || entry === 'node_modules') continue+ const full = join(dir, entry)+ const st = statSync(full)+ if (st.isDirectory()) { hits.push(...scanDir(full)); continue }+ if (!entry.endsWith('.ts') && !entry.endsWith('.tsx')) continue+ hits.push(...scanFile(full))+ }+ return hits+}++// Documented, justified exceptions. Each entry needs a reason a reader can+// verify against the code, not just a filename.+const EXCEPTIONS: Record<string, string> = {+ // getBuiltinTemplates() in workflows.ts ships three STARTER templates for+ // the (currently unwired, no UI calls getBuiltinTemplates or reads+ // .rawWorkflow anywhere) Workflow Manager's template gallery. Their+ // 'model.safetensors' / 'clip.safetensors' / 'ae.safetensors' /+ // 'vae.safetensors' values are editable PLACEHOLDERS in a graph the+ // system never submits to /prompt as-is: a real generation always goes+ // through parseImportedWorkflow -> autoDetectParameterMap ->+ // injectParameters, which writes the live-picked model name in at+ // generation time. Not K2's bug class (a live request silently sending a+ // stale/wrong value): nothing here is ever silently submitted.+ 'workflows.ts': 'getBuiltinTemplates() starter-template placeholders, never submitted directly (see comment above)',+}++describe('no ComfyUI loader node in src/api hardcodes a *_name file value (K2)', () => {+ it('sanity: the scanner actually walks files and the field set is non-empty', () => {+ const all = scanDir(API_DIR)+ expect(LOADER_NAME_FIELDS.size).toBeGreaterThan(5)+ // Sanity that the scanner itself works: the exception file must show up.+ expect(all.some((h) => h.file === 'workflows.ts')).toBe(true)+ })++ it('every hit is inside a documented exception file', () => {+ const hits = scanDir(API_DIR)+ const undocumented = hits.filter((h) => !(h.file in EXCEPTIONS))+ expect(+ undocumented,+ `Hardcoded loader value(s) found: ${undocumented.map((h) => `${h.file}:${h.line} ${h.field}="${h.value}"`).join(', ')}. ` ++ `Resolve against the live enum (findMatchingVAE/findMatchingCLIP/findMatchingAudioEncoder/findMatchingClipVision/findFramePackCLIPPair/findFluxCLIPPair, ` ++ `or resolveLoraNames), or add a justified, reasoned entry to EXCEPTIONS above.`,+ ).toEqual([])+ })++ it('sampler_name literals are NOT flagged (algorithm choice, not a file)', () => {+ // Regression guard for the scanner itself: dynamic-workflow.ts writes+ // sampler_name: 'euler' for music generation, and that must stay legal.+ const hits = scanDir(API_DIR)+ expect(hits.some((h) => h.field === 'sampler_name')).toBe(false)+ })+})diff --git a/src/api/__tests__/vae-override-live-check-k2.test.ts b/src/api/__tests__/vae-override-live-check-k2.test.tsindex 539dbbb9..03feb778 100644--- a/src/api/__tests__/vae-override-live-check-k2.test.ts+++ b/src/api/__tests__/vae-override-live-check-k2.test.ts@@ -6,11 +6,19 @@* A `params.vae` override (a stale remembered pick from an older LU/ComfyUI* install, a wrong path separator, a subfolder-qualified name, ...) used to* go straight into the VAELoader node unchecked. buildDynamicWorkflow now- * validates it against `models.vaes` — the live VAELoader enum already read- * off the same /object_info response this build used for strategy detection- * — BEFORE writing the node, and throws an actionable WorkflowUnavailableError+ * validates it against `models.vaes`, the live VAELoader enum already read+ * off the same /object_info response this build used for strategy detection,+ * BEFORE writing the node, and throws an actionable WorkflowUnavailableError* instead of letting ComfyUI's opaque "Value not in list" reach the user.*+ * review-create.md nachbessert, Punkt 3: a plain `models.vaes.includes()`+ * blocked a file that really IS installed whenever the remembered spelling+ * differed cosmetically (backslash instead of slash, a leftover subfolder+ * prefix, different case) from the live enum's own spelling. The check now+ * normalizes first (normalizeLoaderValue in dynamic-workflow.ts) and, on a+ * match, writes the LIVE enum's spelling to the node, not the remembered+ * one, so an existing file never blocks the run. Only a genuine miss throws.+ ** Run: npx vitest run src/api/__tests__/vae-override-live-check-k2.test.ts*/import { describe, it, expect, vi, beforeEach } from 'vitest'@@ -43,7 +51,7 @@ const baseParams = {width: 1024, height: 1024, steps: 20, cfgScale: 7, seed: 1, batchSize: 1,} as never-describe('buildDynamicWorkflow — K2: VAE override validated against the live list', () => {+describe('buildDynamicWorkflow (K2): VAE override validated against the live list', () => {beforeEach(() => {vi.clearAllMocks()vi.mocked(getAllNodeInfo).mockResolvedValue(CHECKPOINT_NODES as never)@@ -65,6 +73,36 @@ describe('buildDynamicWorkflow — K2: VAE override validated against the live lexpect((vaeNode?.inputs as { vae_name?: string } | undefined)?.vae_name).toBe('ae.safetensors')})+ // Punkt 3: an existing file must never block the run over a cosmetic+ // mismatch, and the node must carry the LIVE spelling, not the remembered+ // (possibly wrong-case, wrong-separator, subfolder-qualified) one.+ it('a Windows-style backslash path resolves to the live basename, not a rejection', async () => {+ const wf = await buildDynamicWorkflow({ ...(baseParams as object), vae: 'vae\\ae.safetensors' } as never)+ expect(classTypes(wf)).toContain('VAELoader')+ const [, vaeNode] = nodeOf(wf, 'VAELoader') ?? []+ expect((vaeNode?.inputs as { vae_name?: string } | undefined)?.vae_name).toBe('ae.safetensors')+ })++ it('different case resolves to the live spelling', async () => {+ const wf = await buildDynamicWorkflow({ ...(baseParams as object), vae: 'AE.SAFETENSORS' } as never)+ const [, vaeNode] = nodeOf(wf, 'VAELoader') ?? []+ expect((vaeNode?.inputs as { vae_name?: string } | undefined)?.vae_name).toBe('ae.safetensors')+ })++ it('a subfolder-qualified name resolves by basename to the live spelling', async () => {+ const wf = await buildDynamicWorkflow({ ...(baseParams as object), vae: 'vae/sdxl_vae.safetensors' } as never)+ const [, vaeNode] = nodeOf(wf, 'VAELoader') ?? []+ expect((vaeNode?.inputs as { vae_name?: string } | undefined)?.vae_name).toBe('sdxl_vae.safetensors')+ })++ it('a genuinely different, short live-list name is never a false positive for an unrelated stale pick', async () => {+ // Regression guard: "ae.safetensors" is a substring of almost anything+ // ending in those two letters. Normalization must not treat that as a match.+ await expect(+ buildDynamicWorkflow({ ...(baseParams as object), vae: 'old-2.6.9-remembered-vae.safetensors' } as never),+ ).rejects.toThrow(/not installed in ComfyUI/)+ })+it('"auto" and unset skip the check entirely (checkpoint keeps its bundled VAE)', async () => {const wfAuto = await buildDynamicWorkflow({ ...(baseParams as object), vae: 'auto' } as never)expect(classTypes(wfAuto)).not.toContain('VAELoader')diff --git a/src/api/__tests__/wan22-workflow.test.ts b/src/api/__tests__/wan22-workflow.test.tsindex e5b0cee8..de9bbba7 100644--- a/src/api/__tests__/wan22-workflow.test.ts+++ b/src/api/__tests__/wan22-workflow.test.ts@@ -127,6 +127,17 @@ describe('determineStrategy — wan22 gate', () => {describe('buildDynamicWorkflow — Wan 2.2 graph', () => {beforeEach(() => {vi.mocked(getAllNodeInfo).mockResolvedValue(WAN22_NODES as never)+ // K2 (Punkt 1 of the nachbessert list): buildWan22Workflow now resolves+ // its CLIP/VAE against the live enum (findMatchingCLIP/findMatchingVAE)+ // instead of hardcoded literals, so /object_info/CLIPLoader and+ // /object_info/VAELoader need real answers, not just getAllNodeInfo's.+ vi.mocked(localFetch).mockResolvedValue({+ ok: true,+ json: async () => ({+ CLIPLoader: { input: { required: { clip_name: [['umt5_xxl_fp8_e4m3fn_scaled.safetensors']] } } },+ VAELoader: { input: { required: { vae_name: [['wan2.2_vae.safetensors']] } } },+ }),+ } as never)})it('T2V (no inputImage): Wan22 latent has NO start_image, uses the 2.2 VAE + UMT5', async () => {@@ -149,6 +160,28 @@ describe('buildDynamicWorkflow — Wan 2.2 graph', () => {expect(nodeOf(wf, 'ImageScale')).toBeUndefined()})+ // K2 (Punkt 1): before this fix, buildWan22Workflow wrote the CLIP/VAE+ // names as hardcoded literals ('umt5_xxl_fp8_e4m3fn_scaled.safetensors' /+ // 'wan2.2_vae.safetensors') REGARDLESS of the live enum, so a graph built+ // against a different live list would still have shown the old literal+ // here. This test's mock deliberately answers with DIFFERENT filenames+ // (a plausible post-3.0 /internal/folder_paths rename) so it only passes+ // if the values genuinely come from findMatchingCLIP/findMatchingVAE.+ it('uses whatever the live enum actually names, not the historic literal filenames', async () => {+ vi.mocked(localFetch).mockResolvedValue({+ ok: true,+ json: async () => ({+ CLIPLoader: { input: { required: { clip_name: [['models/umt5_xxl_fp8_e4m3fn_scaled.safetensors']] } } },+ VAELoader: { input: { required: { vae_name: [['models/wan2.2_vae.safetensors']] } } },+ }),+ } as never)+ const wf = await buildDynamicWorkflow({ ...wan22Params } as never)+ const vae = nodeOf(wf, 'VAELoader')!+ const clip = nodeOf(wf, 'CLIPLoader')!+ expect(vae[1].inputs.vae_name).toBe('models/wan2.2_vae.safetensors')+ expect(clip[1].inputs.clip_name).toBe('models/umt5_xxl_fp8_e4m3fn_scaled.safetensors')+ })+it('T2V wires the sampler through ModelSamplingSD3 (Wan shift)', async () => {const wf = await buildDynamicWorkflow({ ...wan22Params } as never)const [shiftId, shift] = nodeOf(wf, 'ModelSamplingSD3')!diff --git a/src/api/comfyui.ts b/src/api/comfyui.tsindex db6e8476..1d330825 100644--- a/src/api/comfyui.ts+++ b/src/api/comfyui.ts@@ -270,7 +270,7 @@ export function classifyModel(name: string | null | undefined): ModelType {// "krea2") + VAE pipeline, NOT a self-contained CheckpointLoaderSimple// graph. Before this check the name fell through to 'unknown', which// CLASSIFIED it as an ordinary checkpoint and loaded it with- // CheckpointLoaderSimple — the file has no embedded CLIP, so ComfyUI+ // CheckpointLoaderSimple, and the file has no embedded CLIP, so ComfyUI// answered "clip input is invalid: None". Detect before the 'xl' suffix// scan below: CivitAI filenames commonly end "...Krea2_fp8.safetensors",// which would otherwise never reach it anyway, but keep the ordering@@ -450,9 +450,9 @@ export const MODEL_TYPE_DEFAULTS: Record<string, ModelTypeDefaults> = {// ─── Component Requirements per model type ───// K9 (GH #136): the registry used to be declared here AND, separately, in-// discover.ts — two copies of the same per-model-type data that both had to+// discover.ts, two copies of the same per-model-type data that both had to// be remembered on every new architecture. Krea 2 only reached one of them.-// Canonical data now lives in component-registry.ts (Audit W-T2 pattern —+// Canonical data now lives in component-registry.ts (Audit W-T2 pattern,// same fix as pulling the bundle catalog into model-bundles.ts); both// comfyui.ts and discover.ts import it and neither has to import the other.export type { ComponentSpec, ComponentRequirements } from './component-registry'@@ -1504,6 +1504,26 @@ export async function findFluxCLIPPair(): Promise<{ t5: string; clipL: string }>return { t5, clipL }}+/**+ * K2 (review-create.md nachbessert, Punkt 2): FramePack's DualCLIPLoader+ * (type "hunyuan_video") wrote `clip_l.safetensors` and+ * `llava_llama3_fp8_scaled.safetensors` straight into the node, same+ * hardcoded-literal failure class the rest of K2 already fixed for VAE/CLIP/+ * audio_encoder/clip_vision in the other builders. Resolved now against the+ * live CLIP enum, same shape as findFluxCLIPPair above, with the same+ * actionable "download <file>" errors on a miss.+ */+export async function findFramePackCLIPPair(): Promise<{ clipL: string; llavaLlama3: string }> {+ const clips = await getCLIPModels()+ if (clips.length === 0) throw new Error('No text encoder models found. Download a CLIP/T5 model for your model type from the Model Manager.')+ const lower = (s: string) => s.toLowerCase()+ const clipL = clips.find(c => lower(c).includes('clip_l'))+ const llavaLlama3 = clips.find(c => lower(c).includes('llava'))+ if (!clipL) throw new Error(`No FramePack CLIP-L text encoder found. Download "clip_l.safetensors" from the Model Manager.`)+ if (!llavaLlama3) throw new Error(`No FramePack llava_llama3 text encoder found. Download "llava_llama3_fp8_scaled.safetensors" from the Model Manager.`)+ return { clipL, llavaLlama3 }+}+/*** Pick the right text encoder for a model.*@@ -1560,7 +1580,7 @@ export async function findMatchingCLIP(modelType: ModelType, activeModelName?: sif (modelType === 'krea2') {// Krea 2 uses Qwen3-VL 4B, shipped under different quant-tier filenames// by different finetune authors (GH #136: qwen3vl_4b_int8_convrot vs- // qwen3vl_4b_fp8_scaled) — match on the qwen3vl family, not one filename.+ // qwen3vl_4b_fp8_scaled), so match on the qwen3vl family, not one filename.const match = clips.find(c => lower(c).includes('qwen3vl') || lower(c).includes('qwen3_vl'))|| clips.find(c => lower(c).includes('qwen') && lower(c).includes('vl'))if (match) return match@@ -1624,7 +1644,7 @@ export async function findMatchingCLIP(modelType: ModelType, activeModelName?: s* safetensors'` straight into AudioEncoderLoader, never checked against* ComfyUI's live enum. A box that doesn't have that exact file (a different* quant, a subfolder, or simply nothing installed) submitted it verbatim and- * ComfyUI's /prompt validator rejected the node with "Value not in list" —+ * ComfyUI's /prompt validator rejected the node with "Value not in list",* the same failure mode Bug C already fixed for CLIPLoader, just not carried* over to the newer local lanes. Same no-silent-fallback rule as* findMatchingVAE/findMatchingCLIP: resolve against the live list, throw andiff --git a/src/api/dynamic-workflow.ts b/src/api/dynamic-workflow.tsindex 0a2785ab..729e784f 100644--- a/src/api/dynamic-workflow.ts+++ b/src/api/dynamic-workflow.ts@@ -1,6 +1,6 @@import {classifyModel, findMatchingVAE, findMatchingCLIP, findFluxCLIPPair,- findMatchingAudioEncoder, findMatchingClipVision,+ findMatchingAudioEncoder, findMatchingClipVision, findFramePackCLIPPair,} from './comfyui'import type { ModelType, GenerateParams, VideoParams } from './comfyui'import { log } from '../lib/logger'@@ -278,13 +278,13 @@ export function determineStrategy(}// K9: this used to fall back to 'unet_flux' whenever CheckpointLoaderSimple- // was missing (rare — it is a core node, present on virtually every real+ // was missing (rare, it is a core node, present on virtually every real// install), on the unstated assumption that any UNET-only file must be a// FLUX model. For a genuinely unrecognized architecture that is a silent// guess: it picks FLUX's CLIP type and VAE match patterns for a model that// may not be FLUX at all, which either fails confusingly or "succeeds"// with a wrong text encoder. classifyModel returning 'unknown' means LU- // could not name this model's architecture — say so honestly instead of+ // could not name this model's architecture, so say so honestly instead of// routing it through a guessed pipeline. A real architecture (Krea 2,// FLUX 2, Z-Image, ...) has its own branch above and never reaches here.if (hasUNET && hasCLIPLoader && hasVAELoader) {@@ -373,7 +373,7 @@ export function normalizeLoraStrengths(* letting ComfyUI reject the whole workflow with "Value not in list". */export function resolveLoraNames(requested: string[], installed: string[]): string[] {return requested.map((req) => {- const hit = resolveOneLora(req, installed)+ const hit = resolveLoaderName(req, installed)if (!hit) {const list = installed.length ? installed.slice(0, 12).join(', ') : '(none installed)'throw new Error(@@ -385,7 +385,34 @@ export function resolveLoraNames(requested: string[], installed: string[]): stri})}-function resolveOneLora(req: string, installed: string[]): string | null {+/**+ * Normalize a remembered loader value (path separator, case, an optional+ * subfolder prefix) against ComfyUI's live enum for that loader, WITHOUT the+ * loose substring tier resolveLoaderName uses for LoRA names below. That+ * tier is right for a LoRA name an LLM paraphrased ("pixel art" for+ * "pixel-art-xl.safetensors") but wrong here: a short live entry like+ * "ae.safetensors" is a substring of almost anything ending in those two+ * letters, so "old-2.6.9-remembered-vae.safetensors" would falsely resolve+ * to it. K2 (review-create.md Punkt 3) only needs cosmetic drift covered+ * (separator, case, subfolder prefix), never a guess at a DIFFERENT file.+ */+function normalizeLoaderValue(req: string, installed: string[]): string | null {+ if (installed.includes(req)) return req+ const norm = (s: string) => s.toLowerCase().replace(/\\/g, '/')+ const rq = norm(req)+ const exact = installed.filter((c) => norm(c) === rq)+ if (exact.length === 1) return exact[0]+ const rqBase = rq.split('/').pop() || rq+ const byBase = installed.filter((c) => (norm(c).split('/').pop() || '') === rqBase)+ if (byBase.length === 1) return byBase[0]+ return null+}++/**+ * Fuzzy-match a remembered LoRA name (file name, path separator and case+ * left unspecified, or paraphrased by an LLM) against ComfyUI's live enum.+ */+function resolveLoaderName(req: string, installed: string[]): string | null {if (installed.includes(req)) return reqconst norm = (s: string) =>s.toLowerCase().replace(/\.(safetensors|pt|ckpt|bin)$/i, '').replace(/\\/g, '/')@@ -395,7 +422,7 @@ function resolveOneLora(req: string, installed: string[]): string | null {const rq = norm(req)let hits = installed.filter((c) => norm(c) === rq)if (hits.length === 1) return hits[0]- // Enum entries can be "subfolder/name.safetensors" — try basename equality.+ // Enum entries can be "subfolder/name.safetensors": try basename equality.const rqBase = rq.split('/').pop() || rqhits = installed.filter((c) => (norm(c).split('/').pop() || '') === rqBase)if (hits.length === 1) return hits[0]@@ -464,7 +491,7 @@ export async function buildDynamicWorkflow(return buildSVDWorkflow(params as VideoParams, seed, nodes)}if (strategy === 'wan22') {- return buildWan22Workflow(params as VideoParams, seed, nodes, allNodes)+ return await buildWan22Workflow(params as VideoParams, seed, nodes, allNodes)}if (strategy === 'framepack') {return await buildFramePackWorkflow(params as VideoParams, seed, nodes)@@ -682,27 +709,41 @@ export async function buildDynamicWorkflow(}if (params.vae && params.vae !== 'auto') {- // K2: this override used to go straight into VAELoader unchecked — a+ // K2: this override used to go straight into VAELoader unchecked, so a// stale remembered pick (a name that existed in an older LU/ComfyUI// install, a wrong path separator, a subfolder-qualified name ComfyUI's// enum does not use) reached /prompt as-is and came back "Value not in// list". `models.vaes` is the live VAELoader enum already read off this- // same /object_info response — validate against it before writing the+ // same /object_info response, validate against it before writing the// node. Skip the check only when that enum came back empty (an older// ComfyUI that answered a different schema): saying nothing is safer// than a false rejection of a value we simply could not verify.- if (models.vaes.length > 0 && !models.vaes.includes(params.vae)) {- const list = models.vaes.slice(0, 12).join(', ')- throw new WorkflowUnavailableError(- `VAE "${params.vae}" is not installed in ComfyUI. Installed VAEs: ${list}. ` +- `Put the file into ComfyUI/models/vae and retry, or clear the VAE override.`,- strategy,- )+ //+ // K2 (review-create.md nachbessert, Punkt 3): a straight `includes()`+ // rejected an installed file for a purely cosmetic mismatch (backslash+ // vs slash, a leftover subfolder prefix, different case) even though+ // ComfyUI would have accepted the LIVE spelling just fine. Normalize+ // first via normalizeLoaderValue; on a hit, write the LIVE enum's own+ // spelling to the node, not the remembered one, and only throw on a+ // genuine miss.+ let vaeName = params.vae+ if (models.vaes.length > 0 && !models.vaes.includes(vaeName)) {+ const resolved = normalizeLoaderValue(vaeName, models.vaes)+ if (resolved) {+ vaeName = resolved+ } else {+ const list = models.vaes.slice(0, 12).join(', ')+ throw new WorkflowUnavailableError(+ `VAE "${params.vae}" is not installed in ComfyUI. Installed VAEs: ${list}. ` ++ `Put the file into ComfyUI/models/vae and retry, or clear the VAE override.`,+ strategy,+ )+ }}const vaeId = String(n++)workflow[vaeId] = {class_type: 'VAELoader',- inputs: { vae_name: params.vae },+ inputs: { vae_name: vaeName },}vaeSourceId = vaeIdvaeOutputSlot = 0@@ -1218,17 +1259,30 @@ export function snapWanLength(frames: number): number {}/**- * Wan 2.2 TI2V-5B — one model, both modes. `Wan22ImageToVideoLatent` takes an- * OPTIONAL `start_image`: present → image-to-video (the clip opens on the source- * still), absent → text-to-video. Uses the Wan 2.2 VAE (NOT the 2.1 VAE — the 2.2- * VAE has 16× spatial / 4× temporal compression, a different latent shape) and the- * shared UMT5-XXL text encoder. `ModelSamplingSD3` applies Wan's sampling shift.+ * Wan 2.2 TI2V-5B, one model, both modes. `Wan22ImageToVideoLatent` takes an+ * OPTIONAL `start_image`: present is image-to-video (the clip opens on the+ * source still), absent is text-to-video. Uses the Wan 2.2 VAE, not the 2.1+ * VAE (the 2.2 VAE has 16x spatial / 4x temporal compression, a different+ * latent shape) and the shared UMT5-XXL text encoder. `ModelSamplingSD3`+ * applies Wan's sampling shift.** I2V faithfulness (David 2026-06-11): an `ImageScale(crop:center)` aspect-fills* the source into the generation size, so the first frame matches the still- * instead of being squished — the same fix proven on the SVD path.+ * instead of being squished, the same fix proven on the SVD path.+ *+ * K2 (review-create.md nachbessert, Punkt 1): the CLIP/VAE names below used+ * to be hardcoded literals, the same failure class as buildS2VWorkflow and+ * buildMotionWorkflow (see their own K2 comments) and Node 3 in this builder+ * is also the VAELoader, so an unresolved live enum produced the identical+ * "Node 3 (VAELoader): Value not in list" here. Wan 2.2 TI2V-5B is the+ * default local Animate model, so this is the actual path a customer hits.+ * Resolved now via the same findMatchingCLIP/findMatchingVAE live-list+ * resolvers Bug C and K2 already use elsewhere, with 'wan22' for the VAE+ * (its own compression profile, comfyui.ts:1441) and 'wan' for the CLIP+ * (wan22 shares the plain Wan UMT5 encoder, component-registry.ts confirms+ * clipType: 'wan' for both wan and wan22).*/-function buildWan22Workflow(params: VideoParams, seed: number, nodes: CategorizedNodes, allNodes: NodePresence): ComfyApiGraph {+async function buildWan22Workflow(params: VideoParams, seed: number, nodes: CategorizedNodes, allNodes: NodePresence): Promise<ComfyApiGraph> {const workflow: ComfyApiGraph = {}let n = 1@@ -1238,6 +1292,11 @@ function buildWan22Workflow(params: VideoParams, seed: number, nodes: Categorizeconst height = snap32(params.height, 576)const length = snapWanLength(params.frames || 49)+ const [wan22Clip, wan22Vae] = await Promise.all([+ findMatchingCLIP('wan', params.model),+ findMatchingVAE('wan22'),+ ])+const unetId = String(n++)const clipId = String(n++)const vaeId = String(n++)@@ -1245,14 +1304,14 @@ function buildWan22Workflow(params: VideoParams, seed: number, nodes: Categorizeconst negId = String(n++)addUnetLoader(workflow, unetId, params.model, allNodes)- workflow[clipId] = { class_type: 'CLIPLoader', inputs: { clip_name: 'umt5_xxl_fp8_e4m3fn_scaled.safetensors', type: 'wan', device: 'default' } }- workflow[vaeId] = { class_type: 'VAELoader', inputs: { vae_name: 'wan2.2_vae.safetensors' } }+ workflow[clipId] = { class_type: 'CLIPLoader', inputs: { clip_name: wan22Clip, type: 'wan', device: 'default' } }+ workflow[vaeId] = { class_type: 'VAELoader', inputs: { vae_name: wan22Vae } }workflow[posId] = { class_type: 'CLIPTextEncode', inputs: { text: params.prompt, clip: [clipId, 0] } }workflow[negId] = { class_type: 'CLIPTextEncode', inputs: { text: params.negativePrompt || '', clip: [clipId, 0] } }// Optional LoRA chain (D#80, game-master0): video LoRAs are model-only, so// patch the UNET with LoraLoaderModelOnly (no clip side) before the sampling- // shift. Guarded on params.lora — a plain Wan 2.2 gen stays byte-identical.+ // shift. Guarded on params.lora, a plain Wan 2.2 gen stays byte-identical.let wanModelSrc = unetIdconst wanLoras = normalizeLoraList(params.lora)if (wanLoras.length > 0) {@@ -1478,8 +1537,9 @@ export function buildMusicWorkflow(params: LocalOpParams, seed: number, allNodes* 2026-09-15/17): the CLIP/VAE/audio-encoder filenames below used to be* written straight into their loader nodes as literal strings, never checked* against what ComfyUI actually has installed. Whichever one the box didn't- * have failed validation with "Value not in list" — Node 3 (VAELoader) in- * the reports, because that is the third node this builder creates. Resolve+ * have failed validation with "Value not in list", specifically Node 3+ * (VAELoader) in the reports, because that is the third node this builder+ * creates. Resolve* every one of them against the live enum first (same rule Bug C already* applied to the FLUX/video lanes in buildDynamicWorkflow), so a mismatch is* caught before /prompt submission with an actionable "download <file>"@@ -1565,8 +1625,8 @@ export async function buildS2VWorkflow(params: LocalOpParams, seed: number, allN* onnxruntime path works on every Windows box, no GPU wheel roulette).* The driving clip's own audio is carried over into the result.*- * K2: same live-list-first fix as buildS2VWorkflow above — CLIP/VAE were- * hardcoded literals here too.+ * K2: same live-list-first fix as buildS2VWorkflow above, since CLIP/VAE+ * were hardcoded literals here too.*/export async function buildMotionWorkflow(params: LocalOpParams, seed: number, allNodes: NodePresence): Promise<ComfyApiGraph> {const workflow: ComfyApiGraph = {}@@ -1703,11 +1763,14 @@ async function buildFramePackWorkflow(params: VideoParams, seed: number, nodes:// documented low-VRAM combo and is what makes FramePack actually run on 12 GB// (and down to ~6 GB) instead of OOMing on every consumer card.workflow[modelId] = { class_type: 'LoadFramePackModel', inputs: { model: params.model, base_precision: 'bf16', quantization: 'fp8_e4m3fn', load_device: 'offload_device' } }- // DualCLIPLoader with type "hunyuan_video" — CLIPLoader type "wan" creates Llama2 with 128256 vocab- // but llava_llama3 has 128320 tokens, causing state_dict size mismatch. DualCLIPLoader handles both correctly.- workflow[clipId] = { class_type: 'DualCLIPLoader', inputs: { clip_name1: 'clip_l.safetensors', clip_name2: 'llava_llama3_fp8_scaled.safetensors', type: 'hunyuan_video' } }+ // DualCLIPLoader with type "hunyuan_video": CLIPLoader type "wan" creates Llama2 with+ // 128256 vocab but llava_llama3 has 128320 tokens, causing a state_dict size mismatch.+ // DualCLIPLoader handles both correctly. K2 (Punkt 2): both names used to be hardcoded+ // literals, resolved now via findFramePackCLIPPair against the live CLIP enum.+ const framePackClips = await findFramePackCLIPPair()+ workflow[clipId] = { class_type: 'DualCLIPLoader', inputs: { clip_name1: framePackClips.clipL, clip_name2: framePackClips.llavaLlama3, type: 'hunyuan_video' } }// K2: was a hardcoded literal never checked against the live CLIPVisionLoader- // enum — same "Value not in list" failure mode as the VAE below, just for a+ // enum, same "Value not in list" failure mode as the VAE below, just for a// different node. Resolved against the live list like the VAE already is.workflow[clipVisionId] = { class_type: 'CLIPVisionLoader', inputs: { clip_name: await findMatchingClipVision() } }// FramePack is a HunyuanVideo 1.0 model. Its sampler allocates the history