Eliminate xAIGen and LTX; AIGen is the only studio.

Drop the studio split, backup-to-xAIGen link, and LTX engine option. Show all LoRAs on AIGen and remove the Photos show/hide inputs toggle so slots stay visible.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-10-27 17:55:59 -05:00
co-authored by Cursor
parent 2b603b1d58
commit 08caeb51de
38 changed files with 174 additions and 635 deletions
+1 -5
View File
@@ -1,6 +1,5 @@
import { createHash, timingSafeEqual } from 'node:crypto'
import type { H3Event } from 'h3'
import { isXaigenStudio } from '~/utils/videoModels'
import { passwordAuthEnabled, privateInstanceId } from '~/server/utils/localAuth'
function configuredApiKey() {
@@ -30,7 +29,6 @@ export function aigenApiKeyConfigured() {
}
export function aigenBearerAuthorized(event: H3Event) {
if (isXaigenStudio()) return false
const expected = configuredApiKey()
if (!expected) return false
const header = String(getHeader(event, 'authorization') || '')
@@ -46,7 +44,5 @@ export function aigenApiPathAllowed(path: string, method: string) {
}
export function assertAigenFeature() {
if (isXaigenStudio()) {
throw createError({ statusCode: 404, statusMessage: 'Not found' })
}
/* AIGen API is always available on the single studio deployment. */
}
-48
View File
@@ -1,48 +0,0 @@
function env(...keys: string[]) {
for (const key of keys) {
const value = String(process.env[key] || '').trim()
if (value) return value
}
return ''
}
function looksLikeUrl(value: string) {
return /^https?:\/\//i.test(value)
}
export function backupStudioTarget() {
const config = useRuntimeConfig()
const url = String(
config.backupStudioUrl
|| env('BACKUP_STUDIO_URL', 'NUXT_BACKUP_STUDIO_URL')
).replace(/\/$/, '')
const token = String(
config.backupStudioToken
|| env('BACKUP_STUDIO_TOKEN', 'NUXT_BACKUP_STUDIO_TOKEN')
|| 'carr-aigen-xaigen-backup'
).trim()
const misplaced = env('BACKUP_INGEST_TOKEN', 'NUXT_BACKUP_INGEST_TOKEN')
return { url, token, misplaced }
}
export function backupIngestSecret() {
const config = useRuntimeConfig()
return String(
config.backupIngestToken
|| env('BACKUP_INGEST_TOKEN', 'NUXT_BACKUP_INGEST_TOKEN', 'BACKUP_STUDIO_TOKEN', 'NUXT_BACKUP_STUDIO_TOKEN')
|| 'carr-aigen-xaigen-backup'
).trim()
}
export function backupStudioConfigError() {
const { url, token, misplaced } = backupStudioTarget()
if (url && token) return ''
if (!url && looksLikeUrl(misplaced)) {
return 'BACKUP_INGEST_TOKEN on AIGen is a URL. Put https://xaigen.carrgarage.com in BACKUP_STUDIO_URL, and put the same secret in BACKUP_STUDIO_TOKEN here and BACKUP_INGEST_TOKEN on xAIGen.'
}
if (!url && !token) {
return 'Set BACKUP_STUDIO_URL and BACKUP_STUDIO_TOKEN on AIGen. The token must match BACKUP_INGEST_TOKEN on xAIGen.'
}
if (!url) return 'Set BACKUP_STUDIO_URL on AIGen to https://xaigen.carrgarage.com'
return 'Set BACKUP_STUDIO_TOKEN on AIGen to the same secret as BACKUP_INGEST_TOKEN on xAIGen'
}
+2 -5
View File
@@ -5,7 +5,7 @@ import { composePromptParts } from '~/utils/promptParts'
import { parsePostedLoraStack, listStudioLoras, persistLoraFields, ensureComfyLoraNames } from '~/server/utils/loras'
import { readLoraStack } from '~/utils/loras'
import { clampVideoCfg } from '~/utils/generationPresets'
import { defaultVideoSteps, isLtxWorkflow, LTX_DISABLED_MESSAGE, ltxWorkflowEnabled, parseVideoWorkflow } from '~/utils/videoModels'
import { coerceVideoWorkflow, defaultVideoSteps, parseVideoWorkflow } from '~/utils/videoModels'
import { clampVideoDuration, clipPartDuration } from '~/utils/videoDuration'
import { createJob, emitJob, type Job } from '~/server/utils/jobs'
import {
@@ -105,10 +105,7 @@ export async function beginExtendFromClip(params: {
shotIndex: (source.chainIndex || 0) + 1,
familyRefs: source.permanenceRefs
})
const workflow = parseVideoWorkflow(source.workflow)
if (isLtxWorkflow(workflow) && !ltxWorkflowEnabled()) {
throw createError({ statusCode: 400, statusMessage: LTX_DISABLED_MESSAGE })
}
const workflow = coerceVideoWorkflow(source.workflow)
const turbo = source.turbo !== false
const fps = parseFps(source.fps)
const cfg = parseCfg(source.cfg, turbo)
+6 -10
View File
@@ -43,7 +43,7 @@ import {
sanitizeMusicLyrics,
sanitizeMusicTags
} from '~/utils/music'
import { coerceVideoWorkflow, isXaigenStudio, parseVideoWorkflow } from '~/utils/videoModels'
import { coerceVideoWorkflow, parseVideoWorkflow } from '~/utils/videoModels'
const writeChains = new Map<string, Promise<unknown>>()
@@ -143,8 +143,8 @@ function sanitizeImageV2Settings(raw: unknown): ImageV2PresetSettings {
task: mode === 'compose' ? parseImageV2Task(rec.task, 'scene') : mode === 'refine' ? 'refine' : mode === 'generate' ? 't2i' : 'scene',
prompt: sanitizePrompt(rec.prompt),
negative: String(rec.negative || '').slice(0, 2000),
snofsModel: isXaigenStudio() ? clampImageV2Strength(rec.snofsModel ?? rec.snofs_model, IMAGE_V2_SNOFS_MODEL) : 0,
snofsClip: isXaigenStudio() ? clampImageV2Strength(rec.snofsClip ?? rec.snofs_clip, IMAGE_V2_SNOFS_CLIP) : 0,
snofsModel: clampImageV2Strength(rec.snofsModel ?? rec.snofs_model, IMAGE_V2_SNOFS_MODEL),
snofsClip: clampImageV2Strength(rec.snofsClip ?? rec.snofs_clip, IMAGE_V2_SNOFS_CLIP),
consistencyModel: clampImageV2Strength(rec.consistencyModel ?? rec.consistency_model, mode === 'generate' ? 0 : IMAGE_V2_CONSISTENCY_MODEL),
consistencyClip: clampImageV2Strength(rec.consistencyClip ?? rec.consistency_clip, mode === 'generate' ? 0 : IMAGE_V2_CONSISTENCY_CLIP),
steps: engine === 'krea' || engine === 'moss' ? clampImageSteps(rec.steps, sampling.steps) : turbo ? 8 : clampImageSteps(rec.steps, IMAGE_V2_STEPS_DEFAULT),
@@ -202,15 +202,12 @@ function normalizeStoredPreset(raw: unknown): GenerationPreset | null {
}
function publicPreset(preset: GenerationPreset): GenerationPreset {
const xaigen = isXaigenStudio()
const settings = preset.kind === 'video'
? { ...preset.settings, workflow: coerceVideoWorkflow((preset.settings as VideoPresetSettings).workflow) }
: preset.kind === 'imagev2' && !xaigen
? { ...preset.settings, snofsModel: 0, snofsClip: 0 }
: preset.settings
: preset.settings
return {
...preset,
loraStack: filterLoraStackForStudio(preset.loraStack, xaigen),
loraStack: filterLoraStackForStudio(preset.loraStack),
settings
}
}
@@ -234,8 +231,7 @@ export async function saveGenerationPreset(owner: string, input: {
throw createError({ statusCode: 400, statusMessage: 'A preset name is required' })
}
const kind = parseGenerationPresetKind(input.kind)
const xaigen = isXaigenStudio()
const loraStack = filterLoraStackForStudio(input.loraStack, xaigen)
const loraStack = filterLoraStackForStudio(input.loraStack)
const settings = sanitizeSettings(kind, input.settings)
const now = Date.now()
return mutate(owner, (presets) => {
+1 -2
View File
@@ -10,7 +10,6 @@ import { emitChainJob } from '~/server/utils/watch'
import { saveStill, stillChainName } from '~/server/utils/library'
import { comfyJobPrefix } from '~/utils/outputNames'
import { restorePromptParts, wrappedPromptForComfy } from '~/utils/promptParts'
import { isXaigenStudio } from '~/utils/videoModels'
import {
imageV2GraphMode,
imageV2StackSpecials,
@@ -141,7 +140,7 @@ export async function runEditV2(job: Job, params: EditV2RunParams) {
const appliedStack = mergeLegacyImageV2Loras(pass?.loraStack ?? params.loraStack ?? library.loraStack, {
engine,
mode: graphMode,
xaigen: isXaigenStudio(),
xaigen: true,
snofsModel: pass?.loraStack !== undefined ? 0 : params.snofsModel,
snofsClip: pass?.loraStack !== undefined ? 0 : params.snofsClip,
consistencyModel: pass?.loraStack !== undefined ? 0 : params.consistencyModel,
+1 -2
View File
@@ -13,7 +13,6 @@ import { imageComfyFetch } from '~/server/utils/imageComfy'
import { applyImageV2UserLoras } from '~/server/utils/loras'
import { type LoraStackItem } from '~/utils/loras'
import { clampImageCfg, clampImageScaleMegapixels, clampImageSteps } from '~/utils/generationPresets'
import { isXaigenStudio } from '~/utils/videoModels'
import {
IMAGE_V2_KREA_CFG,
IMAGE_V2_KREA_CLIP,
@@ -490,7 +489,7 @@ function imageV2UserStack(params: ImageV2BuildParams, engine: ImageV2Engine) {
return mergeLegacyImageV2Loras(params.loraStack, {
engine,
mode: params.mode,
xaigen: isXaigenStudio(),
xaigen: true,
snofsModel: params.snofsModel,
snofsClip: params.snofsClip,
consistencyModel: params.consistencyModel,
+9 -21
View File
@@ -1,12 +1,10 @@
import { comfyConfigured, comfyFetch, getComfyHost } from '~/server/utils/comfy'
import { getBeastImageHost, imageComfyFetch, sameImageHost } from '~/server/utils/imageComfy'
import {
XAIGEN_LORA_MESSAGE,
MINIMAX_TURBO_LORA,
filterLorasForStudio,
imageLoraEngineMismatchMessage,
imageLoraEngineOf,
isXaigenOnlyLora,
loraIdentityKey,
normalizeLoraName,
normalizeLoraStack,
@@ -15,7 +13,7 @@ import {
type LoraKind,
type LoraStackItem
} from '~/utils/loras'
import { isXaigenStudio, LTX_DISTILLED_LORA } from '~/utils/videoModels'
import { LTX_DISTILLED_LORA } from '~/utils/videoModels'
type WorkflowNode = { class_type: string; inputs: Record<string, unknown>; _meta?: { title?: string } }
type WorkflowGraph = Record<string, WorkflowNode>
@@ -216,22 +214,21 @@ async function loadLoraCache(options: { fresh?: boolean } = {}): Promise<LoraCac
}
export async function listStudioLoras(options: { fresh?: boolean } = {}) {
const xaigen = isXaigenStudio()
// `fresh` hits Comfy /object_info so new files under models/loras/<site>/<engine>/ show up
// without a restart. Names stay Comfy-relative (slashes included) for the graph.
try {
const listed = await loadLoraCache(options)
return {
at: listed.at,
image: filterLorasForStudio(listed.image, xaigen),
video: filterLorasForStudio(listed.video, xaigen)
image: filterLorasForStudio(listed.image),
video: filterLorasForStudio(listed.video)
}
} catch {
if (cache) {
return {
at: cache.at,
image: filterLorasForStudio(cache.image, xaigen),
video: filterLorasForStudio(cache.video, xaigen)
image: filterLorasForStudio(cache.image),
video: filterLorasForStudio(cache.video)
}
}
return { at: 0, image: [] as string[], video: [] as string[] }
@@ -267,7 +264,7 @@ export function resolveGraphLoraNames(graph: WorkflowGraph, kind?: LoraKind) {
}
function allowedLoraNames(kind?: LoraKind) {
return filterLorasForStudio(cachedComfyLoraNames(kind), isXaigenStudio())
return filterLorasForStudio(cachedComfyLoraNames(kind))
}
function resolveUserLoraName(name: string, kind?: LoraKind) {
@@ -279,9 +276,6 @@ function resolveUserLoraName(name: string, kind?: LoraKind) {
export function assertLoraAllowed(raw: unknown, kind: LoraKind) {
const name = normalizeLoraName(raw)
if (!name) return ''
if (isXaigenOnlyLora(name) && !isXaigenStudio()) {
throw createError({ statusCode: 400, statusMessage: XAIGEN_LORA_MESSAGE })
}
const allowed = allowedLoraNames(kind)
if (allowed.length) {
const identity = loraIdentityKey(name)
@@ -394,14 +388,12 @@ function bypassLoraNode(graph: WorkflowGraph, id: string) {
/** Optional Klein-style LoraLoader: user stack only. Empty stack bypasses model/CLIP around the loader. */
export function applyOptionalLoraLoaders(graph: WorkflowGraph, stack?: unknown, kind: LoraKind = 'image') {
const loaders = Object.entries(graph).filter(([, node]) => node.class_type === LORA_LOADER)
const xaigen = isXaigenStudio()
const items = normalizeLoraStack(stack)
.filter(item => xaigen || !isXaigenOnlyLora(item.name))
.map(item => ({
...item,
name: resolveUserLoraName(item.name, kind)
}))
.filter(item => item.name && (xaigen || !isXaigenOnlyLora(item.name)))
.filter(item => item.name)
if (!loaders.length) {
applyUserLoraToGraph(graph, items)
return
@@ -487,14 +479,12 @@ export function applyImageV2UserLoras(
) {
stripExistingLoraLoaders(graph)
const xaigen = isXaigenStudio()
const items = normalizeLoraStack(stack)
.filter(item => xaigen || !isXaigenOnlyLora(item.name))
.map(item => ({
...item,
name: resolveUserLoraName(item.name, 'image')
}))
.filter(item => item.name && (xaigen || !isXaigenOnlyLora(item.name)) && (item.strengthModel !== 0 || item.strengthClip !== 0))
.filter(item => item.name && (item.strengthModel !== 0 || item.strengthClip !== 0))
const wrong = items.find((item) => {
const tagged = imageLoraEngineOf(item.name)
@@ -557,11 +547,9 @@ export function applyImageV2UserLoras(
}
export function applyUserLoraToGraph(graph: WorkflowGraph, stack?: unknown) {
const xaigen = isXaigenStudio()
const items = normalizeLoraStack(stack)
.filter(item => xaigen || !isXaigenOnlyLora(item.name))
.map(item => ({ ...item, name: resolveUserLoraName(item.name) }))
.filter(item => item.name && (xaigen || !isXaigenOnlyLora(item.name)) && !alreadyHasLora(graph, item.name))
.filter(item => item.name && !alreadyHasLora(graph, item.name))
if (!items.length) return
const clipLoaders = Object.entries(graph).filter(([, node]) => node.class_type === LORA_LOADER)
+10 -41
View File
@@ -273,47 +273,16 @@ async function prepareGraph(r: any) {
start = await upload(r, 'start', readFileSync(dest));
unlinkSync(dest);
}
if (q.engine === 'ltx') {
const { buildWorkflow } = await import('../workflow');
const { frameLength } = await import('../videoChain');
const { ltxWorkflowEnabled, LTX_DISABLED_MESSAGE } = await import('~/utils/videoModels');
if (!ltxWorkflowEnabled()) throw new Error(LTX_DISABLED_MESSAGE);
const textToVideo = q.mode === 'video' && !start;
if (!start && !textToVideo) throw new Error('Choose a start still for LTX video.');
const fps = s.fps || 24;
graph = buildWorkflow({
workflow: textToVideo ? 'ltx-t2v' : 'ltx',
imageName: start || '',
prompt: q.compiledPrompt,
width: s.width,
height: s.height,
length: frameLength(s.duration || 5, fps),
fps,
steps: s.steps,
cfg: s.cfg,
seed: s.seed,
samplerName: 'euler',
scheduler: 'simple',
turbo: false,
duration: s.duration || 5,
filenamePrefix: prefix + '/video',
loraStack: s.loraStack,
useIdentityRefs: false
});
await ensureComfyLoraNames('video');
r.graphId = textToVideo ? 'workflow_ltx_video.json#t2v' : 'workflow_ltx_video.json';
} else {
if (q.engine !== 'minimax')
throw new Error('Studio 2 video supports MiniMax H3 and LTX (xAIGen).');
const end = await load(q.endStillId, 'end'), guides = [];
for (const [i, g] of q.guides.entries())
guides.push({ image: await load(g.stillId, `guide${i}`), frame: g.frame });
graph = nativeVideoGraph(template, q, { hero, start, end, guides }, prefix);
await ensureComfyLoraNames('video');
resolveGraphLoraNames(graph, 'video');
applyUserLoraToGraph(graph, s.loraStack);
r.graphId = 'studio2_minimax_native.json';
}
if (q.engine !== 'minimax')
throw new Error('Studio 2 video supports MiniMax H3 only.');
const end = await load(q.endStillId, 'end'), guides = [];
for (const [i, g] of q.guides.entries())
guides.push({ image: await load(g.stillId, `guide${i}`), frame: g.frame });
graph = nativeVideoGraph(template, q, { hero, start, end, guides }, prefix);
await ensureComfyLoraNames('video');
resolveGraphLoraNames(graph, 'video');
applyUserLoraToGraph(graph, s.loraStack);
r.graphId = 'studio2_minimax_native.json';
}
else if (q.engine === 'moss') {
if (q.mode !== 'generate')
+2 -5
View File
@@ -5,7 +5,7 @@ import { getJob, listJobs, emitJob, type Job } from '~/server/utils/jobs'
import { listPendingJobs, patchPendingJob, readPendingJob, deletePendingJob } from '~/server/utils/pending'
import { getShotQueue, pendingSegmentCount } from '~/server/utils/shotQueue'
import { fetchLiveQueue } from '~/server/utils/comfy'
import { isLtxWorkflow, isTextToVideo, isXaigenStudio, LTX_DISABLED_MESSAGE, ltxWorkflowEnabled, parseVideoWorkflow, type VideoWorkflowId } from '~/utils/videoModels'
import { coerceVideoWorkflow, isTextToVideo, parseVideoWorkflow, type VideoWorkflowId } from '~/utils/videoModels'
import { persistLoraFields } from '~/server/utils/loras'
import { resolveLoraStack } from '~/utils/loras'
import { persistPromptWrappers } from '~/utils/promptParts'
@@ -1565,10 +1565,7 @@ async function startStudioJobReserved(item: StudioJob) {
const { existsSync, readFileSync } = await import('node:fs')
const payload = item.payload
const workflow = parseVideoWorkflow(payload.workflow)
if (isLtxWorkflow(workflow) && !ltxWorkflowEnabled()) {
throw new Error(LTX_DISABLED_MESSAGE)
}
const workflow = coerceVideoWorkflow(payload.workflow)
const identity = allowIdentityRefs(
payload.useIdentityRefs,
payload.permanenceRefs,
+2 -6
View File
@@ -7,11 +7,10 @@ import { buildIdentityPrompt } from '~/utils/identityPrompt'
import { applyUserLoraToGraph, resolveGraphLoraNames } from '~/server/utils/loras'
import type { LoraStackItem } from '~/utils/loras'
import {
coerceVideoWorkflow,
isLtxWorkflow,
isTextToVideo,
LTX_DISABLED_MESSAGE,
LTX_NEGATIVE,
ltxWorkflowEnabled,
parseVideoWorkflow,
type VideoWorkflowId
} from '~/utils/videoModels'
@@ -81,10 +80,7 @@ function templateFor(id: VideoWorkflowId) {
}
export function buildWorkflow(params: GenerateParams) {
const version = parseVideoWorkflow(params.workflow)
if (isLtxWorkflow(version) && !ltxWorkflowEnabled()) {
throw new Error(LTX_DISABLED_MESSAGE)
}
const version = coerceVideoWorkflow(params.workflow)
if (isLtxWorkflow(version)) return buildLtxWorkflow(params, version)
const graph = structuredClone(templateFor(version === 't2v' ? 'v1' : version === 'v2' ? 'v2' : 'v1'))