dist-mcp / services / modelOverlays.js
dist-mcp / services / modelOverlays.js
"use strict";
/**
* Model Overlays Registry
* Maps model identifiers to their parameter overlays for txt2img and img2img modes.
*
* - "auto": Use defaults (no overlay)
* - "z-image": Use z-image-turbo optimized settings
* - "qwen-image": Use qwen-image optimized settings
* - "flux": Use flux optimized settings
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.modelOverlays = exports.MODEL_FAMILIES = exports.MODEL_IDS = void 0;
exports.getModelOverlay = getModelOverlay;
exports.isValidModelId = isValidModelId;
exports.getModelFilename = getModelFilename;
exports.getModelRequiredFiles = getModelRequiredFiles;
const core_bundle_mjs_1 = require("../core-bundle.mjs");
/**
* All model IDs including sub-categories (e.g. qwen-edit).
* Used internally for overlay lookups.
*/
exports.MODEL_IDS = [
"auto",
"z-image",
"krea",
"qwen-image",
"qwen-edit",
"flux",
"ltx",
"custom",
];
exports.MODEL_FAMILIES = [
"auto",
"z-image",
"krea",
"qwen-image",
"flux",
"ltx",
"custom",
];
/**
* Registry of model overlays.
* - `null` means "use defaults, no overlay"
*/
exports.modelOverlays = {
auto: {
txt2img: null,
img2img: null,
edit: null,
txt2vid: null,
img2vid: null,
},
"z-image": {
txt2img: core_bundle_mjs_1.zImageOverlays.txt2img,
img2img: core_bundle_mjs_1.zImageOverlays.img2img,
edit: null, // z-image does not support edit mode
txt2vid: null,
img2vid: null,
},
krea: {
txt2img: core_bundle_mjs_1.kreaOverlays.txt2img,
img2img: core_bundle_mjs_1.kreaOverlays.img2img,
edit: null, // krea does not support edit mode
txt2vid: null,
img2vid: null,
},
"qwen-image": {
txt2img: core_bundle_mjs_1.qwenImageOverlays.txt2img,
img2img: core_bundle_mjs_1.qwenImageOverlays.img2img,
edit: core_bundle_mjs_1.qwenImageOverlays.edit,
txt2vid: null,
img2vid: null,
},
// qwen-edit: dedicated edit/i2i preset using qwen_image_edit models
// Uses same overlays as qwen-image for img2img/edit (no txt2img support)
"qwen-edit": {
txt2img: null, // qwen-edit does not support text2image
img2img: core_bundle_mjs_1.qwenImageOverlays.img2img,
edit: core_bundle_mjs_1.qwenImageOverlays.edit,
txt2vid: null,
img2vid: null,
},
flux: {
txt2img: core_bundle_mjs_1.fluxOverlays.txt2img,
img2img: core_bundle_mjs_1.fluxOverlays.img2img,
edit: core_bundle_mjs_1.fluxOverlays.edit,
txt2vid: null,
img2vid: null,
},
ltx: {
txt2img: core_bundle_mjs_1.ltxOverlays.txt2vid, // LTX can also produce single images
img2img: core_bundle_mjs_1.ltxOverlays.img2vid, // LTX can also do image2image
edit: null, // LTX does not support edit mode
txt2vid: core_bundle_mjs_1.ltxOverlays.txt2vid,
img2vid: core_bundle_mjs_1.ltxOverlays.img2vid,
},
custom: {
txt2img: null, // custom configs only, no built-in overlay
img2img: null, // custom configs only, no built-in overlay
edit: null, // custom configs only, no built-in overlay
txt2vid: null,
img2vid: null,
},
};
/**
* Get overlay params for a given model and mode.
* Returns null if no overlay should be applied.
*/
function getModelOverlay(modelId, mode) {
if (!modelId || modelId === "auto") {
return null;
}
// "krea2" is a user-facing alias for the "krea" preset (see capabilities.ts MODEL_PRESET_TO_CAPABILITY_KEY).
const normalizedModelId = modelId === "krea2" ? "krea" : modelId;
const entry = exports.modelOverlays[normalizedModelId];
if (!entry) {
console.error(`Unknown model '${modelId}', using defaults`);
return null;
}
return entry[mode];
}
/**
* Check if a string is a valid ModelId
*/
function isValidModelId(value) {
return typeof value === "string" && exports.MODEL_IDS.includes(value);
}
/**
* Get the actual .ckpt filename for a model preset.
* Returns the filename that should exist on the Draw Things backend.
* Returns null for "auto" or unknown models.
*/
function getModelFilename(modelId, mode) {
if (!modelId || modelId === "auto") {
return null;
}
const normalizedModelId = modelId === "krea2" ? "krea" : modelId;
const entry = exports.modelOverlays[normalizedModelId];
if (!entry) {
return null;
}
const overlay = entry[mode];
if (!overlay) {
return null;
}
return typeof overlay.model === "string" ? overlay.model : null;
}
/**
* Get all required .ckpt filenames for a model preset (model + LoRAs).
* Returns an array of filenames that should exist on the Draw Things backend.
*/
function getModelRequiredFiles(modelId, mode) {
const files = [];
if (!modelId || modelId === "auto") {
return files;
}
const normalizedModelId = modelId === "krea2" ? "krea" : modelId;
const entry = exports.modelOverlays[normalizedModelId];
if (!entry) {
return files;
}
const overlay = entry[mode];
if (!overlay) {
return files;
}
if (typeof overlay.model === "string") {
files.push(overlay.model);
}
if (Array.isArray(overlay.loras)) {
for (const lora of overlay.loras) {
if (typeof lora === "object" &&
lora !== null &&
typeof lora.file === "string") {
files.push(lora.file);
}
}
}
return files;
}
"use strict";
/**
* Model Overlays Registry
* Maps model identifiers to their parameter overlays for txt2img and img2img modes.
*
* - "auto": Use defaults (no overlay)
* - "z-image": Use z-image-turbo optimized settings
* - "qwen-image": Use qwen-image optimized settings
* - "flux": Use flux optimized settings
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.modelOverlays = exports.MODEL_FAMILIES = exports.MODEL_IDS = void 0;
exports.getModelOverlay = getModelOverlay;
exports.isValidModelId = isValidModelId;
exports.getModelFilename = getModelFilename;
exports.getModelRequiredFiles = getModelRequiredFiles;
const core_bundle_mjs_1 = require("../core-bundle.mjs");
/**
* All model IDs including sub-categories (e.g. qwen-edit).
* Used internally for overlay lookups.
*/
exports.MODEL_IDS = [
"auto",
"z-image",
"krea",
"qwen-image",
"qwen-edit",
"flux",
"ltx",
"custom",
];
exports.MODEL_FAMILIES = [
"auto",
"z-image",
"krea",
"qwen-image",
"flux",
"ltx",
"custom",
];
/**
* Registry of model overlays.
* - `null` means "use defaults, no overlay"
*/
exports.modelOverlays = {
auto: {
txt2img: null,
img2img: null,
edit: null,
txt2vid: null,
img2vid: null,
},
"z-image": {
txt2img: core_bundle_mjs_1.zImageOverlays.txt2img,
img2img: core_bundle_mjs_1.zImageOverlays.img2img,
edit: null, // z-image does not support edit mode
txt2vid: null,
img2vid: null,
},
krea: {
txt2img: core_bundle_mjs_1.kreaOverlays.txt2img,
img2img: core_bundle_mjs_1.kreaOverlays.img2img,
edit: null, // krea does not support edit mode
txt2vid: null,
img2vid: null,
},
"qwen-image": {
txt2img: core_bundle_mjs_1.qwenImageOverlays.txt2img,
img2img: core_bundle_mjs_1.qwenImageOverlays.img2img,
edit: core_bundle_mjs_1.qwenImageOverlays.edit,
txt2vid: null,
img2vid: null,
},
// qwen-edit: dedicated edit/i2i preset using qwen_image_edit models
// Uses same overlays as qwen-image for img2img/edit (no txt2img support)
"qwen-edit": {
txt2img: null, // qwen-edit does not support text2image
img2img: core_bundle_mjs_1.qwenImageOverlays.img2img,
edit: core_bundle_mjs_1.qwenImageOverlays.edit,
txt2vid: null,
img2vid: null,
},
flux: {
txt2img: core_bundle_mjs_1.fluxOverlays.txt2img,
img2img: core_bundle_mjs_1.fluxOverlays.img2img,
edit: core_bundle_mjs_1.fluxOverlays.edit,
txt2vid: null,
img2vid: null,
},
ltx: {
txt2img: core_bundle_mjs_1.ltxOverlays.txt2vid, // LTX can also produce single images
img2img: core_bundle_mjs_1.ltxOverlays.img2vid, // LTX can also do image2image
edit: null, // LTX does not support edit mode
txt2vid: core_bundle_mjs_1.ltxOverlays.txt2vid,
img2vid: core_bundle_mjs_1.ltxOverlays.img2vid,
},
custom: {
txt2img: null, // custom configs only, no built-in overlay
img2img: null, // custom configs only, no built-in overlay
edit: null, // custom configs only, no built-in overlay
txt2vid: null,
img2vid: null,
},
};
/**
* Get overlay params for a given model and mode.
* Returns null if no overlay should be applied.
*/
function getModelOverlay(modelId, mode) {
if (!modelId || modelId === "auto") {
return null;
}
// "krea2" is a user-facing alias for the "krea" preset (see capabilities.ts MODEL_PRESET_TO_CAPABILITY_KEY).
const normalizedModelId = modelId === "krea2" ? "krea" : modelId;
const entry = exports.modelOverlays[normalizedModelId];
if (!entry) {
console.error(`Unknown model '${modelId}', using defaults`);
return null;
}
return entry[mode];
}
/**
* Check if a string is a valid ModelId
*/
function isValidModelId(value) {
return typeof value === "string" && exports.MODEL_IDS.includes(value);
}
/**
* Get the actual .ckpt filename for a model preset.
* Returns the filename that should exist on the Draw Things backend.
* Returns null for "auto" or unknown models.
*/
function getModelFilename(modelId, mode) {
if (!modelId || modelId === "auto") {
return null;
}
const normalizedModelId = modelId === "krea2" ? "krea" : modelId;
const entry = exports.modelOverlays[normalizedModelId];
if (!entry) {
return null;
}
const overlay = entry[mode];
if (!overlay) {
return null;
}
return typeof overlay.model === "string" ? overlay.model : null;
}
/**
* Get all required .ckpt filenames for a model preset (model + LoRAs).
* Returns an array of filenames that should exist on the Draw Things backend.
*/
function getModelRequiredFiles(modelId, mode) {
const files = [];
if (!modelId || modelId === "auto") {
return files;
}
const normalizedModelId = modelId === "krea2" ? "krea" : modelId;
const entry = exports.modelOverlays[normalizedModelId];
if (!entry) {
return files;
}
const overlay = entry[mode];
if (!overlay) {
return files;
}
if (typeof overlay.model === "string") {
files.push(overlay.model);
}
if (Array.isArray(overlay.loras)) {
for (const lora of overlay.loras) {
if (typeof lora === "object" &&
lora !== null &&
typeof lora.file === "string") {
files.push(lora.file);
}
}
}
return files;
}