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
+65 -2
View File
@@ -8,7 +8,7 @@ import {
export const IMAGE_V2_MODES = ['edit', 'compose', 'refine', 'generate', 'iterate'] as const
export const IMAGE_V2_TASKS = ['scene', 'identity', 'outfit', 'face_lock', 'refine', 't2i'] as const
export const IMAGE_V2_ENGINES = ['flux', 'krea'] as const
export const IMAGE_V2_ENGINES = ['flux', 'krea', 'moss'] as const
export type ImageV2Mode = (typeof IMAGE_V2_MODES)[number]
export type ImageV2Task = (typeof IMAGE_V2_TASKS)[number]
@@ -89,6 +89,63 @@ export const IMAGE_V2_KREA_UNET_CANDIDATES = [
] as const
export const IMAGE_V2_KREA_CONCEPT_LORA = 'xaigen-snofs_krea_v1_3D.safetensors'
/** Official template speed point. 50 / CFG 3 is the slower published look. */
export const IMAGE_V2_MOSS_STEPS = 25
export const IMAGE_V2_MOSS_CFG = 2.5
export const IMAGE_V2_MOSS_SHIFT = 5
export const IMAGE_V2_MOSS_SLG_LAYER = '22'
export const IMAGE_V2_MOSS_CLIP_TYPE = 'moss_image'
export const IMAGE_V2_MOSS_UNET = 'moss_image_sft_int8_convrot.safetensors'
export const IMAGE_V2_MOSS_CLIP_CANDIDATES = [
'qwen3.5_9b_w4a8_gptq.safetensors',
'qwen3.5_9b_int8_convrot.safetensors'
] as const
export const IMAGE_V2_MOSS_VAE_CANDIDATES = [
'flux2-vae_small.safetensors',
'flux2-vae.safetensors'
] as const
export const IMAGE_V2_LOOK_STORAGE_KEY = 'aigen-image-v2-look'
export type ImageV2EngineLook = { steps: number; cfg: number; turbo: boolean }
export function imageV2SamplingDefaults(engine: ImageV2Engine) {
if (engine === 'krea') return { steps: IMAGE_V2_KREA_STEPS, cfg: IMAGE_V2_KREA_CFG }
if (engine === 'moss') return { steps: IMAGE_V2_MOSS_STEPS, cfg: IMAGE_V2_MOSS_CFG }
return { steps: IMAGE_V2_STEPS_DEFAULT, cfg: IMAGE_V2_CFG_DEFAULT }
}
export function defaultImageV2EngineLook(engine: ImageV2Engine): ImageV2EngineLook {
const sampling = imageV2SamplingDefaults(engine)
return { steps: sampling.steps, cfg: sampling.cfg, turbo: false }
}
function lookNumber(raw: unknown, fallback: number, min: number, max: number, step: number) {
const value = Number(raw)
if (!Number.isFinite(value)) return fallback
const snapped = Math.round(value / step) * step
const digits = step < 1 ? 1 : 0
const rounded = Number(snapped.toFixed(digits))
return Math.min(max, Math.max(min, rounded))
}
export function readImageV2LookState(raw: unknown): {
engine: ImageV2Engine
looks: Record<ImageV2Engine, ImageV2EngineLook>
} {
const src = raw && typeof raw === 'object' ? raw as Record<string, unknown> : {}
const looks = {} as Record<ImageV2Engine, ImageV2EngineLook>
for (const engine of IMAGE_V2_ENGINES) {
const row = src[engine] && typeof src[engine] === 'object' ? src[engine] as Record<string, unknown> : {}
const fallback = defaultImageV2EngineLook(engine)
looks[engine] = {
steps: lookNumber(row.steps, fallback.steps, 1, 50, 1),
cfg: lookNumber(row.cfg, fallback.cfg, 0, 20, 0.1),
turbo: engine === 'flux' && row.turbo === true
}
}
return { engine: parseImageV2Engine(src.engine, 'flux'), looks }
}
export const IMAGE_V2_ROLE_HEADERS: Record<Exclude<ImageV2Task, 'scene' | 'refine' | 't2i'>, string> = {
outfit: 'Person, face, body, pose, and background from image 1. Clothing only from image 2. Fit the outfit from image 2 to the body in image 1. Do not copy image 2’s face, body shape, or pose.',
face_lock: 'Body, pose, and scene from image 1. Exact face from image 2.',
@@ -106,12 +163,14 @@ export function parseImageV2Task(raw: unknown, fallback: ImageV2Task = 'scene'):
}
export function parseImageV2Engine(raw: unknown, fallback: ImageV2Engine = 'flux'): ImageV2Engine {
const value = String(raw || '').trim().toLowerCase()
const value = String(raw || '').trim().toLowerCase().replace(/[\s_]+/g, '-')
if (value === 'moss-image' || value === 'mossimage' || value === 'openmoss') return 'moss'
return IMAGE_V2_ENGINES.includes(value as ImageV2Engine) ? value as ImageV2Engine : fallback
}
export function imageV2WorkflowFile(mode: ImageV2Mode, engine: ImageV2Engine = 'flux', opts: { hasImage?: boolean; hasReference?: boolean } = {}) {
const graph = imageV2GraphMode(mode, opts)
if (engine === 'moss') return 'moss_v2_generate.json'
if (engine === 'krea') {
if (graph === 'generate') return 'krea_v2_generate.json'
if (graph === 'refine') return 'krea_v2_refine.json'
@@ -194,6 +253,7 @@ export type ImageV2PresetSettings = {
}
export function imageV2ConceptLoraName(engine: ImageV2Engine, kreaConcept?: string) {
if (engine === 'moss') return ''
if (engine === 'krea') return String(kreaConcept || IMAGE_V2_KREA_CONCEPT_LORA || '').trim()
return IMAGE_V2_SNOFS_LORA
}
@@ -202,6 +262,7 @@ export function isImageV2ConceptLora(name: string, engine?: ImageV2Engine) {
const id = loraIdentityKey(name)
const flux = id === loraIdentityKey(IMAGE_V2_SNOFS_LORA) || /klein_snofs/i.test(id)
const krea = id === loraIdentityKey(IMAGE_V2_KREA_CONCEPT_LORA) || /snofs_krea/i.test(id)
if (engine === 'moss') return false
if (engine === 'krea') return krea
if (engine === 'flux') return flux
return flux || krea
@@ -248,6 +309,7 @@ export function defaultImageV2LoraStack(opts: {
xaigen: boolean
kreaConcept?: string
}): LoraStackItem[] {
if (opts.engine === 'moss') return []
if (opts.engine === 'krea') {
const name = String(opts.kreaConcept || '').trim()
if (!opts.xaigen || !name) return []
@@ -276,6 +338,7 @@ export function mergeLegacyImageV2Loras(stack: unknown, opts: {
consistencyClip?: number
kreaConcept?: string
}): LoraStackItem[] {
if (opts.engine === 'moss') return []
let items = filterLoraStackForImageEngine(stack, opts.engine)
if (opts.engine === 'krea') {
const name = String(opts.kreaConcept || '').trim()