Add MOSS-Image on the Image v2 path and stop the queue calling it Klein.

The bench queue labeled every engine except Krea, Qwen, MiniMax, and LTX as Klein, and the v2 starter treated any engine other than Krea as Flux.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-10-22 20:04:58 -05:00
co-authored by Cursor
parent 74edeabc39
commit 354f475866
30 changed files with 873 additions and 111 deletions
+2 -1
View File
@@ -7,7 +7,7 @@ import { pathToFileURL } from 'node:url'
import ts from 'typescript'
const stub = `
export const IMAGE_V2_ENGINES = ['flux', 'krea']
export const IMAGE_V2_ENGINES = ['flux', 'krea', 'moss']
export function parseImageV2Engine(raw, fallback = 'flux') {
const value = String(raw || '').trim().toLowerCase()
return IMAGE_V2_ENGINES.includes(value) ? value : fallback
@@ -70,6 +70,7 @@ test('default negative blocks trademarked names and NSFW', () => {
test('engine and style defaults; sizes snap to allowed sides', () => {
assert.equal(parseAssetPackEngine(undefined), 'flux')
assert.equal(parseAssetPackEngine('krea'), 'krea')
assert.equal(parseAssetPackEngine('moss'), 'moss')
assert.equal(parseAssetPackStyle('panel_bg'), 'panel_bg')
assert.deepEqual(assetPackSize('sticker'), { width: 1024, height: 1024, aspect: null })
assert.deepEqual(assetPackSize('icon'), { width: 768, height: 768, aspect: null })
+94
View File
@@ -0,0 +1,94 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readFileSync, writeFileSync, mkdirSync, rmSync } from 'node:fs'
import { join } from 'node:path'
import { tmpdir } from 'node:os'
import { pathToFileURL } from 'node:url'
import ts from 'typescript'
const stub = `
export function filterLoraStackForImageEngine(stack, engine) {
if (engine === 'moss') return []
return Array.isArray(stack) ? stack : []
}
export function loraIdentityKey(name) {
return String(name || '').replace(/\\\\/g, '/').split('/').pop().toLowerCase()
}
export function makeLoraStackItem(name, model, clip) {
const value = String(name || '').trim()
return value ? { name: value, strengthModel: model, strengthClip: clip } : null
}
export function normalizeLoraStack(stack) {
return Array.isArray(stack) ? stack : []
}
`
const src = readFileSync(new URL('../utils/imageV2.ts', import.meta.url), 'utf8')
.replace(/from '~\/utils\/loras'/g, "from './loras-stub.mjs'")
const dir = join(tmpdir(), `image-v2-moss-${process.pid}`)
mkdirSync(dir, { recursive: true })
const out = join(dir, 'imageV2.mjs')
writeFileSync(join(dir, 'loras-stub.mjs'), stub)
writeFileSync(out, ts.transpileModule(src, {
compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.ESNext }
}).outputText)
const api = await import(pathToFileURL(out).href)
rmSync(dir, { recursive: true, force: true })
const graph = JSON.parse(readFileSync(new URL('../server/assets/moss_v2_generate.json', import.meta.url), 'utf8'))
test('MOSS is a generate engine with its own workflow and sampling defaults', () => {
assert.equal(api.parseImageV2Engine('moss'), 'moss')
assert.equal(api.parseImageV2Engine('moss-image'), 'moss')
assert.equal(api.parseImageV2Engine('nope'), 'flux')
assert.equal(api.imageV2WorkflowFile('generate', 'moss'), 'moss_v2_generate.json')
assert.equal(api.imageV2WorkflowFile('edit', 'flux'), 'klein_v2_edit.json')
assert.equal(api.imageV2WorkflowFile('generate', 'krea'), 'krea_v2_generate.json')
assert.deepEqual(api.imageV2SamplingDefaults('moss'), { steps: 25, cfg: 2.5 })
assert.deepEqual(api.imageV2SamplingDefaults('krea'), { steps: 8, cfg: 1 })
assert.deepEqual(api.imageV2SamplingDefaults('flux'), { steps: 24, cfg: 4 })
assert.deepEqual(api.defaultImageV2LoraStack({ engine: 'moss', mode: 'generate', xaigen: true }), [])
assert.deepEqual(api.mergeLegacyImageV2Loras([{ name: 'klein.safetensors', strengthModel: 1, strengthClip: 1 }], {
engine: 'moss',
mode: 'generate',
xaigen: true
}), [])
})
test('MOSS look settings stay separate from Klein and Krea', () => {
const state = api.readImageV2LookState({
engine: 'moss',
flux: { steps: 30, cfg: 4.5, turbo: true },
krea: { steps: 8, cfg: 1 },
moss: { steps: 40, cfg: 3 }
})
assert.equal(state.engine, 'moss')
assert.deepEqual(state.looks.flux, { steps: 30, cfg: 4.5, turbo: true })
assert.deepEqual(state.looks.krea, { steps: 8, cfg: 1, turbo: false })
assert.deepEqual(state.looks.moss, { steps: 40, cfg: 3, turbo: false })
const fresh = api.readImageV2LookState(null)
assert.equal(fresh.engine, 'flux')
assert.deepEqual(fresh.looks.moss, { steps: 25, cfg: 2.5, turbo: false })
assert.equal(fresh.looks.krea.turbo, false)
})
test('MOSS generate graph uses the INT8 loaders, shift 5, and layer 22', () => {
assert.equal(graph['4'].class_type, 'UNETLoader')
assert.equal(graph['4'].inputs.unet_name, 'moss_image_sft_int8_convrot.safetensors')
assert.equal(graph['5'].class_type, 'CLIPLoader')
assert.equal(graph['5'].inputs.type, 'moss_image')
assert.equal(graph['5'].inputs.clip_name, 'qwen3.5_9b_w4a8_gptq.safetensors')
assert.equal(graph['5'].inputs.device, 'cpu')
assert.equal(graph['6'].inputs.vae_name, 'flux2-vae_small.safetensors')
assert.equal(graph['14'].class_type, 'EmptyFlux2LatentImage')
assert.equal(graph['40'].class_type, 'ModelSamplingAuraFlow')
assert.equal(graph['40'].inputs.shift, 5)
assert.equal(graph['41'].class_type, 'SkipLayerGuidanceDiTSimple')
assert.equal(graph['41'].inputs.single_layers, '22')
assert.equal(graph['41'].inputs.double_layers, '')
assert.equal(graph['15'].class_type, 'KSampler')
assert.equal(graph['15'].inputs.steps, 25)
assert.equal(graph['15'].inputs.cfg, 2.5)
assert.equal(graph['15'].inputs.scheduler, 'sgm_uniform')
assert.deepEqual(graph['15'].inputs.model, ['41', 0])
assert.equal(Object.values(graph).some(node => node.class_type === 'LoadImage' || node.class_type === 'LoraLoader' || node.class_type === 'Flux2Scheduler'), false)
})
+26
View File
@@ -6,6 +6,7 @@ import {folderAssets,reconcileSelection,activeJobs,previewHidden} from '../share
import {useAsHero,useAsSource,restoreAll,hydrateStudio2Job} from '../shared/studio2/input.mjs'
import {toggleStyle,parseBatch,parseBatchDoubleBlank,stylePrompt} from '../shared/studio2/styles.mjs'
import {compilePrompt,validateRequest} from '../shared/studio2/contracts.mjs'
import {queueEngineLabel} from '../shared/studio2/queue-view.mjs'
import {cachedLoras} from '../shared/studio2/lora-cache.mjs'
import {resolveQwen21Size} from '../shared/studio2/qwen21-size.mjs'
import {ensureQwen21EditPrompt,stitchQwen21PeEditPrompt,QWEN21_EDIT_KEEP_CHANGE} from '../shared/studio2/qwen21-edit.mjs'
@@ -86,6 +87,31 @@ test('image chips compile positive and negative independently; video chips do no
assert.deepEqual(parseBatchDoubleBlank('one\n\ntwo'),['one\n\ntwo'])
assert.deepEqual(parseBatchDoubleBlank('one\n\n\ntwo\n\n\n\nthree\n'),['one','two','three'])
})
test('queue card names MOSS-Image and does not call it Klein',()=>{
assert.equal(queueEngineLabel('moss'),'MOSS-Image')
assert.equal(queueEngineLabel('moss-image'),'MOSS-Image')
assert.equal(queueEngineLabel('flux'),'Klein')
assert.equal(queueEngineLabel('krea'),'Krea 2')
const src=readFileSync(new URL('../components/studio2/Bench.vue',import.meta.url),'utf8')
assert.match(src,/queueEngineLabel\(job\.request\?\.engine\)/)
assert.doesNotMatch(src,/engine==='minimax'\?'MiniMax H3':'Klein'/)
})
test('moss is generate-only with its own steps and CFG',()=>{
const q=validateRequest({mode:'generate',engine:'moss',folderId:'f',promptSections:{action:'a red ceramic cup'},settings:{aspect:'1:1',steps:40,cfg:3,loraStack:[{name:'klein-anime.safetensors'}]}})
assert.equal(q.engine,'moss')
assert.equal(q.settings.steps,40)
assert.equal(q.settings.cfg,3)
assert.equal(q.settings.width,1024)
assert.equal(q.settings.height,1024)
assert.equal(q.turbo,false)
assert.equal(q.enhancePrompt,false)
assert.deepEqual(q.settings.loraStack,[])
assert.equal(q.identityStillId,'')
const fresh=validateRequest({mode:'generate',engine:'moss',folderId:'f',promptSections:{action:'cup'},settings:{aspect:'auto'}})
assert.equal(fresh.settings.steps,25)
assert.equal(fresh.settings.cfg,2.5)
assert.throws(()=>validateRequest({mode:'edit',engine:'moss',folderId:'f',imageAId:'s',promptSections:{action:'x'}}),/text-to-image only/)
})
test('qwen21 supports Generate and Edit with 25/1 defaults and no locks',()=>{
const q=validateRequest({mode:'generate',engine:'qwen21',folderId:'f',promptSections:{action:'a red bicycle'},settings:{aspect:'1:1'}})
assert.equal(q.engine,'qwen21');assert.equal(q.settings.steps,25);assert.equal(q.settings.cfg,1)