Compare commits
7
Commits
2b603b1d58
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e83ef1c6c2 | ||
|
|
ab1d6acb2d | ||
|
|
7fd040ad62 | ||
|
|
8c9b4d5f7d | ||
|
|
1834ac4af9 | ||
|
|
96776ed493 | ||
|
|
08caeb51de |
+2
-8
@@ -29,15 +29,9 @@ NUXT_OIDC_AUTHORIZE_URL=https://auth.carrgarage.com/application/o/authorize/
|
|||||||
NUXT_OIDC_TOKEN_URL=http://192.168.77.2:9000/application/o/token/
|
NUXT_OIDC_TOKEN_URL=http://192.168.77.2:9000/application/o/token/
|
||||||
LIBRARY_DIR=/data/library
|
LIBRARY_DIR=/data/library
|
||||||
|
|
||||||
# AIGen → xAIGen still backup. Defaults live in the app. Override only if you need a different host or secret.
|
# Private password login (optional)
|
||||||
# BACKUP_STUDIO_URL=https://xaigen.carrgarage.com
|
|
||||||
# BACKUP_STUDIO_TOKEN=
|
|
||||||
# BACKUP_INGEST_TOKEN=
|
|
||||||
|
|
||||||
# Private clone (xaigen): password login, isolated library, Comfy prefix
|
|
||||||
# AUTH_MODE=password
|
# AUTH_MODE=password
|
||||||
# NUXT_PUBLIC_INSTANCE_NAME=xAIGen
|
# NUXT_PUBLIC_INSTANCE_NAME=AIGen
|
||||||
# NUXT_PUBLIC_STUDIO=xaigen
|
|
||||||
# AUTH_USERNAME=
|
# AUTH_USERNAME=
|
||||||
# AUTH_PASSWORD=
|
# AUTH_PASSWORD=
|
||||||
# COMFY_FILENAME_PREFIX=video/xAIGen
|
# COMFY_FILENAME_PREFIX=video/xAIGen
|
||||||
|
|||||||
@@ -5,14 +5,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { isXaigenStudio } from '~/utils/videoModels'
|
|
||||||
|
|
||||||
const config = useRuntimeConfig()
|
|
||||||
useHead({
|
useHead({
|
||||||
link: [{
|
link: [{
|
||||||
rel: 'icon',
|
rel: 'icon',
|
||||||
type: 'image/svg+xml',
|
type: 'image/svg+xml',
|
||||||
href: isXaigenStudio(config.public) ? '/favicon.svg' : '/favicon-aigen.svg'
|
href: '/favicon-aigen.svg'
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -21,27 +21,7 @@
|
|||||||
</svg>
|
</svg>
|
||||||
<span class="mt-3 block font-display text-lg font-bold text-zinc-100">Video</span>
|
<span class="mt-3 block font-display text-lg font-bold text-zinc-100">Video</span>
|
||||||
</button>
|
</button>
|
||||||
<div v-if="ltxEnabled" class="grid grid-cols-2 border-t border-white/10">
|
<p class="border-t border-white/10 px-4 py-2 text-xs text-zinc-500">MiniMax H3</p>
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="border-r border-white/10 px-3 py-2.5 text-left text-sm transition"
|
|
||||||
:class="engineBtnClass(current === 'video' && videoEngine === 'minimax')"
|
|
||||||
@click="pickVideo('minimax')"
|
|
||||||
>
|
|
||||||
<span class="block font-semibold">MiniMax</span>
|
|
||||||
<span class="text-xs opacity-80">H3</span>
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="px-3 py-2.5 text-left text-sm transition"
|
|
||||||
:class="engineBtnClass(current === 'video' && videoEngine === 'ltx')"
|
|
||||||
@click="pickVideo('ltx')"
|
|
||||||
>
|
|
||||||
<span class="block font-semibold">LTX</span>
|
|
||||||
<span class="text-xs opacity-80">2.3</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<p v-else class="border-t border-white/10 px-4 py-2 text-xs text-zinc-500">MiniMax H3</p>
|
|
||||||
<p class="border-t border-white/10 px-4 py-2 text-xs text-zinc-400">{{ videoStart === 'still' ? 'Image to video' : 'Text to video' }} · automatic</p>
|
<p class="border-t border-white/10 px-4 py-2 text-xs text-zinc-400">{{ videoStart === 'still' ? 'Image to video' : 'Text to video' }} · automatic</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -117,13 +97,11 @@
|
|||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
current: 'video' | 'image' | 'music'
|
current: 'video' | 'image' | 'music'
|
||||||
advanced?: boolean
|
advanced?: boolean
|
||||||
ltxEnabled?: boolean
|
videoEngine?: 'minimax'
|
||||||
videoEngine?: 'minimax' | 'ltx'
|
|
||||||
videoStart?: 'still' | 'text'
|
videoStart?: 'still' | 'text'
|
||||||
imageEngine?: 'flux' | 'krea' | 'moss'
|
imageEngine?: 'flux' | 'krea' | 'moss'
|
||||||
musicEngine?: 'yue2'
|
musicEngine?: 'yue2'
|
||||||
}>(), {
|
}>(), {
|
||||||
ltxEnabled: false,
|
|
||||||
videoEngine: 'minimax',
|
videoEngine: 'minimax',
|
||||||
videoStart: 'still',
|
videoStart: 'still',
|
||||||
imageEngine: 'flux',
|
imageEngine: 'flux',
|
||||||
@@ -132,22 +110,22 @@ const props = withDefaults(defineProps<{
|
|||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
select: [kind: 'video' | 'image']
|
select: [kind: 'video' | 'image']
|
||||||
'video-engine': [engine: 'minimax' | 'ltx']
|
'video-engine': [engine: 'minimax']
|
||||||
'image-engine': [engine: 'flux' | 'krea' | 'moss']
|
'image-engine': [engine: 'flux' | 'krea' | 'moss']
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
function engineBtnClass(active: boolean) {
|
function engineBtnClass(active: boolean) {
|
||||||
if (active) return 'bg-amber-400/15 text-amber-100'
|
if (active) return 'bg-amber-400/15 text-amber-100'
|
||||||
return 'text-zinc-400 hover:bg-white/5 hover:text-zinc-200'
|
return 'hover:bg-white/5'
|
||||||
}
|
}
|
||||||
|
|
||||||
function pickVideo(engine: 'minimax' | 'ltx') {
|
function pickVideo(engine: 'minimax') {
|
||||||
emit('video-engine', engine)
|
emit('video-engine', engine)
|
||||||
if (props.current !== 'video') emit('select', 'video')
|
emit('select', 'video')
|
||||||
}
|
}
|
||||||
|
|
||||||
function pickImage(engine: 'flux' | 'krea' | 'moss') {
|
function pickImage(engine: 'flux' | 'krea' | 'moss') {
|
||||||
emit('image-engine', engine)
|
emit('image-engine', engine)
|
||||||
if (props.current !== 'image') emit('select', 'image')
|
emit('select', 'image')
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -82,12 +82,6 @@
|
|||||||
<section v-if="photosPlanState.show" class="photos-section" aria-label="Photos">
|
<section v-if="photosPlanState.show" class="photos-section" aria-label="Photos">
|
||||||
<div class="photos-head">
|
<div class="photos-head">
|
||||||
<span class="field-label">Photos</span>
|
<span class="field-label">Photos</span>
|
||||||
<button
|
|
||||||
v-if="!photosPlanState.handoffReadonly"
|
|
||||||
type="button"
|
|
||||||
class="photos-inputs-toggle"
|
|
||||||
@click="hideInputs=!hideInputs"
|
|
||||||
>{{ hideInputs ? 'Show inputs' : 'Hide inputs' }}</button>
|
|
||||||
</div>
|
</div>
|
||||||
<p v-if="photosPlanState.handoffReadonly" class="text-[var(--type-sm)] text-[var(--muted)]">Continues from last frame</p>
|
<p v-if="photosPlanState.handoffReadonly" class="text-[var(--type-sm)] text-[var(--muted)]">Continues from last frame</p>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
@@ -97,7 +91,6 @@
|
|||||||
:key="'photo-'+index+'-'+card.stillId"
|
:key="'photo-'+index+'-'+card.stillId"
|
||||||
:asset="stillById(card.stillId)"
|
:asset="stillById(card.stillId)"
|
||||||
:version="library.catalogEpoch || 0"
|
:version="library.catalogEpoch || 0"
|
||||||
:hidden="hideInputs"
|
|
||||||
:role="card.role"
|
:role="card.role"
|
||||||
:role-options="photoRoleOptions"
|
:role-options="photoRoleOptions"
|
||||||
@pick="picker='photo:'+index"
|
@pick="picker='photo:'+index"
|
||||||
@@ -225,8 +218,6 @@
|
|||||||
<label class="inline-flex items-center gap-1.5"><input v-model="form.lockFace" type="checkbox" class="accent-[var(--amber)]">Lock face</label>
|
<label class="inline-flex items-center gap-1.5"><input v-model="form.lockFace" type="checkbox" class="accent-[var(--amber)]">Lock face</label>
|
||||||
<label class="inline-flex items-center gap-1.5"><input v-model="form.lockOutfit" type="checkbox" class="accent-[var(--amber)]">Lock outfit</label>
|
<label class="inline-flex items-center gap-1.5"><input v-model="form.lockOutfit" type="checkbox" class="accent-[var(--amber)]">Lock outfit</label>
|
||||||
</template>
|
</template>
|
||||||
<label v-if="xaigen" class="inline-flex items-center gap-1.5"><input v-model="classicHideInput" type="checkbox" class="accent-[var(--amber)]">Hide input</label>
|
|
||||||
<label v-if="xaigen" class="inline-flex items-center gap-1.5"><input v-model="classicHideOutput" type="checkbox" class="accent-[var(--amber)]">Hide output</label>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="center-stack">
|
<div class="center-stack">
|
||||||
@@ -465,14 +456,6 @@
|
|||||||
<label class="slot-upload">Upload from disk
|
<label class="slot-upload">Upload from disk
|
||||||
<input type="file" accept="image/*" class="sr-only" :disabled="uploading" @change="uploadPickerFile">
|
<input type="file" accept="image/*" class="sr-only" :disabled="uploading" @change="uploadPickerFile">
|
||||||
</label>
|
</label>
|
||||||
<button
|
|
||||||
v-if="xaigen && pickerAssets.length"
|
|
||||||
type="button"
|
|
||||||
class="text-[var(--type-sm)]"
|
|
||||||
:class="pickerRevealAll ? 'text-[var(--amber)]' : 'text-[var(--muted)]'"
|
|
||||||
:title="pickerRevealAll ? 'Hide all thumbnails in this picker' : 'Reveal all thumbnails in this picker'"
|
|
||||||
@click="pickerRevealAll=!pickerRevealAll"
|
|
||||||
>{{ pickerRevealAll ? 'Hide all' : 'Reveal all' }}</button>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="grid grid-cols-2 gap-3 sm:grid-cols-4 lg:grid-cols-5">
|
<div class="grid grid-cols-2 gap-3 sm:grid-cols-4 lg:grid-cols-5">
|
||||||
<button v-for="a in pickerAssets" :key="a.id" type="button" class="rounded-[var(--radius)] border border-[var(--line)] p-2 text-left" @click="pickAsset(a)">
|
<button v-for="a in pickerAssets" :key="a.id" type="button" class="rounded-[var(--radius)] border border-[var(--line)] p-2 text-left" @click="pickAsset(a)">
|
||||||
@@ -492,7 +475,7 @@ import {createLoraMemory,loraUse} from '~/shared/studio2/lora-memory.mjs'
|
|||||||
import {filterLorasForStudio,filterLorasForUse} from '~/utils/loras'
|
import {filterLorasForStudio,filterLorasForUse} from '~/utils/loras'
|
||||||
import {sectionsFrom} from '~/shared/studio2/contracts.mjs'
|
import {sectionsFrom} from '~/shared/studio2/contracts.mjs'
|
||||||
import {aspectOptions,resolveSize,bindClip,restoreAll,useAsSource,hydrateStudio2Job} from '~/shared/studio2/input.mjs'
|
import {aspectOptions,resolveSize,bindClip,restoreAll,useAsSource,hydrateStudio2Job} from '~/shared/studio2/input.mjs'
|
||||||
import {folderAssets,newestOutput,assetLabel,reconcileSelection,previewHidden,folderImageCount,libraryAfterWipe,libraryMediaUrl} from '~/shared/studio2/viewer.mjs'
|
import {folderAssets,newestOutput,assetLabel,reconcileSelection,folderImageCount,libraryAfterWipe,libraryMediaUrl} from '~/shared/studio2/viewer.mjs'
|
||||||
import {queueJobs,queueEngineLabel,jobStageLabel,jobProgressView,elapsedSeconds} from '~/shared/studio2/queue-view.mjs'
|
import {queueJobs,queueEngineLabel,jobStageLabel,jobProgressView,elapsedSeconds} from '~/shared/studio2/queue-view.mjs'
|
||||||
import {gpuStatus} from '~/shared/studio2/status.mjs'
|
import {gpuStatus} from '~/shared/studio2/status.mjs'
|
||||||
import {CAPTION_STYLES} from '~/shared/caption.mjs'
|
import {CAPTION_STYLES} from '~/shared/caption.mjs'
|
||||||
@@ -509,7 +492,6 @@ import {
|
|||||||
photosFromRequest
|
photosFromRequest
|
||||||
} from '~/shared/studio2/photos.mjs'
|
} from '~/shared/studio2/photos.mjs'
|
||||||
import {DEFAULT_MUSIC_LYRICS,DEFAULT_MUSIC_TAGS} from '~/utils/music'
|
import {DEFAULT_MUSIC_LYRICS,DEFAULT_MUSIC_TAGS} from '~/utils/music'
|
||||||
import {isXaigenStudio} from '~/utils/videoModels'
|
|
||||||
import {studio2EngineDefaults} from '~/shared/studio2/engine-defaults.mjs'
|
import {studio2EngineDefaults} from '~/shared/studio2/engine-defaults.mjs'
|
||||||
import {LOAD_GENERATION_PAYLOAD_KEY} from '~/utils/queuedJob'
|
import {LOAD_GENERATION_PAYLOAD_KEY} from '~/utils/queuedJob'
|
||||||
|
|
||||||
@@ -640,7 +622,6 @@ function benchDraftPayload(){
|
|||||||
engineSampling:plainEngineSamplingMap(),
|
engineSampling:plainEngineSamplingMap(),
|
||||||
batchMode:!!batchMode.value,
|
batchMode:!!batchMode.value,
|
||||||
eyeOpen:!!eyeOpen.value,
|
eyeOpen:!!eyeOpen.value,
|
||||||
hideInputs:!!hideInputs.value,
|
|
||||||
queueCollapsed:!!queueCollapsed.value,
|
queueCollapsed:!!queueCollapsed.value,
|
||||||
selectedId:typeof selected.value?.id==='string'?selected.value.id:'',
|
selectedId:typeof selected.value?.id==='string'?selected.value.id:'',
|
||||||
music:{
|
music:{
|
||||||
@@ -747,7 +728,6 @@ function restoreBenchDraft(){
|
|||||||
if(['flux','krea','qwen21','moss'].includes(form.engine)) applyEngineSampling(form.engine)
|
if(['flux','krea','qwen21','moss'].includes(form.engine)) applyEngineSampling(form.engine)
|
||||||
if(draft.batchMode!=null)batchMode.value=!!draft.batchMode
|
if(draft.batchMode!=null)batchMode.value=!!draft.batchMode
|
||||||
if(draft.eyeOpen!=null)eyeOpen.value=!!draft.eyeOpen
|
if(draft.eyeOpen!=null)eyeOpen.value=!!draft.eyeOpen
|
||||||
if(draft.hideInputs!=null)hideInputs.value=!!draft.hideInputs
|
|
||||||
if(draft.queueCollapsed!=null)queueCollapsed.value=!!draft.queueCollapsed
|
if(draft.queueCollapsed!=null)queueCollapsed.value=!!draft.queueCollapsed
|
||||||
if(draft.music){
|
if(draft.music){
|
||||||
music.tags=String(draft.music.tags||music.tags)
|
music.tags=String(draft.music.tags||music.tags)
|
||||||
@@ -803,16 +783,12 @@ function restoreDraftSelection(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const xaigen=isXaigenStudio(useRuntimeConfig().public)
|
|
||||||
const instanceName=String(useRuntimeConfig().public.instanceName || 'AIGen')
|
const instanceName=String(useRuntimeConfig().public.instanceName || 'AIGen')
|
||||||
const {displayMode,isClassic}=useDisplayMode()
|
const {displayMode,isClassic}=useDisplayMode()
|
||||||
const {isMobile}=useIsMobile()
|
const {isMobile}=useIsMobile()
|
||||||
const classicHideInput=ref(true)
|
|
||||||
const classicHideOutput=ref(true)
|
|
||||||
const picker=ref('')
|
const picker=ref('')
|
||||||
const pickerRevealAll=ref(false)
|
const pickerRevealAll=ref(false)
|
||||||
const uploading=ref(false),uploadMessage=ref('')
|
const uploading=ref(false),uploadMessage=ref('')
|
||||||
const revealed=ref<Set<string>>(new Set())
|
|
||||||
const measured=reactive<Record<string,{width:number;height:number}>>({}),seenOutputs=new Set<string>(),removedStillIds=new Set<string>(),watchedJobIds=new Set<string>()
|
const measured=reactive<Record<string,{width:number;height:number}>>({}),seenOutputs=new Set<string>(),removedStillIds=new Set<string>(),watchedJobIds=new Set<string>()
|
||||||
let holdEmptyStage=false
|
let holdEmptyStage=false
|
||||||
let libraryLoadedAt=0
|
let libraryLoadedAt=0
|
||||||
@@ -823,9 +799,8 @@ const liveMusic=ref<Record<string,any>>({})
|
|||||||
const negativeDraft=ref('')
|
const negativeDraft=ref('')
|
||||||
const libraryOpen=ref(false)
|
const libraryOpen=ref(false)
|
||||||
const stageMenu=ref<'copy'|'load'|''>('')
|
const stageMenu=ref<'copy'|'load'|''>('')
|
||||||
const eyeOpen=ref(!xaigen)
|
const eyeOpen=ref(true)
|
||||||
const hideInputs=ref(!!xaigen)
|
const form=reactive<any>({mode:'generate',engine:'flux',enhancePrompt:readStoredEnhancePrompt(),turbo:readStoredTurbo(),imageStyles:{positive:[],negative:readStoredNegatives()},lockFace:true,lockOutfit:true,hideInput:false,folderId:'',identityStillId:'',imageAId:'',imageBId:'',maskId:'',startClipId:'',endStillId:'',guides:[],photos:[],promptSections:sectionsFrom({}),settings:{aspect:'auto',fps:24,steps:24,cfg:4,seed:null,seedMode:'random',duration:5,turbo:true,loraStack:[]}})
|
||||||
const form=reactive<any>({mode:'generate',engine:'flux',enhancePrompt:readStoredEnhancePrompt(),turbo:readStoredTurbo(),imageStyles:{positive:[],negative:readStoredNegatives()},lockFace:true,lockOutfit:true,hideInput:xaigen,folderId:'',identityStillId:'',imageAId:'',imageBId:'',maskId:'',startClipId:'',endStillId:'',guides:[],photos:[],promptSections:sectionsFrom({}),settings:{aspect:'auto',fps:24,steps:24,cfg:4,seed:null,seedMode:'random',duration:5,turbo:true,loraStack:[]}})
|
|
||||||
const promptArea=ref<HTMLTextAreaElement|null>(null)
|
const promptArea=ref<HTMLTextAreaElement|null>(null)
|
||||||
const promptCaret=ref({start:0,end:0})
|
const promptCaret=ref({start:0,end:0})
|
||||||
const music=reactive({tags:DEFAULT_MUSIC_TAGS,lyrics:DEFAULT_MUSIC_LYRICS,duration:60,seed:'',name:''})
|
const music=reactive({tags:DEFAULT_MUSIC_TAGS,lyrics:DEFAULT_MUSIC_LYRICS,duration:60,seed:'',name:''})
|
||||||
@@ -833,9 +808,9 @@ const tagsPlaceholder=DEFAULT_MUSIC_TAGS,lyricsPlaceholder=DEFAULT_MUSIC_LYRICS
|
|||||||
const captionStyles=CAPTION_STYLES
|
const captionStyles=CAPTION_STYLES
|
||||||
const captionStyle=ref('descriptive')
|
const captionStyle=ref('descriptive')
|
||||||
const liveCaption=ref<Record<string,any>>({})
|
const liveCaption=ref<Record<string,any>>({})
|
||||||
let loraMemory=createLoraMemory(xaigen)
|
let loraMemory=createLoraMemory()
|
||||||
const currentLoraUse=computed(()=>loraUse(form))
|
const currentLoraUse=computed(()=>loraUse(form))
|
||||||
const pickerLoras=computed(()=>!xaigen && currentLoraUse.value==='ltx'?[]:filterLorasForUse(filterLorasForStudio([...loraNames.value.image,...loraNames.value.video],xaigen),currentLoraUse.value))
|
const pickerLoras=computed(()=>filterLorasForUse(filterLorasForStudio([...loraNames.value.image,...loraNames.value.video]),currentLoraUse.value))
|
||||||
watch(()=>[currentLoraUse.value,form.settings.loraStack],()=>loraMemory.sync(form),{deep:true,flush:'sync'})
|
watch(()=>[currentLoraUse.value,form.settings.loraStack],()=>loraMemory.sync(form),{deep:true,flush:'sync'})
|
||||||
const route=useRoute()
|
const route=useRoute()
|
||||||
const tasks=['generate','edit','compose','refine','video','extend','music']
|
const tasks=['generate','edit','compose','refine','video','extend','music']
|
||||||
@@ -860,8 +835,7 @@ const qwenAllowed=computed(()=>['generate','edit'].includes(form.mode))
|
|||||||
const engineOptions=computed(()=>{
|
const engineOptions=computed(()=>{
|
||||||
if(video.value){
|
if(video.value){
|
||||||
return [
|
return [
|
||||||
{value:'minimax',label:'MiniMax H3',disabled:false,hint:''},
|
{value:'minimax',label:'MiniMax H3',disabled:false,hint:''}
|
||||||
{value:'ltx',label:'LTX',disabled:!xaigen,hint:xaigen?'':'xAIGen only'}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
@@ -877,7 +851,7 @@ function defaultSamplingFor(engine:string){
|
|||||||
return {steps:form.turbo?6:d.steps,cfg:d.cfg}
|
return {steps:form.turbo?6:d.steps,cfg:d.cfg}
|
||||||
}
|
}
|
||||||
if(engine==='moss') return studio2EngineDefaults('moss')
|
if(engine==='moss') return studio2EngineDefaults('moss')
|
||||||
if(engine==='minimax' || engine==='ltx') return {steps:8,cfg:1.5}
|
if(engine==='minimax') return {steps:8,cfg:1.5}
|
||||||
return studio2EngineDefaults(engine==='krea'?'krea':'flux')
|
return studio2EngineDefaults(engine==='krea'?'krea':'flux')
|
||||||
}
|
}
|
||||||
function rememberEngineSampling(engine:string){
|
function rememberEngineSampling(engine:string){
|
||||||
@@ -963,7 +937,6 @@ watch(()=>form.folderId,(id,prev)=>{
|
|||||||
form.photos=[]
|
form.photos=[]
|
||||||
form.startClipId=''
|
form.startClipId=''
|
||||||
}
|
}
|
||||||
loadRevealed(id)
|
|
||||||
if(import.meta.client && form.engine!=='qwen21'){
|
if(import.meta.client && form.engine!=='qwen21'){
|
||||||
const hero=localStorage.getItem(`studio2-hero:${id}`)||''
|
const hero=localStorage.getItem(`studio2-hero:${id}`)||''
|
||||||
form.identityStillId=hero && !removedStillIds.has(hero)?hero:''
|
form.identityStillId=hero && !removedStillIds.has(hero)?hero:''
|
||||||
@@ -1516,7 +1489,7 @@ function loadInputRaw(item?:any){
|
|||||||
function stillIdSet(){return new Set(stills.value.map((s:any)=>s.id))}
|
function stillIdSet(){return new Set(stills.value.map((s:any)=>s.id))}
|
||||||
function clipIdSet(){return new Set(clips.value.map((c:any)=>c.id))}
|
function clipIdSet(){return new Set(clips.value.map((c:any)=>c.id))}
|
||||||
function applyHydratedJob(saved:any,output?:any){
|
function applyHydratedJob(saved:any,output?:any){
|
||||||
const {form:next,missing}=hydrateStudio2Job(form,saved,{stillIds:stillIdSet(),clipIds:clipIdSet(),xaigen,memory:loraMemory})
|
const {form:next,missing}=hydrateStudio2Job(form,saved,{stillIds:stillIdSet(),clipIds:clipIdSet(),memory:loraMemory})
|
||||||
Object.assign(form,next)
|
Object.assign(form,next)
|
||||||
form.guides=form.guides||[]
|
form.guides=form.guides||[]
|
||||||
form.photos=photosFromRequest({...next,photos:saved.photos})
|
form.photos=photosFromRequest({...next,photos:saved.photos})
|
||||||
@@ -1575,23 +1548,15 @@ function focusQueueCard(card:any){
|
|||||||
}
|
}
|
||||||
function isHidden(asset:any){
|
function isHidden(asset:any){
|
||||||
if(!asset?.id)return false
|
if(!asset?.id)return false
|
||||||
if(isClassic.value){
|
|
||||||
const input=asset.role==='input'
|
|
||||||
return input?classicHideInput.value:classicHideOutput.value
|
|
||||||
}
|
|
||||||
// Session chrome: eye gates the stage preview across neighbors.
|
// Session chrome: eye gates the stage preview across neighbors.
|
||||||
return !eyeOpen.value
|
return !eyeOpen.value
|
||||||
}
|
}
|
||||||
function pickerThumbHidden(asset:any){
|
function pickerThumbHidden(_asset:any){
|
||||||
if(pickerRevealAll.value)return false
|
if(pickerRevealAll.value)return false
|
||||||
if(!asset?.id)return false
|
|
||||||
if(isClassic.value)return classicHideInput.value
|
|
||||||
if(xaigen) return previewHidden(asset,revealed.value,xaigen)
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
function slotHidden(_id:string){
|
function slotHidden(_id:string){
|
||||||
// Photos inspector uses hideInputs — never the output eye.
|
return false
|
||||||
return hideInputs.value
|
|
||||||
}
|
}
|
||||||
function toggleReveal(_id?:string){
|
function toggleReveal(_id?:string){
|
||||||
eyeOpen.value=!eyeOpen.value
|
eyeOpen.value=!eyeOpen.value
|
||||||
@@ -1797,7 +1762,7 @@ async function uploadPickerFile(event:Event){
|
|||||||
const key=picker.value
|
const key=picker.value
|
||||||
const photoIndex=key.startsWith('photo:')?Number(key.slice(6)):-1
|
const photoIndex=key.startsWith('photo:')?Number(key.slice(6)):-1
|
||||||
uploading.value=true;uploadMessage.value='';error.value=''
|
uploading.value=true;uploadMessage.value='';error.value=''
|
||||||
const body=new FormData();body.append('image',file);body.append('folderId',form.folderId);body.append('hideInput',String(xaigen))
|
const body=new FormData();body.append('image',file);body.append('folderId',form.folderId);body.append('hideInput','false')
|
||||||
try{
|
try{
|
||||||
const response=await $fetch<any>('/api/studio-2/stills',{method:'POST',body})
|
const response=await $fetch<any>('/api/studio-2/stills',{method:'POST',body})
|
||||||
const still=response?.still
|
const still=response?.still
|
||||||
@@ -1827,7 +1792,7 @@ async function uploadPickerFile(event:Event){
|
|||||||
async function upload(event:Event,target:'source'|'hero'){
|
async function upload(event:Event,target:'source'|'hero'){
|
||||||
const input=event.target as HTMLInputElement,file=input.files?.[0];if(!file)return
|
const input=event.target as HTMLInputElement,file=input.files?.[0];if(!file)return
|
||||||
uploading.value=true;uploadMessage.value='';error.value=''
|
uploading.value=true;uploadMessage.value='';error.value=''
|
||||||
const body=new FormData();body.append('image',file);body.append('folderId',form.folderId);body.append('hideInput',String(xaigen))
|
const body=new FormData();body.append('image',file);body.append('folderId',form.folderId);body.append('hideInput','false')
|
||||||
try{
|
try{
|
||||||
const response=await $fetch<any>('/api/studio-2/stills',{method:'POST',body})
|
const response=await $fetch<any>('/api/studio-2/stills',{method:'POST',body})
|
||||||
const still=response?.still
|
const still=response?.still
|
||||||
@@ -1854,12 +1819,6 @@ async function upload(event:Event,target:'source'|'hero'){
|
|||||||
catch(e:any){error.value=e.data?.statusMessage||e.message||'Could not save image'}
|
catch(e:any){error.value=e.data?.statusMessage||e.message||'Could not save image'}
|
||||||
finally{uploading.value=false;input.value=''}
|
finally{uploading.value=false;input.value=''}
|
||||||
}
|
}
|
||||||
function loadRevealed(folderId:string){
|
|
||||||
if(!import.meta.client||!xaigen){revealed.value=new Set();return}
|
|
||||||
try{revealed.value=new Set(JSON.parse(localStorage.getItem(`studio2-revealed:${folderId}`)||'[]'))}
|
|
||||||
catch{revealed.value=new Set()}
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(()=>sourceAsset.value?.id,id=>{
|
watch(()=>sourceAsset.value?.id,id=>{
|
||||||
const asset=sourceAsset.value
|
const asset=sourceAsset.value
|
||||||
if(!import.meta.client||!asset||measured[id])return
|
if(!import.meta.client||!asset||measured[id])return
|
||||||
@@ -1883,10 +1842,10 @@ function chooseTask(task:string){
|
|||||||
if(task==='music'){form.mode='music';return}
|
if(task==='music'){form.mode='music';return}
|
||||||
if(task==='extend'){
|
if(task==='extend'){
|
||||||
form.mode='extend'
|
form.mode='extend'
|
||||||
form.engine=xaigen && form.engine==='ltx'?'ltx':'minimax'
|
form.engine='minimax'
|
||||||
const clip=selected.value?.kind==='clip'?selected.value:clips.value.find((c:any)=>c.id===form.startClipId)
|
const clip=selected.value?.kind==='clip'?selected.value:clips.value.find((c:any)=>c.id===form.startClipId)
|
||||||
if(clip?.id){
|
if(clip?.id){
|
||||||
try{Object.assign(form,bindClip(form,clip,xaigen,loraMemory))}
|
try{Object.assign(form,bindClip(form,clip,loraMemory))}
|
||||||
catch(e:any){error.value=e?.message||'Could not copy clip settings. Previous clip is still bound.';form.startClipId=clip.id}
|
catch(e:any){error.value=e?.message||'Could not copy clip settings. Previous clip is still bound.';form.startClipId=clip.id}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@@ -1894,14 +1853,14 @@ function chooseTask(task:string){
|
|||||||
const was=video.value;form.mode=task;form.startClipId=''
|
const was=video.value;form.mode=task;form.startClipId=''
|
||||||
if(video.value!==was){
|
if(video.value!==was){
|
||||||
if(was && ['flux','krea','qwen21','moss'].includes(form.engine)) rememberEngineSampling(form.engine)
|
if(was && ['flux','krea','qwen21','moss'].includes(form.engine)) rememberEngineSampling(form.engine)
|
||||||
form.engine=video.value?(xaigen && form.engine==='ltx'?'ltx':'minimax'):'flux'
|
form.engine=video.value?'minimax':'flux'
|
||||||
if(video.value){form.settings.steps=8;form.settings.cfg=1.5}
|
if(video.value){form.settings.steps=8;form.settings.cfg=1.5}
|
||||||
else applyEngineSampling(form.engine)
|
else applyEngineSampling(form.engine)
|
||||||
}
|
}
|
||||||
if(selected.value?.kind==='track' && task!=='music') selected.value=family.value.find((a:any)=>a.kind!=='track') || null
|
if(selected.value?.kind==='track' && task!=='music') selected.value=family.value.find((a:any)=>a.kind!=='track') || null
|
||||||
}
|
}
|
||||||
function onTaskSelect(event:Event){chooseTask((event.target as HTMLSelectElement).value)}
|
function onTaskSelect(event:Event){chooseTask((event.target as HTMLSelectElement).value)}
|
||||||
function chooseClip(id:string){if(!id){form.startClipId='';return}const clip=clips.value.find((c:any)=>c.id===id);if(clip){try{Object.assign(form,bindClip(form,clip,xaigen,loraMemory))}catch(e:any){error.value=e?.message||'Could not copy clip settings.';form.startClipId=clip.id;form.mode='extend';form.engine=xaigen && form.engine==='ltx'?'ltx':'minimax'}}}
|
function chooseClip(id:string){if(!id){form.startClipId='';return}const clip=clips.value.find((c:any)=>c.id===id);if(clip){try{Object.assign(form,bindClip(form,clip,loraMemory))}catch(e:any){error.value=e?.message||'Could not copy clip settings.';form.startClipId=clip.id;form.mode='extend';form.engine='minimax'}}}
|
||||||
function selectOutput(item:any){
|
function selectOutput(item:any){
|
||||||
stageMenu.value=''
|
stageMenu.value=''
|
||||||
if(!item?.id || forgottenStillIds.value.has(item.id) || removedStillIds.has(item.id)){
|
if(!item?.id || forgottenStillIds.value.has(item.id) || removedStillIds.has(item.id)){
|
||||||
@@ -1925,7 +1884,7 @@ function selectOutput(item:any){
|
|||||||
selectionPinned.value=true
|
selectionPinned.value=true
|
||||||
if(form.mode==='extend' && item?.kind==='clip')chooseClip(item.id)
|
if(form.mode==='extend' && item?.kind==='clip')chooseClip(item.id)
|
||||||
}
|
}
|
||||||
function restore(item:any){Object.assign(form,restoreAll(form,item,xaigen,loraMemory));form.guides=form.guides||[];batchText.value=''}
|
function restore(item:any){Object.assign(form,restoreAll(form,item,loraMemory));form.guides=form.guides||[];batchText.value=''}
|
||||||
function focusJob(job:any){selectOutput(job.outputs?.at(-1)||null);focusedJobId.value=job.id}
|
function focusJob(job:any){selectOutput(job.outputs?.at(-1)||null);focusedJobId.value=job.id}
|
||||||
async function loadLoras(fresh=false){try{loraNames.value=await $fetch('/api/studio-2/loras'+(fresh?'?fresh=1':''))}catch{error.value='Could not refresh LoRAs. The last loaded list is still available.'}}
|
async function loadLoras(fresh=false){try{loraNames.value=await $fetch('/api/studio-2/loras'+(fresh?'?fresh=1':''))}catch{error.value='Could not refresh LoRAs. The last loaded list is still available.'}}
|
||||||
async function clearFinished(){await $fetch('/api/studio-2/clear-finished',{method:'POST'});await refreshJobs()}
|
async function clearFinished(){await $fetch('/api/studio-2/clear-finished',{method:'POST'});await refreshJobs()}
|
||||||
@@ -2114,7 +2073,7 @@ async function queue(){
|
|||||||
turbo:!!form.turbo,
|
turbo:!!form.turbo,
|
||||||
lockFace:!!form.lockFace,
|
lockFace:!!form.lockFace,
|
||||||
lockOutfit:!!form.lockOutfit,
|
lockOutfit:!!form.lockOutfit,
|
||||||
hideInput:!!xaigen,
|
hideInput:!!form.hideInput,
|
||||||
hideOutput:false,
|
hideOutput:false,
|
||||||
imageAId:String(form.imageAId||''),
|
imageAId:String(form.imageAId||''),
|
||||||
imageBId:String(form.imageBId||''),
|
imageBId:String(form.imageBId||''),
|
||||||
@@ -2260,7 +2219,7 @@ async function fetchHealth(){
|
|||||||
watch(()=>[
|
watch(()=>[
|
||||||
form.mode,form.engine,form.folderId,form.enhancePrompt,form.turbo,form.lockFace,form.lockOutfit,
|
form.mode,form.engine,form.folderId,form.enhancePrompt,form.turbo,form.lockFace,form.lockOutfit,
|
||||||
form.promptSections,form.photos,form.imageStyles,form.settings,
|
form.promptSections,form.photos,form.imageStyles,form.settings,
|
||||||
eyeOpen.value,hideInputs.value,batchMode.value,queueCollapsed.value,
|
eyeOpen.value,batchMode.value,queueCollapsed.value,
|
||||||
music.tags,music.lyrics,music.duration,music.seed,music.name
|
music.tags,music.lyrics,music.duration,music.seed,music.name
|
||||||
],()=>saveBenchDraft(),{deep:true})
|
],()=>saveBenchDraft(),{deep:true})
|
||||||
function onPageHide(){saveBenchDraft(true)}
|
function onPageHide(){saveBenchDraft(true)}
|
||||||
@@ -2274,12 +2233,11 @@ let timer:ReturnType<typeof setTimeout>,clock:ReturnType<typeof setInterval>,dis
|
|||||||
onMounted(()=>{
|
onMounted(()=>{
|
||||||
submitting.value=false
|
submitting.value=false
|
||||||
let storage;try{storage=localStorage}catch{}
|
let storage;try{storage=localStorage}catch{}
|
||||||
loraMemory=createLoraMemory(xaigen,storage);loraMemory.sync(form);form.settings.seed=randomSeed()
|
loraMemory=createLoraMemory(storage);loraMemory.sync(form);form.settings.seed=randomSeed()
|
||||||
// First paint in ~2s: chrome + draft. Do not await library before the prompt works.
|
// First paint in ~2s: chrome + draft. Do not await library before the prompt works.
|
||||||
restoreBenchDraft()
|
restoreBenchDraft()
|
||||||
if(['flux','krea','qwen21','moss'].includes(form.engine)) rememberEngineSampling(form.engine)
|
if(['flux','krea','qwen21','moss'].includes(form.engine)) rememberEngineSampling(form.engine)
|
||||||
if(!form.folderId && library.value.folders?.[0]?.id) form.folderId=library.value.folders[0].id
|
if(!form.folderId && library.value.folders?.[0]?.id) form.folderId=library.value.folders[0].id
|
||||||
loadRevealed(form.folderId)
|
|
||||||
clock=setInterval(()=>{now.value=Date.now()},1000)
|
clock=setInterval(()=>{now.value=Date.now()},1000)
|
||||||
void loadLoras(false)
|
void loadLoras(false)
|
||||||
// Folder page in background — never blocks Generate / prompt
|
// Folder page in background — never blocks Generate / prompt
|
||||||
@@ -2288,11 +2246,10 @@ onMounted(()=>{
|
|||||||
restoreDraftSelection()
|
restoreDraftSelection()
|
||||||
clearRefsMissingFromLibrary()
|
clearRefsMissingFromLibrary()
|
||||||
if(!form.folderId)form.folderId=library.value.folders[0]?.id||''
|
if(!form.folderId)form.folderId=library.value.folders[0]?.id||''
|
||||||
loadRevealed(form.folderId)
|
|
||||||
void applyIncomingGenerationLoad()
|
void applyIncomingGenerationLoad()
|
||||||
const id=String(route.query.still||route.query.clip||route.query.track||'')
|
const id=String(route.query.still||route.query.clip||route.query.track||'')
|
||||||
const asset=[...library.value.stills,...library.value.clips,...(library.value.tracks||[])].find((a:any)=>a.id===id)
|
const asset=[...library.value.stills,...library.value.clips,...(library.value.tracks||[])].find((a:any)=>a.id===id)
|
||||||
if(asset){selected.value={...asset,kind:route.query.clip?'clip':route.query.track?'track':'still'};if(route.query.use==='1'&&selected.value.kind!=='track')restore(selected.value);if(xaigen)toggleReveal(asset.id)}
|
if(asset){selected.value={...asset,kind:route.query.clip?'clip':route.query.track?'track':'still'};if(route.query.use==='1'&&selected.value.kind!=='track')restore(selected.value)}
|
||||||
if(route.query.task==='music')form.mode='music'
|
if(route.query.task==='music')form.mode='music'
|
||||||
}).catch((e:any)=>{error.value=e.data?.statusMessage||e.message})
|
}).catch((e:any)=>{error.value=e.data?.statusMessage||e.message})
|
||||||
// Idle poll: jobs + health only — 800ms health budget, chip GPU ? on miss
|
// Idle poll: jobs + health only — 800ms health budget, chip GPU ? on miss
|
||||||
@@ -2330,7 +2287,6 @@ function setPicker(key:string){picker.value=key}
|
|||||||
|
|
||||||
const mobileCtx=computed(()=>({
|
const mobileCtx=computed(()=>({
|
||||||
instanceName,
|
instanceName,
|
||||||
xaigen,
|
|
||||||
form,
|
form,
|
||||||
music,
|
music,
|
||||||
library:library.value,
|
library:library.value,
|
||||||
@@ -2355,13 +2311,11 @@ const mobileCtx=computed(()=>({
|
|||||||
selectedTrackLive:selectedTrackLive.value,
|
selectedTrackLive:selectedTrackLive.value,
|
||||||
libraryOpen:libraryOpen.value,
|
libraryOpen:libraryOpen.value,
|
||||||
eyeOpen:eyeOpen.value,
|
eyeOpen:eyeOpen.value,
|
||||||
hideInputs:hideInputs.value,
|
|
||||||
photoFilledCount:photoFilledCount.value,
|
photoFilledCount:photoFilledCount.value,
|
||||||
clearPrompt,
|
clearPrompt,
|
||||||
openLibrary:()=>{libraryOpen.value=true},
|
openLibrary:()=>{libraryOpen.value=true},
|
||||||
closeLibrary:()=>{libraryOpen.value=false},
|
closeLibrary:()=>{libraryOpen.value=false},
|
||||||
toggleHideInputs:()=>{hideInputs.value=!hideInputs.value;saveBenchDraft(true)},
|
showInputsAndAddPhoto:()=>{addPhoto()},
|
||||||
showInputsAndAddPhoto:()=>{hideInputs.value=false;addPhoto()},
|
|
||||||
sourceSlot:sourceSlot.value,
|
sourceSlot:sourceSlot.value,
|
||||||
video:video.value,
|
video:video.value,
|
||||||
submitting:submitting.value,
|
submitting:submitting.value,
|
||||||
|
|||||||
@@ -193,17 +193,11 @@
|
|||||||
<p class="m-muted">Continues from last frame</p>
|
<p class="m-muted">Continues from last frame</p>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<div class="m-photos-head">
|
|
||||||
<button type="button" class="m-link" @click="ctx.toggleHideInputs()">
|
|
||||||
{{ ctx.hideInputs ? 'Show inputs' : 'Hide inputs' }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<p v-if="!ctx.form.photos?.length && ctx.photosPlanState.emptyHint" class="m-muted">{{ ctx.photosPlanState.emptyHint }}</p>
|
<p v-if="!ctx.form.photos?.length && ctx.photosPlanState.emptyHint" class="m-muted">{{ ctx.photosPlanState.emptyHint }}</p>
|
||||||
<Studio2AssetSlot
|
<Studio2AssetSlot
|
||||||
v-for="(card, index) in ctx.form.photos"
|
v-for="(card, index) in ctx.form.photos"
|
||||||
:key="'m-photo-'+index+'-'+card.stillId"
|
:key="'m-photo-'+index+'-'+card.stillId"
|
||||||
:asset="ctx.stillById(card.stillId)"
|
:asset="ctx.stillById(card.stillId)"
|
||||||
:hidden="!!ctx.hideInputs"
|
|
||||||
:role="card.role"
|
:role="card.role"
|
||||||
:role-options="ctx.photoRoleOptions"
|
:role-options="ctx.photoRoleOptions"
|
||||||
@pick="ctx.setPicker('photo:'+index)"
|
@pick="ctx.setPicker('photo:'+index)"
|
||||||
|
|||||||
+2
-11
@@ -1,6 +1,3 @@
|
|||||||
const xaigenStudio = /^xaigen$/i.test(String(process.env.NUXT_PUBLIC_STUDIO || '').trim())
|
|
||||||
|| /xaigen/i.test(String(process.env.NUXT_PUBLIC_INSTANCE_NAME || '').trim())
|
|
||||||
|
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
compatibilityDate: '2025-08-01',
|
compatibilityDate: '2025-08-01',
|
||||||
modules: ['@nuxtjs/tailwindcss'],
|
modules: ['@nuxtjs/tailwindcss'],
|
||||||
@@ -16,7 +13,7 @@ export default defineNuxtConfig({
|
|||||||
{ name: 'description', content: 'Headless MiniMax H3 image-to-video studio relayed to local ComfyUI.' }
|
{ name: 'description', content: 'Headless MiniMax H3 image-to-video studio relayed to local ComfyUI.' }
|
||||||
],
|
],
|
||||||
link: [
|
link: [
|
||||||
{ rel: 'icon', type: 'image/svg+xml', href: xaigenStudio ? '/favicon.svg' : '/favicon-aigen.svg' },
|
{ rel: 'icon', type: 'image/svg+xml', href: '/favicon-aigen.svg' },
|
||||||
{ rel: 'preconnect', href: 'https://fonts.googleapis.com' },
|
{ rel: 'preconnect', href: 'https://fonts.googleapis.com' },
|
||||||
{ rel: 'preconnect', href: 'https://fonts.gstatic.com', crossorigin: '' },
|
{ rel: 'preconnect', href: 'https://fonts.gstatic.com', crossorigin: '' },
|
||||||
{
|
{
|
||||||
@@ -53,9 +50,6 @@ export default defineNuxtConfig({
|
|||||||
authMode: process.env.NUXT_AUTH_MODE || process.env.AUTH_MODE || '',
|
authMode: process.env.NUXT_AUTH_MODE || process.env.AUTH_MODE || '',
|
||||||
authUsername: process.env.AUTH_USERNAME || '',
|
authUsername: process.env.AUTH_USERNAME || '',
|
||||||
authPassword: process.env.AUTH_PASSWORD || '',
|
authPassword: process.env.AUTH_PASSWORD || '',
|
||||||
backupStudioUrl: process.env.BACKUP_STUDIO_URL ?? (xaigenStudio ? '' : 'https://xaigen.carrgarage.com'),
|
|
||||||
backupStudioToken: process.env.BACKUP_STUDIO_TOKEN || 'carr-aigen-xaigen-backup',
|
|
||||||
backupIngestToken: process.env.BACKUP_INGEST_TOKEN || 'carr-aigen-xaigen-backup',
|
|
||||||
purgeComfyOutputs: process.env.PURGE_COMFY_OUTPUTS !== 'false',
|
purgeComfyOutputs: process.env.PURGE_COMFY_OUTPUTS !== 'false',
|
||||||
comfyFilenamePrefix: process.env.COMFY_FILENAME_PREFIX || 'video/MiniMax_H3',
|
comfyFilenamePrefix: process.env.COMFY_FILENAME_PREFIX || 'video/MiniMax_H3',
|
||||||
comfyAudioPrefix: process.env.COMFY_AUDIO_PREFIX || 'audio/AIGen',
|
comfyAudioPrefix: process.env.COMFY_AUDIO_PREFIX || 'audio/AIGen',
|
||||||
@@ -65,10 +59,7 @@ export default defineNuxtConfig({
|
|||||||
authEnabled: process.env.NUXT_PUBLIC_AUTH_ENABLED === 'true',
|
authEnabled: process.env.NUXT_PUBLIC_AUTH_ENABLED === 'true',
|
||||||
authMode: process.env.NUXT_PUBLIC_AUTH_MODE || process.env.AUTH_MODE || '',
|
authMode: process.env.NUXT_PUBLIC_AUTH_MODE || process.env.AUTH_MODE || '',
|
||||||
instanceName: process.env.NUXT_PUBLIC_INSTANCE_NAME || 'AIGen',
|
instanceName: process.env.NUXT_PUBLIC_INSTANCE_NAME || 'AIGen',
|
||||||
// NUXT_PUBLIC_STUDIO=xaigen on the xAIGen Coolify app (LTX Pink Cherry + xAIGen-prefixed LoRAs)
|
kreaConceptLora: process.env.NUXT_PUBLIC_KREA_CONCEPT_LORA || process.env.NUXT_KREA_CONCEPT_LORA || ''
|
||||||
studio: process.env.NUXT_PUBLIC_STUDIO || '',
|
|
||||||
kreaConceptLora: process.env.NUXT_PUBLIC_KREA_CONCEPT_LORA || process.env.NUXT_KREA_CONCEPT_LORA || '',
|
|
||||||
backupStudioEnabled: !xaigenStudio
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
nitro: {
|
nitro: {
|
||||||
|
|||||||
+1
-28
@@ -386,13 +386,6 @@
|
|||||||
:disabled="keepingInputBusy"
|
:disabled="keepingInputBusy"
|
||||||
@click="saveFocusedAsInput"
|
@click="saveFocusedAsInput"
|
||||||
>{{ keepingInputBusy ? 'Saving…' : 'Save as input' }}</button>
|
>{{ keepingInputBusy ? 'Saving…' : 'Save as input' }}</button>
|
||||||
<button
|
|
||||||
v-if="focused.kind === 'still' && backupStudioEnabled"
|
|
||||||
type="button"
|
|
||||||
class="rounded-full border border-white/10 px-3 py-1.5 text-xs text-zinc-300 hover:text-white"
|
|
||||||
:disabled="backupBusy"
|
|
||||||
@click="sendFocusedToBackup"
|
|
||||||
>{{ backupBusy ? 'Sending…' : 'Send to Backup' }}</button>
|
|
||||||
<a
|
<a
|
||||||
v-if="downloadHref"
|
v-if="downloadHref"
|
||||||
:href="downloadHref"
|
:href="downloadHref"
|
||||||
@@ -557,7 +550,6 @@ import {
|
|||||||
type LibraryTrack
|
type LibraryTrack
|
||||||
} from '~/utils/libraryBrowse'
|
} from '~/utils/libraryBrowse'
|
||||||
import { libraryAfterWipe, libraryMediaUrl, mergeLibraryRows } from '~/shared/studio2/viewer.mjs'
|
import { libraryAfterWipe, libraryMediaUrl, mergeLibraryRows } from '~/shared/studio2/viewer.mjs'
|
||||||
import { isXaigenStudio } from '~/utils/videoModels'
|
|
||||||
import { clipSettingsRows, stillSettingsRows, trackSettingsRows } from '~/utils/libraryGeneration'
|
import { clipSettingsRows, stillSettingsRows, trackSettingsRows } from '~/utils/libraryGeneration'
|
||||||
|
|
||||||
const CARD_MIN = 156
|
const CARD_MIN = 156
|
||||||
@@ -574,12 +566,7 @@ const filterOptions = [
|
|||||||
|
|
||||||
const runtimeConfig = useRuntimeConfig()
|
const runtimeConfig = useRuntimeConfig()
|
||||||
const instanceName = ref(String(runtimeConfig.public.instanceName || 'AIGen'))
|
const instanceName = ref(String(runtimeConfig.public.instanceName || 'AIGen'))
|
||||||
const backupStudioEnabled = computed(() => Boolean(runtimeConfig.public.backupStudioEnabled))
|
const showPrivacyToggles = computed(() => false)
|
||||||
const backupBusy = ref(false)
|
|
||||||
const showPrivacyToggles = computed(() => isXaigenStudio({
|
|
||||||
studio: runtimeConfig.public.studio,
|
|
||||||
instanceName: runtimeConfig.public.instanceName || instanceName.value
|
|
||||||
}))
|
|
||||||
const folders = ref<LibraryFolder[]>([])
|
const folders = ref<LibraryFolder[]>([])
|
||||||
const clips = ref<LibraryClip[]>([])
|
const clips = ref<LibraryClip[]>([])
|
||||||
const stills = ref<LibraryStill[]>([])
|
const stills = ref<LibraryStill[]>([])
|
||||||
@@ -1194,20 +1181,6 @@ function useInStudio(entry: LibraryEntry) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sendFocusedToBackup() {
|
|
||||||
const still = focusedStill.value
|
|
||||||
if (!still || !backupStudioEnabled.value || backupBusy.value) return
|
|
||||||
backupBusy.value = true
|
|
||||||
try {
|
|
||||||
await $fetch(`/api/library/stills/${still.id}/backup`, { method: 'POST' })
|
|
||||||
toast('Sent to Backup')
|
|
||||||
} catch (error: any) {
|
|
||||||
toast(error?.data?.statusMessage || 'Could not send that still to Backup')
|
|
||||||
} finally {
|
|
||||||
backupBusy.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function saveFocusedAsInput() {
|
async function saveFocusedAsInput() {
|
||||||
const still = focusedStill.value
|
const still = focusedStill.value
|
||||||
if (!still || keepingInputBusy.value) return
|
if (!still || keepingInputBusy.value) return
|
||||||
|
|||||||
+21
-113
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="min-h-dvh min-w-0">
|
<div class="min-h-dvh min-w-0">
|
||||||
<AppHeader
|
<AppHeader
|
||||||
:subtitle="advanced ? (ltxEnabled ? 'MiniMax H3 · LTX-2.3 · Flux.2 Klein' : 'MiniMax H3 · Flux.2 Klein') : 'Create images, video, and music'"
|
:subtitle="advanced ? 'MiniMax H3 · Flux.2 Klein' : 'Create images, video, and music'"
|
||||||
current="studio"
|
current="studio"
|
||||||
:queue-count="queueBadgeCount"
|
:queue-count="queueBadgeCount"
|
||||||
@gpu="pollComfyHealth"
|
@gpu="pollComfyHealth"
|
||||||
@@ -11,7 +11,6 @@
|
|||||||
<StudioKindCards
|
<StudioKindCards
|
||||||
:advanced="advanced"
|
:advanced="advanced"
|
||||||
:current="imageStudio ? 'image' : 'video'"
|
:current="imageStudio ? 'image' : 'video'"
|
||||||
:ltx-enabled="ltxEnabled"
|
|
||||||
:video-engine="videoEngine"
|
:video-engine="videoEngine"
|
||||||
:video-start="videoStart"
|
:video-start="videoStart"
|
||||||
:image-engine="v2Engine"
|
:image-engine="v2Engine"
|
||||||
@@ -754,7 +753,7 @@
|
|||||||
<span>Model</span>
|
<span>Model</span>
|
||||||
<select v-if="imageStudio" :value="v2Engine" class="w-full rounded-xl border border-white/15 bg-zinc-900 p-3" @change="setV2Engine(($event.target as HTMLSelectElement).value as ImageV2Engine)"><option value="flux">Flux Klein 9B</option><option value="krea">Krea 2 Turbo</option><option value="moss">MOSS-Image</option></select>
|
<select v-if="imageStudio" :value="v2Engine" class="w-full rounded-xl border border-white/15 bg-zinc-900 p-3" @change="setV2Engine(($event.target as HTMLSelectElement).value as ImageV2Engine)"><option value="flux">Flux Klein 9B</option><option value="krea">Krea 2 Turbo</option><option value="moss">MOSS-Image</option></select>
|
||||||
<p v-if="imageStudio && v2Engine === 'moss'" class="text-[11px] leading-snug text-zinc-500">Text-to-image only. INT8 SFT, text encoder on CPU, 25 steps, CFG 2.5, shift 5. Starts at 1024×1024.</p>
|
<p v-if="imageStudio && v2Engine === 'moss'" class="text-[11px] leading-snug text-zinc-500">Text-to-image only. INT8 SFT, text encoder on CPU, 25 steps, CFG 2.5, shift 5. Starts at 1024×1024.</p>
|
||||||
<select v-else :value="videoEngine" class="w-full rounded-xl border border-white/15 bg-zinc-900 p-3" @change="selectVideoEngine(($event.target as HTMLSelectElement).value as VideoEngineId)"><option value="minimax">MiniMax H3</option><option v-if="ltxEnabled" value="ltx">LTX 2.3</option></select>
|
<select v-else :value="videoEngine" class="w-full rounded-xl border border-white/15 bg-zinc-900 p-3" @change="selectVideoEngine(($event.target as HTMLSelectElement).value as VideoEngineId)"><option value="minimax">MiniMax H3</option></select>
|
||||||
</label>
|
</label>
|
||||||
<div v-if="studioMode === 'video'" class="max-w-md space-y-2">
|
<div v-if="studioMode === 'video'" class="max-w-md space-y-2">
|
||||||
<LoraSelect
|
<LoraSelect
|
||||||
@@ -1437,15 +1436,6 @@
|
|||||||
>
|
>
|
||||||
{{ keepingInputBusy ? 'Saving…' : 'Save as input' }}
|
{{ keepingInputBusy ? 'Saving…' : 'Save as input' }}
|
||||||
</button>
|
</button>
|
||||||
<button
|
|
||||||
v-if="canUseGeneratedStill && backupStudioEnabled"
|
|
||||||
type="button"
|
|
||||||
class="inline-flex rounded-2xl border border-amber-300/40 px-4 py-2 text-sm text-amber-100 hover:border-amber-300/70 disabled:cursor-not-allowed disabled:opacity-50"
|
|
||||||
:disabled="Boolean(backupBusyId)"
|
|
||||||
@click="sendOutputStillToBackup"
|
|
||||||
>
|
|
||||||
{{ backupBusyId ? 'Sending…' : 'Send to Backup' }}
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
<div v-if="extendOpen" id="extend-clip" class="mt-4 space-y-4 rounded-2xl border border-white/10 bg-zinc-950/50 p-4">
|
<div v-if="extendOpen" id="extend-clip" class="mt-4 space-y-4 rounded-2xl border border-white/10 bg-zinc-950/50 p-4">
|
||||||
<div class="flex items-start justify-between gap-3">
|
<div class="flex items-start justify-between gap-3">
|
||||||
@@ -1649,15 +1639,6 @@
|
|||||||
>
|
>
|
||||||
{{ usingInputSettingsBusy ? 'Loading settings…' : 'Use as input' }}
|
{{ usingInputSettingsBusy ? 'Loading settings…' : 'Use as input' }}
|
||||||
</button>
|
</button>
|
||||||
<button
|
|
||||||
v-if="backupStudioEnabled"
|
|
||||||
type="button"
|
|
||||||
class="inline-flex rounded-2xl border border-amber-300/40 px-4 py-2 text-sm text-amber-100 hover:border-amber-300/70 disabled:cursor-not-allowed disabled:opacity-50"
|
|
||||||
:disabled="Boolean(backupBusyId)"
|
|
||||||
@click="sendOutputStillToBackup"
|
|
||||||
>
|
|
||||||
{{ backupBusyId ? 'Sending…' : 'Send to Backup' }}
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -2041,13 +2022,6 @@
|
|||||||
:disabled="keepingInputBusy"
|
:disabled="keepingInputBusy"
|
||||||
@click="saveStillAsInput(entry.stillGroup.head)"
|
@click="saveStillAsInput(entry.stillGroup.head)"
|
||||||
>Save as input</button>
|
>Save as input</button>
|
||||||
<button
|
|
||||||
v-if="backupStudioEnabled"
|
|
||||||
type="button"
|
|
||||||
class="text-xs text-amber-300"
|
|
||||||
:disabled="backupBusyId === entry.stillGroup.head.id"
|
|
||||||
@click="sendStillToBackup(entry.stillGroup.head)"
|
|
||||||
>{{ backupBusyId === entry.stillGroup.head.id ? 'Sending…' : 'Send to Backup' }}</button>
|
|
||||||
<button type="button" class="text-xs text-zinc-400" @click="toggleDetails(entry.key)">
|
<button type="button" class="text-xs text-zinc-400" @click="toggleDetails(entry.key)">
|
||||||
{{ expandedDetails[entry.key] ? 'Hide details' : 'Details' }}
|
{{ expandedDetails[entry.key] ? 'Hide details' : 'Details' }}
|
||||||
</button>
|
</button>
|
||||||
@@ -2124,13 +2098,6 @@
|
|||||||
:disabled="keepingInputBusy"
|
:disabled="keepingInputBusy"
|
||||||
@click="saveStillAsInput(item)"
|
@click="saveStillAsInput(item)"
|
||||||
>Save as input</button>
|
>Save as input</button>
|
||||||
<button
|
|
||||||
v-if="backupStudioEnabled"
|
|
||||||
type="button"
|
|
||||||
class="text-xs text-amber-300"
|
|
||||||
:disabled="backupBusyId === item.id"
|
|
||||||
@click="sendStillToBackup(item)"
|
|
||||||
>{{ backupBusyId === item.id ? 'Sending…' : 'Send to Backup' }}</button>
|
|
||||||
<button type="button" class="text-xs text-zinc-400" @click="toggleDetails(item.id)">
|
<button type="button" class="text-xs text-zinc-400" @click="toggleDetails(item.id)">
|
||||||
{{ expandedDetails[item.id] ? 'Hide details' : 'Details' }}
|
{{ expandedDetails[item.id] ? 'Hide details' : 'Details' }}
|
||||||
</button>
|
</button>
|
||||||
@@ -2399,8 +2366,6 @@ import {
|
|||||||
composeVideoWorkflow,
|
composeVideoWorkflow,
|
||||||
isLtxWorkflow,
|
isLtxWorkflow,
|
||||||
isTextToVideo,
|
isTextToVideo,
|
||||||
isXaigenStudio,
|
|
||||||
ltxWorkflowEnabled,
|
|
||||||
minimaxGraphOf,
|
minimaxGraphOf,
|
||||||
parseVideoWorkflow,
|
parseVideoWorkflow,
|
||||||
videoEngineOf,
|
videoEngineOf,
|
||||||
@@ -2619,8 +2584,6 @@ const dragging = ref(false)
|
|||||||
const prompt = ref('')
|
const prompt = ref('')
|
||||||
const promptPre = ref('')
|
const promptPre = ref('')
|
||||||
const promptPost = ref('')
|
const promptPost = ref('')
|
||||||
const backupBusyId = ref('')
|
|
||||||
const backupStudioEnabled = computed(() => Boolean(runtimeConfig.public.backupStudioEnabled))
|
|
||||||
const shotScriptMode = ref(false)
|
const shotScriptMode = ref(false)
|
||||||
const directorScripts = ref<DirectorScript[]>([])
|
const directorScripts = ref<DirectorScript[]>([])
|
||||||
const directorScriptId = ref('')
|
const directorScriptId = ref('')
|
||||||
@@ -2863,22 +2826,12 @@ const comfyAsleep = ref(false)
|
|||||||
const gpuWaking = ref(false)
|
const gpuWaking = ref(false)
|
||||||
const gpuWakeError = ref('')
|
const gpuWakeError = ref('')
|
||||||
const instanceName = ref(String(runtimeConfig.public.instanceName || 'AIGen'))
|
const instanceName = ref(String(runtimeConfig.public.instanceName || 'AIGen'))
|
||||||
const ltxEnabled = computed(() => ltxWorkflowEnabled({
|
const showPrivacyToggles = computed(() => false)
|
||||||
studio: runtimeConfig.public.studio,
|
const v2ConceptLoraEnabled = computed(() => true)
|
||||||
instanceName: instanceName.value
|
|
||||||
}))
|
|
||||||
const showPrivacyToggles = computed(() => isXaigenStudio({
|
|
||||||
studio: runtimeConfig.public.studio,
|
|
||||||
instanceName: instanceName.value
|
|
||||||
}))
|
|
||||||
const v2ConceptLoraEnabled = computed(() => isXaigenStudio({
|
|
||||||
studio: runtimeConfig.public.studio,
|
|
||||||
instanceName: instanceName.value
|
|
||||||
}))
|
|
||||||
|
|
||||||
function imageV2EngineLoras(stack?: unknown) {
|
function imageV2EngineLoras(stack?: unknown) {
|
||||||
return filterLoraStackForImageEngine(
|
return filterLoraStackForImageEngine(
|
||||||
filterLoraStackForStudio(stack ?? imageV2LoraStack.value, ltxEnabled.value),
|
filterLoraStackForStudio(stack ?? imageV2LoraStack.value),
|
||||||
v2Engine.value
|
v2Engine.value
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -2969,7 +2922,7 @@ const videoWorkflow = computed(() => composeVideoWorkflow(videoEngine.value, vid
|
|||||||
const textToVideo = computed(() => isTextToVideo(videoWorkflow.value))
|
const textToVideo = computed(() => isTextToVideo(videoWorkflow.value))
|
||||||
const ltxVideo = computed(() => isLtxWorkflow(videoWorkflow.value))
|
const ltxVideo = computed(() => isLtxWorkflow(videoWorkflow.value))
|
||||||
const videoLoraOptions = computed(() => mergeLoraOptions(
|
const videoLoraOptions = computed(() => mergeLoraOptions(
|
||||||
filterLorasForUse(videoLoras.value, ltxVideo.value ? 'ltx' : 'minimax'),
|
filterLorasForUse(videoLoras.value, 'minimax'),
|
||||||
[
|
[
|
||||||
...videoLoraStack.value.map(item => item.name),
|
...videoLoraStack.value.map(item => item.name),
|
||||||
...extendLoraStack.value.map(item => item.name),
|
...extendLoraStack.value.map(item => item.name),
|
||||||
@@ -4137,13 +4090,8 @@ onMounted(async () => {
|
|||||||
videoEngine.value = videoEngineOf(saved)
|
videoEngine.value = videoEngineOf(saved)
|
||||||
minimaxGraph.value = minimaxGraphOf(saved) === 'v1' ? 'v2' : minimaxGraphOf(saved)
|
minimaxGraph.value = minimaxGraphOf(saved) === 'v1' ? 'v2' : minimaxGraphOf(saved)
|
||||||
const engine = localStorage.getItem('aigen-video-engine')
|
const engine = localStorage.getItem('aigen-video-engine')
|
||||||
if (engine === 'ltx' || engine === 'minimax') videoEngine.value = engine
|
if (engine === 'minimax' || engine === 'ltx') videoEngine.value = 'minimax'
|
||||||
if (!ltxEnabled.value && videoEngine.value === 'ltx') {
|
applyEngineDefaults('minimax')
|
||||||
videoEngine.value = 'minimax'
|
|
||||||
applyEngineDefaults('minimax')
|
|
||||||
} else if (videoEngine.value === 'ltx') {
|
|
||||||
applyEngineDefaults('ltx')
|
|
||||||
}
|
|
||||||
} catch { /* ignore */ }
|
} catch { /* ignore */ }
|
||||||
videoLoraStack.value = readStoredLoraStack('aigen-video-lora')
|
videoLoraStack.value = readStoredLoraStack('aigen-video-lora')
|
||||||
imageLoraStack.value = readStoredLoraStack('aigen-image-lora')
|
imageLoraStack.value = readStoredLoraStack('aigen-image-lora')
|
||||||
@@ -4288,13 +4236,6 @@ watch(autoplayEnabled, (value) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(ltxEnabled, (on) => {
|
|
||||||
if (!on && videoEngine.value === 'ltx') {
|
|
||||||
videoEngine.value = 'minimax'
|
|
||||||
applyEngineDefaults('minimax')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
watch(videoWorkflow, (value) => {
|
watch(videoWorkflow, (value) => {
|
||||||
try {
|
try {
|
||||||
localStorage.setItem('aigen-video-workflow', value)
|
localStorage.setItem('aigen-video-workflow', value)
|
||||||
@@ -4717,7 +4658,7 @@ function currentPresetSnapshot() {
|
|||||||
return {
|
return {
|
||||||
kind: 'imagev2' as const,
|
kind: 'imagev2' as const,
|
||||||
loraStack: filterLoraStackForImageEngine(
|
loraStack: filterLoraStackForImageEngine(
|
||||||
filterLoraStackForStudio(imageV2LoraStack.value, ltxEnabled.value),
|
filterLoraStackForStudio(imageV2LoraStack.value),
|
||||||
v2Engine.value
|
v2Engine.value
|
||||||
),
|
),
|
||||||
settings: {
|
settings: {
|
||||||
@@ -4745,7 +4686,7 @@ function currentPresetSnapshot() {
|
|||||||
if (studioMode.value === 'edit') {
|
if (studioMode.value === 'edit') {
|
||||||
return {
|
return {
|
||||||
kind: 'image' as const,
|
kind: 'image' as const,
|
||||||
loraStack: filterLoraStackForStudio(imageLoraStack.value, ltxEnabled.value),
|
loraStack: filterLoraStackForStudio(imageLoraStack.value),
|
||||||
settings: {
|
settings: {
|
||||||
prompt: prompt.value,
|
prompt: prompt.value,
|
||||||
steps: clampImageSteps(editSteps.value),
|
steps: clampImageSteps(editSteps.value),
|
||||||
@@ -4759,7 +4700,7 @@ function currentPresetSnapshot() {
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
kind: 'video' as const,
|
kind: 'video' as const,
|
||||||
loraStack: filterLoraStackForStudio(videoLoraStack.value, ltxEnabled.value),
|
loraStack: filterLoraStackForStudio(videoLoraStack.value),
|
||||||
settings: {
|
settings: {
|
||||||
workflow: videoWorkflow.value,
|
workflow: videoWorkflow.value,
|
||||||
turbo: turbo.value,
|
turbo: turbo.value,
|
||||||
@@ -4775,7 +4716,7 @@ function currentPresetSnapshot() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function applyGenerationPreset(preset: GenerationPreset) {
|
function applyGenerationPreset(preset: GenerationPreset) {
|
||||||
const stack = filterLoraStackForStudio(preset.loraStack, ltxEnabled.value)
|
const stack = filterLoraStackForStudio(preset.loraStack)
|
||||||
const skipped = preset.loraStack.length - stack.length
|
const skipped = preset.loraStack.length - stack.length
|
||||||
if (preset.kind === 'imagev2') {
|
if (preset.kind === 'imagev2') {
|
||||||
const settings = preset.settings as ImageV2PresetSettings
|
const settings = preset.settings as ImageV2PresetSettings
|
||||||
@@ -4855,9 +4796,6 @@ function applyGenerationPreset(preset: GenerationPreset) {
|
|||||||
}
|
}
|
||||||
const wantedWorkflow = String(settings.workflow || '')
|
const wantedWorkflow = String(settings.workflow || '')
|
||||||
applyVideoWorkflow(wantedWorkflow)
|
applyVideoWorkflow(wantedWorkflow)
|
||||||
if (!ltxEnabled.value && isLtxWorkflow(parseVideoWorkflow(wantedWorkflow))) {
|
|
||||||
toast('LTX Pink Cherry is not available on this instance')
|
|
||||||
}
|
|
||||||
restoreAdvanced({
|
restoreAdvanced({
|
||||||
turbo: settings.turbo !== false,
|
turbo: settings.turbo !== false,
|
||||||
aspect: settings.aspect,
|
aspect: settings.aspect,
|
||||||
@@ -4872,7 +4810,7 @@ function applyGenerationPreset(preset: GenerationPreset) {
|
|||||||
videoPresetName.value = preset.name
|
videoPresetName.value = preset.name
|
||||||
}
|
}
|
||||||
toast(skipped
|
toast(skipped
|
||||||
? `Loaded “${preset.name}”. Skipped ${skipped} xAIGen-only LoRA${skipped === 1 ? '' : 's'}.`
|
? `Loaded “${preset.name}”. Skipped ${skipped} incompatible LoRA${skipped === 1 ? '' : 's'}.`
|
||||||
: `Loaded “${preset.name}”.`)
|
: `Loaded “${preset.name}”.`)
|
||||||
console.info('[aigen preset apply]', {
|
console.info('[aigen preset apply]', {
|
||||||
kind: preset.kind,
|
kind: preset.kind,
|
||||||
@@ -5664,7 +5602,7 @@ async function restoreStudioEditJob(payload: {
|
|||||||
if (typeof payload.negative === 'string') editNegative.value = payload.negative
|
if (typeof payload.negative === 'string') editNegative.value = payload.negative
|
||||||
editScaleToTotalPixels.value = payload.scaleToTotalPixels === true
|
editScaleToTotalPixels.value = payload.scaleToTotalPixels === true
|
||||||
if (payload.scaleMegapixels != null) editScaleMegapixels.value = clampImageScaleMegapixels(payload.scaleMegapixels)
|
if (payload.scaleMegapixels != null) editScaleMegapixels.value = clampImageScaleMegapixels(payload.scaleMegapixels)
|
||||||
imageLoraStack.value = filterLoraStackForStudio(readLoraStack(payload), ltxEnabled.value)
|
imageLoraStack.value = filterLoraStackForStudio(readLoraStack(payload))
|
||||||
aspect.value = parseImageAspect(payload.aspect)
|
aspect.value = parseImageAspect(payload.aspect)
|
||||||
}
|
}
|
||||||
// Always restore Still A when the payload has one — including Generate jobs —
|
// Always restore Still A when the payload has one — including Generate jobs —
|
||||||
@@ -6586,7 +6524,7 @@ function applyStillSettings(still: LibraryStill) {
|
|||||||
editNegative.value = settings.negative || ''
|
editNegative.value = settings.negative || ''
|
||||||
editScaleToTotalPixels.value = settings.scaleToTotalPixels === true
|
editScaleToTotalPixels.value = settings.scaleToTotalPixels === true
|
||||||
if (settings.scaleMegapixels != null) editScaleMegapixels.value = clampImageScaleMegapixels(settings.scaleMegapixels)
|
if (settings.scaleMegapixels != null) editScaleMegapixels.value = clampImageScaleMegapixels(settings.scaleMegapixels)
|
||||||
imageLoraStack.value = filterLoraStackForStudio(readLoraStack(settings), ltxEnabled.value)
|
imageLoraStack.value = filterLoraStackForStudio(readLoraStack(settings))
|
||||||
aspect.value = parseImageAspect(settings.aspect)
|
aspect.value = parseImageAspect(settings.aspect)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6637,28 +6575,6 @@ async function useStillAsInput(still: LibraryStill) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sendOutputStillToBackup() {
|
|
||||||
const stillId = lastV2StillId.value || stillIdFromLibraryUrl(editResultUrl.value)
|
|
||||||
if (!stillId) {
|
|
||||||
toast('Save this still first, then send it to Backup.')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
await sendStillToBackup({ id: stillId })
|
|
||||||
}
|
|
||||||
|
|
||||||
async function sendStillToBackup(still: Pick<LibraryStill, 'id'>) {
|
|
||||||
if (!backupStudioEnabled.value || backupBusyId.value) return
|
|
||||||
backupBusyId.value = still.id
|
|
||||||
try {
|
|
||||||
await $fetch(`/api/library/stills/${still.id}/backup`, { method: 'POST' })
|
|
||||||
toast('Sent to Backup')
|
|
||||||
} catch (error: any) {
|
|
||||||
toast(error?.data?.statusMessage || 'Could not send that still to Backup')
|
|
||||||
} finally {
|
|
||||||
backupBusyId.value = ''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function saveStillAsInput(still: Pick<LibraryStill, 'id'>) {
|
async function saveStillAsInput(still: Pick<LibraryStill, 'id'>) {
|
||||||
if (keepingInputBusy.value) return
|
if (keepingInputBusy.value) return
|
||||||
keepingInputBusy.value = true
|
keepingInputBusy.value = true
|
||||||
@@ -7482,7 +7398,7 @@ async function editImageV2() {
|
|||||||
if (extraPasses.length) body.append('passes', JSON.stringify(extraPasses))
|
if (extraPasses.length) body.append('passes', JSON.stringify(extraPasses))
|
||||||
body.append('passMode', iterateGenerate ? 'batch' : imagePassMode.value)
|
body.append('passMode', iterateGenerate ? 'batch' : imagePassMode.value)
|
||||||
const v2Stack = filterLoraStackForImageEngine(
|
const v2Stack = filterLoraStackForImageEngine(
|
||||||
filterLoraStackForStudio(imageV2LoraStack.value, ltxEnabled.value),
|
filterLoraStackForStudio(imageV2LoraStack.value),
|
||||||
v2Engine.value
|
v2Engine.value
|
||||||
)
|
)
|
||||||
const wrongEngine = imageV2LoraStack.value.find((item) => {
|
const wrongEngine = imageV2LoraStack.value.find((item) => {
|
||||||
@@ -7619,18 +7535,13 @@ async function useEditAsInput() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyEngineDefaults(engine: VideoEngineId) {
|
function applyEngineDefaults(_engine: VideoEngineId) {
|
||||||
if (engine === 'ltx') {
|
|
||||||
samplerName.value = 'euler'
|
|
||||||
if (!cfgTouched.value) cfg.value = 3.5
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (samplerName.value === 'euler') samplerName.value = 'res_multistep'
|
if (samplerName.value === 'euler') samplerName.value = 'res_multistep'
|
||||||
if (!cfgTouched.value) cfg.value = turbo.value ? CFG_TURBO : CFG_QUALITY
|
if (!cfgTouched.value) cfg.value = turbo.value ? CFG_TURBO : CFG_QUALITY
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectVideoEngine(engine: VideoEngineId) {
|
function selectVideoEngine(engine: VideoEngineId) {
|
||||||
if (engine === 'ltx' && !ltxEnabled.value) return
|
if (engine !== 'minimax') return
|
||||||
if (videoEngine.value === engine) return
|
if (videoEngine.value === engine) return
|
||||||
cfgTouched.value = false
|
cfgTouched.value = false
|
||||||
videoEngine.value = engine
|
videoEngine.value = engine
|
||||||
@@ -7638,7 +7549,7 @@ function selectVideoEngine(engine: VideoEngineId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function applyVideoWorkflow(raw?: string) {
|
function applyVideoWorkflow(raw?: string) {
|
||||||
const parsed = coerceVideoWorkflow(raw, ltxEnabled.value)
|
const parsed = coerceVideoWorkflow(raw)
|
||||||
videoEngine.value = videoEngineOf(parsed)
|
videoEngine.value = videoEngineOf(parsed)
|
||||||
minimaxGraph.value = minimaxGraphOf(parsed) === 'v1' ? 'v2' : minimaxGraphOf(parsed)
|
minimaxGraph.value = minimaxGraphOf(parsed) === 'v1' ? 'v2' : minimaxGraphOf(parsed)
|
||||||
}
|
}
|
||||||
@@ -7663,11 +7574,8 @@ async function ensureVideoInputStill() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function generate() {
|
async function generate() {
|
||||||
if (!ltxEnabled.value && isLtxWorkflow(videoWorkflow.value)) {
|
if (isLtxWorkflow(videoWorkflow.value)) {
|
||||||
videoEngine.value = 'minimax'
|
applyVideoWorkflow(videoWorkflow.value)
|
||||||
applyEngineDefaults('minimax')
|
|
||||||
toast('LTX Pink Cherry is not available on this instance')
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
console.info('[aigen generate click]', {
|
console.info('[aigen generate click]', {
|
||||||
hasFile: Boolean(file.value),
|
hasFile: Boolean(file.value),
|
||||||
|
|||||||
@@ -1,140 +1,7 @@
|
|||||||
import { filterLoraStackForUse } from '~/utils/loras'
|
import { queueAigenGenerate } from '~/server/utils/aigenGenerate'
|
||||||
import { validateRequest } from '~/shared/studio2/contracts.mjs'
|
|
||||||
import { defaultLibraryFolderId, isStudio2ImageEngine, studio2EngineDefaults } from '~/shared/studio2/engine-defaults.mjs'
|
|
||||||
import { resolveRequestSize } from '../../utils/studio2/size'
|
|
||||||
import { parsePostedLoraStack, assertImageV2LoraStack } from '../../utils/loras'
|
|
||||||
import { saveRecord, readRecord } from '../../utils/studio2/store'
|
|
||||||
import { addStudioJob, kickStudioQueue, type StudioJobPayload } from '../../utils/studioQueue'
|
|
||||||
import { isXaigenStudio } from '~/utils/videoModels'
|
|
||||||
import { assertAigenApiAccess } from '~/server/utils/aigenApi'
|
|
||||||
|
|
||||||
export default defineEventHandler(async (event) => {
|
export default defineEventHandler(async (event) => {
|
||||||
const { owner, catalog } = assertAigenApiAccess(event)
|
|
||||||
const rawBody = await readBody(event).catch(() => ({}))
|
const rawBody = await readBody(event).catch(() => ({}))
|
||||||
const body = rawBody && typeof rawBody === 'object' ? rawBody as Record<string, unknown> : {}
|
const body = rawBody && typeof rawBody === 'object' ? rawBody as Record<string, unknown> : {}
|
||||||
|
return queueAigenGenerate(event, body)
|
||||||
const prompt = String(body.prompt || '').trim()
|
|
||||||
if (!prompt) {
|
|
||||||
throw createError({ statusCode: 400, statusMessage: 'A prompt is required' })
|
|
||||||
}
|
|
||||||
|
|
||||||
const engine = String(body.engine || 'flux').trim().toLowerCase() || 'flux'
|
|
||||||
if (!isStudio2ImageEngine(engine)) {
|
|
||||||
throw createError({ statusCode: 400, statusMessage: 'engine must be flux, krea, qwen21, or moss' })
|
|
||||||
}
|
|
||||||
|
|
||||||
const mode = String(body.mode || 'generate').trim().toLowerCase() || 'generate'
|
|
||||||
if (mode !== 'generate') {
|
|
||||||
throw createError({ statusCode: 400, statusMessage: 'mode must be generate' })
|
|
||||||
}
|
|
||||||
|
|
||||||
const defaults = studio2EngineDefaults(engine)
|
|
||||||
const steps = body.steps == null || body.steps === ''
|
|
||||||
? defaults.steps
|
|
||||||
: Number(body.steps)
|
|
||||||
const cfg = body.cfg == null || body.cfg === ''
|
|
||||||
? defaults.cfg
|
|
||||||
: Number(body.cfg)
|
|
||||||
if (!Number.isFinite(steps) || !Number.isInteger(steps)) {
|
|
||||||
throw createError({ statusCode: 400, statusMessage: 'steps must be an integer' })
|
|
||||||
}
|
|
||||||
if (!Number.isFinite(cfg)) {
|
|
||||||
throw createError({ statusCode: 400, statusMessage: 'cfg must be a number' })
|
|
||||||
}
|
|
||||||
|
|
||||||
const aspect = String(body.aspect || defaults.aspect || 'auto').trim() || defaults.aspect
|
|
||||||
const folderId = defaultLibraryFolderId(catalog, body.folderId == null ? '' : String(body.folderId))
|
|
||||||
if (!folderId) {
|
|
||||||
throw createError({ statusCode: 400, statusMessage: 'Create a library folder before generating' })
|
|
||||||
}
|
|
||||||
|
|
||||||
const seedRaw = body.seed
|
|
||||||
const seedSet = seedRaw != null && String(seedRaw) !== ''
|
|
||||||
const seed = seedSet ? Number(seedRaw) : null
|
|
||||||
if (seedSet && !Number.isFinite(seed)) {
|
|
||||||
throw createError({ statusCode: 400, statusMessage: 'seed must be a number' })
|
|
||||||
}
|
|
||||||
|
|
||||||
const xaigen = isXaigenStudio()
|
|
||||||
const requestRaw = {
|
|
||||||
mode: 'generate',
|
|
||||||
engine,
|
|
||||||
folderId,
|
|
||||||
promptSections: { action: prompt },
|
|
||||||
settings: {
|
|
||||||
aspect,
|
|
||||||
steps,
|
|
||||||
cfg,
|
|
||||||
seed,
|
|
||||||
seedMode: seedSet ? 'locked' : 'random',
|
|
||||||
loraStack: []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let request: any
|
|
||||||
try {
|
|
||||||
request = validateRequest(requestRaw, xaigen)
|
|
||||||
} catch (e: any) {
|
|
||||||
throw createError({ statusCode: e.statusCode || 400, statusMessage: e.message })
|
|
||||||
}
|
|
||||||
|
|
||||||
request.settings.loraStack = parsePostedLoraStack(request.settings.loraStack, 'image')
|
|
||||||
request.settings.loraStack = filterLoraStackForUse(request.settings.loraStack, request.engine, xaigen)
|
|
||||||
if (request.engine !== 'qwen21') assertImageV2LoraStack(request.settings.loraStack, request.engine)
|
|
||||||
assertFolderAccess(event, request.folderId)
|
|
||||||
try {
|
|
||||||
await resolveRequestSize(owner, request)
|
|
||||||
} catch (e: any) {
|
|
||||||
const message = e?.statusMessage || e?.message || 'Could not resolve size'
|
|
||||||
throw createError({
|
|
||||||
statusCode: e?.statusCode || 400,
|
|
||||||
statusMessage: message
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const id = crypto.randomUUID()
|
|
||||||
const record = {
|
|
||||||
id,
|
|
||||||
owner,
|
|
||||||
request,
|
|
||||||
state: 'waiting',
|
|
||||||
queuedAt: Date.now(),
|
|
||||||
familyId: crypto.randomUUID(),
|
|
||||||
outputs: [],
|
|
||||||
purgeResult: 'Not yet saved'
|
|
||||||
}
|
|
||||||
saveRecord(record)
|
|
||||||
void (async () => {
|
|
||||||
try {
|
|
||||||
const row = await addStudioJob({
|
|
||||||
ownerKey: owner,
|
|
||||||
kind: 'edit',
|
|
||||||
familyId: record.familyId,
|
|
||||||
payload: {
|
|
||||||
...request.settings,
|
|
||||||
engine: request.engine,
|
|
||||||
studio2Id: id,
|
|
||||||
studio2Request: structuredClone(request),
|
|
||||||
prompt: request.compiledPrompt,
|
|
||||||
folderId: request.folderId,
|
|
||||||
extensions: [],
|
|
||||||
referenceStillIds: [],
|
|
||||||
useIdentityRefs: false,
|
|
||||||
queueAutoRun: true
|
|
||||||
} as StudioJobPayload
|
|
||||||
})
|
|
||||||
saveRecord({ ...readRecord(owner, id), queueId: row.id })
|
|
||||||
} catch { /* poll / resume will pick up waiting studio2 records */ }
|
|
||||||
kickStudioQueue()
|
|
||||||
})()
|
|
||||||
|
|
||||||
return {
|
|
||||||
id,
|
|
||||||
engine: request.engine,
|
|
||||||
steps: request.settings.steps,
|
|
||||||
cfg: request.settings.cfg,
|
|
||||||
aspect: request.settings.aspect,
|
|
||||||
folderId: request.folderId,
|
|
||||||
status: 'waiting' as const
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,36 +1,6 @@
|
|||||||
import { jobView } from '~/shared/studio2/queue-view.mjs'
|
import { readAigenJob } from '~/server/utils/aigenJob'
|
||||||
import { getJob } from '../../../utils/jobs'
|
|
||||||
import { readRecord } from '../../../utils/studio2/store'
|
|
||||||
import { listStudioJobs } from '../../../utils/studioQueue'
|
|
||||||
import { assertAigenApiAccess } from '~/server/utils/aigenApi'
|
|
||||||
|
|
||||||
export default defineEventHandler((event) => {
|
export default defineEventHandler((event) => {
|
||||||
const { owner } = assertAigenApiAccess(event)
|
|
||||||
const id = String(getRouterParam(event, 'id') || '')
|
const id = String(getRouterParam(event, 'id') || '')
|
||||||
let record: any
|
return readAigenJob(event, id)
|
||||||
try {
|
|
||||||
record = readRecord(owner, id)
|
|
||||||
} catch (e: any) {
|
|
||||||
throw createError({
|
|
||||||
statusCode: e?.statusCode || 404,
|
|
||||||
statusMessage: e?.statusMessage || 'Job not found'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const queue = listStudioJobs(owner).find(row => row.id === record.queueId)
|
|
||||||
const live = record.liveId ? getJob(record.liveId) : null
|
|
||||||
const view = jobView(record, queue, live)
|
|
||||||
const still = (record.outputs || []).find((item: any) => item?.id && item.kind !== 'clip' && item.kind !== 'track')
|
|
||||||
|| (record.outputs || []).find((item: any) => item?.id)
|
|
||||||
const stillId = still?.id ? String(still.id) : undefined
|
|
||||||
|
|
||||||
return {
|
|
||||||
id: record.id,
|
|
||||||
state: view.state,
|
|
||||||
engine: record.request?.engine || '',
|
|
||||||
steps: record.request?.settings?.steps,
|
|
||||||
cfg: record.request?.settings?.cfg,
|
|
||||||
...(view.error ? { error: view.error } : {}),
|
|
||||||
...(stillId ? { stillId, stillUrl: `/api/library/stills/${stillId}` } : {})
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { addStudioJob, kickStudioQueue, listStudioJobs, videoJobsBusy } from '~/
|
|||||||
import { persistLoraFields, parsePostedLoraStack, listStudioLoras } from '~/server/utils/loras'
|
import { persistLoraFields, parsePostedLoraStack, listStudioLoras } from '~/server/utils/loras'
|
||||||
import { readLoraStack } from '~/utils/loras'
|
import { readLoraStack } from '~/utils/loras'
|
||||||
import { clipPartDuration, clampVideoDuration } from '~/utils/videoDuration'
|
import { clipPartDuration, clampVideoDuration } from '~/utils/videoDuration'
|
||||||
import { defaultVideoSteps, isLtxWorkflow, LTX_DISABLED_MESSAGE, ltxWorkflowEnabled, parseVideoWorkflow } from '~/utils/videoModels'
|
import { coerceVideoWorkflow, defaultVideoSteps, parseVideoWorkflow } from '~/utils/videoModels'
|
||||||
import { composePromptParts } from '~/utils/promptParts'
|
import { composePromptParts } from '~/utils/promptParts'
|
||||||
import { nextFamilyPartName } from '~/server/utils/library'
|
import { nextFamilyPartName } from '~/server/utils/library'
|
||||||
import {
|
import {
|
||||||
@@ -58,10 +58,7 @@ export default defineEventHandler(async (event) => {
|
|||||||
if (!composePromptParts(promptPre, prompt, promptPost)) {
|
if (!composePromptParts(promptPre, prompt, promptPost)) {
|
||||||
throw createError({ statusCode: 400, statusMessage: 'An extension prompt is required' })
|
throw createError({ statusCode: 400, statusMessage: 'An extension prompt is required' })
|
||||||
}
|
}
|
||||||
const workflow = parseVideoWorkflow(source.workflow)
|
const workflow = coerceVideoWorkflow(source.workflow)
|
||||||
if (isLtxWorkflow(workflow) && !ltxWorkflowEnabled()) {
|
|
||||||
throw createError({ statusCode: 400, statusMessage: LTX_DISABLED_MESSAGE })
|
|
||||||
}
|
|
||||||
await listStudioLoras()
|
await listStudioLoras()
|
||||||
const postedStack = parsePostedLoraStack(body?.loraStack ?? body?.lora, 'video')
|
const postedStack = parsePostedLoraStack(body?.loraStack ?? body?.lora, 'video')
|
||||||
const loraStack = postedStack.length ? postedStack : parsePostedLoraStack(readLoraStack(source), 'video')
|
const loraStack = postedStack.length ? postedStack : parsePostedLoraStack(readLoraStack(source), 'video')
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { existsSync, readFileSync } from 'node:fs'
|
|||||||
import { addStudioJob, kickStudioQueue, listStudioJobs, videoJobsBusy } from '~/server/utils/studioQueue'
|
import { addStudioJob, kickStudioQueue, listStudioJobs, videoJobsBusy } from '~/server/utils/studioQueue'
|
||||||
import { listStudioLoras, parsePostedLoraStack, parseShotLoraStacks, persistLoraFields } from '~/server/utils/loras'
|
import { listStudioLoras, parsePostedLoraStack, parseShotLoraStacks, persistLoraFields } from '~/server/utils/loras'
|
||||||
import { clampVideoCfg } from '~/utils/generationPresets'
|
import { clampVideoCfg } from '~/utils/generationPresets'
|
||||||
import { defaultVideoSteps, isLtxWorkflow, isTextToVideo, LTX_DISABLED_MESSAGE, ltxWorkflowEnabled, parseVideoWorkflow, videoEngineOf } from '~/utils/videoModels'
|
import { coerceVideoWorkflow, defaultVideoSteps, isTextToVideo, parseVideoWorkflow, videoEngineOf } from '~/utils/videoModels'
|
||||||
import { allowIdentityRefs, normalizePermanenceRefs, resolveGlobalLocks, type PermanenceRef } from '~/utils/globalLocks'
|
import { allowIdentityRefs, normalizePermanenceRefs, resolveGlobalLocks, type PermanenceRef } from '~/utils/globalLocks'
|
||||||
import { composePromptParts, ingestPromptParts, persistPromptWrappers } from '~/utils/promptParts'
|
import { composePromptParts, ingestPromptParts, persistPromptWrappers } from '~/utils/promptParts'
|
||||||
import type { QueuedExtension } from '~/server/utils/library'
|
import type { QueuedExtension } from '~/server/utils/library'
|
||||||
@@ -120,10 +120,7 @@ export default defineEventHandler(async (event) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await listStudioLoras()
|
await listStudioLoras()
|
||||||
const workflow = parseVideoWorkflow(fields.workflow)
|
const workflow = coerceVideoWorkflow(fields.workflow)
|
||||||
if (isLtxWorkflow(workflow) && !ltxWorkflowEnabled()) {
|
|
||||||
throw createError({ statusCode: 400, statusMessage: LTX_DISABLED_MESSAGE })
|
|
||||||
}
|
|
||||||
const textToVideo = isTextToVideo(workflow)
|
const textToVideo = isTextToVideo(workflow)
|
||||||
const ownerKey = libraryOwnerKey(event)
|
const ownerKey = libraryOwnerKey(event)
|
||||||
const postedStillId = (fields.stillId || '').trim()
|
const postedStillId = (fields.stillId || '').trim()
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
import { backupIngestSecret } from '~/server/utils/backupStudio'
|
|
||||||
import { passwordAuthEnabled, privateInstanceId } from '~/server/utils/localAuth'
|
|
||||||
import { saveStill } from '~/server/utils/library'
|
|
||||||
|
|
||||||
function ingestOwner() {
|
|
||||||
if (passwordAuthEnabled()) return privateInstanceId()
|
|
||||||
return 'local'
|
|
||||||
}
|
|
||||||
|
|
||||||
function assertIngestToken(event: Parameters<typeof getHeader>[0]) {
|
|
||||||
const expected = backupIngestSecret()
|
|
||||||
if (!expected || /^https?:\/\//i.test(expected)) {
|
|
||||||
throw createError({
|
|
||||||
statusCode: 503,
|
|
||||||
statusMessage: 'Set BACKUP_INGEST_TOKEN on xAIGen to the same secret as BACKUP_STUDIO_TOKEN on AIGen, not a URL.'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const header = String(getHeader(event, 'authorization') || '')
|
|
||||||
if (header !== `Bearer ${expected}`) {
|
|
||||||
throw createError({ statusCode: 401, statusMessage: 'Unauthorized' })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default defineEventHandler(async (event) => {
|
|
||||||
assertIngestToken(event)
|
|
||||||
const form = await readMultipartFormData(event)
|
|
||||||
if (!form?.length) throw createError({ statusCode: 400, statusMessage: 'Expected an image upload' })
|
|
||||||
const fields: Record<string, string> = {}
|
|
||||||
let image: { filename: string; data: Buffer } | null = null
|
|
||||||
for (const part of form) {
|
|
||||||
if (part.name === 'image' && part.filename && part.data?.length) {
|
|
||||||
image = { filename: part.filename, data: part.data }
|
|
||||||
} else if (part.name && part.data) {
|
|
||||||
fields[part.name] = part.data.toString('utf8')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!image) throw createError({ statusCode: 400, statusMessage: 'An image is required' })
|
|
||||||
const owner = ingestOwner()
|
|
||||||
const still = await saveStill({
|
|
||||||
ownerKey: owner,
|
|
||||||
folderId: 'inbox',
|
|
||||||
filename: image.filename,
|
|
||||||
data: image.data,
|
|
||||||
width: Number(fields.width || 0),
|
|
||||||
height: Number(fields.height || 0),
|
|
||||||
hideInput: true,
|
|
||||||
role: 'input',
|
|
||||||
name: (fields.name || '').trim().slice(0, 80) || undefined
|
|
||||||
})
|
|
||||||
if (!still) throw createError({ statusCode: 400, statusMessage: 'Backup studio already has that still' })
|
|
||||||
return { ok: true, id: still.id }
|
|
||||||
})
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
import { readFileSync } from 'node:fs'
|
|
||||||
import { isXaigenStudio } from '~/utils/videoModels'
|
|
||||||
import { backupStudioConfigError, backupStudioTarget } from '~/server/utils/backupStudio'
|
|
||||||
import { assertLibraryOwner, getStill, stillPath } from '~/server/utils/library'
|
|
||||||
|
|
||||||
export default defineEventHandler(async (event) => {
|
|
||||||
if (isXaigenStudio()) {
|
|
||||||
throw createError({ statusCode: 404, statusMessage: 'Not found' })
|
|
||||||
}
|
|
||||||
const missing = backupStudioConfigError()
|
|
||||||
if (missing) {
|
|
||||||
throw createError({ statusCode: 503, statusMessage: missing })
|
|
||||||
}
|
|
||||||
const { url, token } = backupStudioTarget()
|
|
||||||
const { owner } = assertLibraryOwner(event)
|
|
||||||
const id = String(getRouterParam(event, 'id') || '')
|
|
||||||
const still = getStill(owner, id)
|
|
||||||
const path = stillPath(owner, still.id)
|
|
||||||
const data = readFileSync(path)
|
|
||||||
const body = new FormData()
|
|
||||||
body.append('image', new Blob([Uint8Array.from(data)]), still.filename || 'still.png')
|
|
||||||
body.append('name', still.name || still.filename || 'still')
|
|
||||||
body.append('width', String(still.width || 0))
|
|
||||||
body.append('height', String(still.height || 0))
|
|
||||||
const res = await fetch(`${url}/api/library/backup-ingest`, {
|
|
||||||
method: 'POST',
|
|
||||||
headers: { Authorization: `Bearer ${token}` },
|
|
||||||
body
|
|
||||||
})
|
|
||||||
if (!res.ok) {
|
|
||||||
const message = await res.text().catch(() => '')
|
|
||||||
throw createError({
|
|
||||||
statusCode: res.status === 401 ? 502 : res.status,
|
|
||||||
statusMessage: message || 'xAIGen refused the still. Check BACKUP_INGEST_TOKEN matches AIGen BACKUP_STUDIO_TOKEN.'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return { ok: true }
|
|
||||||
})
|
|
||||||
@@ -4,20 +4,18 @@ import { resolveRequestSize } from '../../utils/studio2/size';
|
|||||||
import { parsePostedLoraStack, assertImageV2LoraStack } from '../../utils/loras';
|
import { parsePostedLoraStack, assertImageV2LoraStack } from '../../utils/loras';
|
||||||
import { saveRecord, readRecord } from '../../utils/studio2/store';
|
import { saveRecord, readRecord } from '../../utils/studio2/store';
|
||||||
import { addStudioJob, kickStudioQueue, type StudioJobPayload } from '../../utils/studioQueue';
|
import { addStudioJob, kickStudioQueue, type StudioJobPayload } from '../../utils/studioQueue';
|
||||||
import { isXaigenStudio } from '~/utils/videoModels';
|
|
||||||
export default defineEventHandler(async (event) => {
|
export default defineEventHandler(async (event) => {
|
||||||
const { owner } = assertLibraryOwner(event), raw = await readBody(event);
|
const { owner } = assertLibraryOwner(event), raw = await readBody(event);
|
||||||
const xaigen = isXaigenStudio();
|
|
||||||
let request: any;
|
let request: any;
|
||||||
try {
|
try {
|
||||||
request = validateRequest(raw, xaigen);
|
request = validateRequest(raw);
|
||||||
}
|
}
|
||||||
catch (e: any) {
|
catch (e: any) {
|
||||||
throw createError({ statusCode: e.statusCode || 400, statusMessage: e.message });
|
throw createError({ statusCode: e.statusCode || 400, statusMessage: e.message });
|
||||||
}
|
}
|
||||||
const video = ['video', 'extend'].includes(request.mode);
|
const video = ['video', 'extend'].includes(request.mode);
|
||||||
request.settings.loraStack = parsePostedLoraStack(request.settings.loraStack, video ? 'video' : 'image');
|
request.settings.loraStack = parsePostedLoraStack(request.settings.loraStack, video ? 'video' : 'image');
|
||||||
request.settings.loraStack = filterLoraStackForUse(request.settings.loraStack, request.engine, xaigen);
|
request.settings.loraStack = filterLoraStackForUse(request.settings.loraStack, request.engine);
|
||||||
if (!video && request.engine !== 'qwen21')
|
if (!video && request.engine !== 'qwen21')
|
||||||
assertImageV2LoraStack(request.settings.loraStack, request.engine);
|
assertImageV2LoraStack(request.settings.loraStack, request.engine);
|
||||||
assertFolderAccess(event, request.folderId);
|
assertFolderAccess(event, request.folderId);
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import {
|
|||||||
type ImageV2Mode,
|
type ImageV2Mode,
|
||||||
type ImageV2Task
|
type ImageV2Task
|
||||||
} from '~/utils/imageV2'
|
} from '~/utils/imageV2'
|
||||||
import { isXaigenStudio } from '~/utils/videoModels'
|
|
||||||
import { ingestPromptParts } from '~/utils/promptParts'
|
import { ingestPromptParts } from '~/utils/promptParts'
|
||||||
import { listStudioLoras, parsePostedLoraStack, persistLoraFields, assertImageV2LoraStack } from '~/server/utils/loras'
|
import { listStudioLoras, parsePostedLoraStack, persistLoraFields, assertImageV2LoraStack } from '~/server/utils/loras'
|
||||||
import { getStill, rememberInputStill, stillPath } from '~/server/utils/library'
|
import { getStill, rememberInputStill, stillPath } from '~/server/utils/library'
|
||||||
@@ -281,7 +280,7 @@ export default defineEventHandler(async (event) => {
|
|||||||
fields.consistency_clip,
|
fields.consistency_clip,
|
||||||
graphMode === 'generate' || engine === 'krea' ? 0 : IMAGE_V2_CONSISTENCY_CLIP
|
graphMode === 'generate' || engine === 'krea' ? 0 : IMAGE_V2_CONSISTENCY_CLIP
|
||||||
)
|
)
|
||||||
const conceptAllowed = isXaigenStudio()
|
const conceptAllowed = true
|
||||||
const generateSnofsFallback = 0
|
const generateSnofsFallback = 0
|
||||||
const generateSnofsClipFallback = 0
|
const generateSnofsClipFallback = 0
|
||||||
await listStudioLoras()
|
await listStudioLoras()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { aigenApiPathAllowed, aigenBearerAuthorized } from '~/server/utils/aigenApiAuth'
|
import { aigenApiPathAllowed, aigenBearerAuthorized } from '~/server/utils/aigenApiAuth'
|
||||||
import { isXaigenStudio } from '~/utils/videoModels'
|
import { applyMcpCors } from '~/server/utils/aigenMcp'
|
||||||
|
|
||||||
export default defineEventHandler((event) => {
|
export default defineEventHandler((event) => {
|
||||||
if (!authEnabled()) return
|
if (!authEnabled()) return
|
||||||
@@ -11,15 +11,24 @@ export default defineEventHandler((event) => {
|
|||||||
path.startsWith('/api/auth/me') ||
|
path.startsWith('/api/auth/me') ||
|
||||||
path.startsWith('/api/health') ||
|
path.startsWith('/api/health') ||
|
||||||
path.startsWith('/api/monitor') ||
|
path.startsWith('/api/monitor') ||
|
||||||
path.startsWith('/api/library/backup-ingest') ||
|
|
||||||
path.startsWith('/_nuxt') ||
|
path.startsWith('/_nuxt') ||
|
||||||
path.startsWith('/favicon') ||
|
path.startsWith('/favicon') ||
|
||||||
path === '/login'
|
path === '/login' ||
|
||||||
|
// Claude MCP discovery — never 302 to /login (JSON 404 handlers serve these).
|
||||||
|
path === '/.well-known/oauth-authorization-server' ||
|
||||||
|
path === '/.well-known/openid-configuration' ||
|
||||||
|
path === '/.well-known/oauth-protected-resource' ||
|
||||||
|
path.startsWith('/.well-known/oauth-protected-resource/')
|
||||||
) {
|
) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const method = String(event.method || getMethod(event) || 'GET').toUpperCase()
|
const method = String(event.method || getMethod(event) || 'GET').toUpperCase()
|
||||||
if (!isXaigenStudio() && aigenApiPathAllowed(path, method) && aigenBearerAuthorized(event)) {
|
// /mcp auth + 401 JSON-RPC bodies are handled in the route — do not 401 here.
|
||||||
|
if (path === '/mcp') {
|
||||||
|
applyMcpCors(event)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (aigenApiPathAllowed(path, method) && aigenBearerAuthorized(event)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const user = getSessionUser(event)
|
const user = getSessionUser(event)
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
/** Claude discovery probe — no OAuth; never redirect to /login. */
|
||||||
|
export default defineEventHandler((event) => {
|
||||||
|
setResponseStatus(event, 404)
|
||||||
|
setResponseHeader(event, 'Content-Type', 'application/json')
|
||||||
|
setResponseHeader(event, 'Cache-Control', 'no-store')
|
||||||
|
return { error: 'not found' }
|
||||||
|
})
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
/** Claude discovery probe — no OAuth; never redirect to /login. */
|
||||||
|
export default defineEventHandler((event) => {
|
||||||
|
setResponseStatus(event, 404)
|
||||||
|
setResponseHeader(event, 'Content-Type', 'application/json')
|
||||||
|
setResponseHeader(event, 'Cache-Control', 'no-store')
|
||||||
|
return { error: 'not found' }
|
||||||
|
})
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
/** Claude discovery probe — no OAuth; never redirect to /login. */
|
||||||
|
export default defineEventHandler((event) => {
|
||||||
|
setResponseStatus(event, 404)
|
||||||
|
setResponseHeader(event, 'Content-Type', 'application/json')
|
||||||
|
setResponseHeader(event, 'Cache-Control', 'no-store')
|
||||||
|
return { error: 'not found' }
|
||||||
|
})
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
/** Claude discovery probe — no OAuth; never redirect to /login. */
|
||||||
|
export default defineEventHandler((event) => {
|
||||||
|
setResponseStatus(event, 404)
|
||||||
|
setResponseHeader(event, 'Content-Type', 'application/json')
|
||||||
|
setResponseHeader(event, 'Cache-Control', 'no-store')
|
||||||
|
return { error: 'not found' }
|
||||||
|
})
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
import { isXaigenStudio } from '~/utils/videoModels'
|
|
||||||
|
|
||||||
export default defineEventHandler((event) => {
|
export default defineEventHandler((event) => {
|
||||||
const pub = useRuntimeConfig().public as { instanceName?: string; studio?: string }
|
const pub = useRuntimeConfig().public as { instanceName?: string }
|
||||||
const xaigen = isXaigenStudio(pub)
|
const name = String(pub.instanceName || 'AIGen')
|
||||||
const name = String(pub.instanceName || (xaigen ? 'xAIGen' : 'AIGen'))
|
|
||||||
setHeader(event, 'Content-Type', 'application/manifest+json')
|
setHeader(event, 'Content-Type', 'application/manifest+json')
|
||||||
setHeader(event, 'Cache-Control', 'no-cache')
|
setHeader(event, 'Cache-Control', 'no-cache')
|
||||||
return {
|
return {
|
||||||
@@ -15,7 +12,7 @@ export default defineEventHandler((event) => {
|
|||||||
background_color: '#09090b',
|
background_color: '#09090b',
|
||||||
theme_color: '#09090b',
|
theme_color: '#09090b',
|
||||||
icons: [{
|
icons: [{
|
||||||
src: xaigen ? '/favicon.svg' : '/favicon-aigen.svg',
|
src: '/favicon-aigen.svg',
|
||||||
sizes: 'any',
|
sizes: 'any',
|
||||||
type: 'image/svg+xml',
|
type: 'image/svg+xml',
|
||||||
purpose: 'any'
|
purpose: 'any'
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
import {
|
||||||
|
MCP_SERVER_INFO,
|
||||||
|
MCP_TOOLS,
|
||||||
|
applyMcpCors,
|
||||||
|
callMcpTool,
|
||||||
|
jsonRpcError,
|
||||||
|
jsonRpcResult,
|
||||||
|
mcpAssertAccess,
|
||||||
|
mcpBearerOk,
|
||||||
|
mcpUnauthorized,
|
||||||
|
resolveMcpProtocolVersion
|
||||||
|
} from '~/server/utils/aigenMcp'
|
||||||
|
|
||||||
|
export default defineEventHandler(async (event) => {
|
||||||
|
applyMcpCors(event)
|
||||||
|
const method = String(getMethod(event) || 'GET').toUpperCase()
|
||||||
|
|
||||||
|
if (method === 'OPTIONS') {
|
||||||
|
setResponseStatus(event, 204)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method === 'GET') {
|
||||||
|
// Claude probes GET /mcp with no Authorization; Cursor always sends bearer.
|
||||||
|
// Never auth-check GET — always open a short SSE stream and end.
|
||||||
|
setResponseStatus(event, 200)
|
||||||
|
setResponseHeader(event, 'Content-Type', 'text/event-stream')
|
||||||
|
setResponseHeader(event, 'Cache-Control', 'no-cache, no-transform')
|
||||||
|
setResponseHeader(event, 'Connection', 'keep-alive')
|
||||||
|
return ': connected\n\n'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method !== 'POST') {
|
||||||
|
setResponseHeader(event, 'Allow', 'GET, POST, OPTIONS')
|
||||||
|
throw createError({ statusCode: 405, statusMessage: 'Method Not Allowed' })
|
||||||
|
}
|
||||||
|
|
||||||
|
setResponseHeader(event, 'Content-Type', 'application/json')
|
||||||
|
|
||||||
|
let body: any
|
||||||
|
try {
|
||||||
|
const raw = await readRawBody(event, 'utf8')
|
||||||
|
if (raw == null || String(raw).trim() === '') {
|
||||||
|
return jsonRpcError(null, -32700, 'Parse error')
|
||||||
|
}
|
||||||
|
body = JSON.parse(String(raw))
|
||||||
|
} catch {
|
||||||
|
return jsonRpcError(null, -32700, 'Parse error')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body == null || typeof body !== 'object' || Array.isArray(body)) {
|
||||||
|
return jsonRpcError(null, -32700, 'Parse error')
|
||||||
|
}
|
||||||
|
|
||||||
|
const rpcMethod = String(body.method || '')
|
||||||
|
const id = Object.prototype.hasOwnProperty.call(body, 'id') ? body.id : undefined
|
||||||
|
const isNotification = id === undefined
|
||||||
|
const params = body.params && typeof body.params === 'object' ? body.params as Record<string, unknown> : {}
|
||||||
|
|
||||||
|
// Handshake methods must succeed with no Authorization (Claude probes before sending the saved header).
|
||||||
|
if (rpcMethod === 'notifications/initialized') {
|
||||||
|
setResponseStatus(event, 202)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rpcMethod === 'initialize') {
|
||||||
|
return jsonRpcResult(id, {
|
||||||
|
protocolVersion: resolveMcpProtocolVersion(params.protocolVersion),
|
||||||
|
capabilities: { tools: {} },
|
||||||
|
serverInfo: MCP_SERVER_INFO
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rpcMethod === 'ping') {
|
||||||
|
return jsonRpcResult(id, {})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rpcMethod === 'tools/list') {
|
||||||
|
return jsonRpcResult(id, { tools: MCP_TOOLS })
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rpcMethod === 'tools/call') {
|
||||||
|
if (!mcpBearerOk(event)) {
|
||||||
|
return mcpUnauthorized(event, id ?? null)
|
||||||
|
}
|
||||||
|
mcpAssertAccess(event)
|
||||||
|
const name = String(params.name || '')
|
||||||
|
const args = params.arguments && typeof params.arguments === 'object' && !Array.isArray(params.arguments)
|
||||||
|
? params.arguments as Record<string, unknown>
|
||||||
|
: {}
|
||||||
|
const result = await callMcpTool(event, name, args)
|
||||||
|
return jsonRpcResult(id, result)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isNotification) {
|
||||||
|
setResponseStatus(event, 202)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return jsonRpcError(id, -32601, `Method not found: ${rpcMethod || '(missing)'}`)
|
||||||
|
})
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
import { createHash, timingSafeEqual } from 'node:crypto'
|
import { createHash, timingSafeEqual } from 'node:crypto'
|
||||||
import type { H3Event } from 'h3'
|
import type { H3Event } from 'h3'
|
||||||
import { isXaigenStudio } from '~/utils/videoModels'
|
|
||||||
import { passwordAuthEnabled, privateInstanceId } from '~/server/utils/localAuth'
|
import { passwordAuthEnabled, privateInstanceId } from '~/server/utils/localAuth'
|
||||||
|
|
||||||
function configuredApiKey() {
|
function configuredApiKey() {
|
||||||
@@ -30,7 +29,6 @@ export function aigenApiKeyConfigured() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function aigenBearerAuthorized(event: H3Event) {
|
export function aigenBearerAuthorized(event: H3Event) {
|
||||||
if (isXaigenStudio()) return false
|
|
||||||
const expected = configuredApiKey()
|
const expected = configuredApiKey()
|
||||||
if (!expected) return false
|
if (!expected) return false
|
||||||
const header = String(getHeader(event, 'authorization') || '')
|
const header = String(getHeader(event, 'authorization') || '')
|
||||||
@@ -40,13 +38,12 @@ export function aigenBearerAuthorized(event: H3Event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function aigenApiPathAllowed(path: string, method: string) {
|
export function aigenApiPathAllowed(path: string, method: string) {
|
||||||
|
if (path === '/mcp') return true
|
||||||
if (path === '/api/aigen' || path.startsWith('/api/aigen/')) return true
|
if (path === '/api/aigen' || path.startsWith('/api/aigen/')) return true
|
||||||
if (method === 'GET' && (path === '/api/library/stills' || path.startsWith('/api/library/stills/'))) return true
|
if (method === 'GET' && (path === '/api/library/stills' || path.startsWith('/api/library/stills/'))) return true
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
export function assertAigenFeature() {
|
export function assertAigenFeature() {
|
||||||
if (isXaigenStudio()) {
|
/* AIGen API is always available on the single studio deployment. */
|
||||||
throw createError({ statusCode: 404, statusMessage: 'Not found' })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,138 @@
|
|||||||
|
import type { H3Event } from 'h3'
|
||||||
|
import { filterLoraStackForUse } from '~/utils/loras'
|
||||||
|
import { validateRequest } from '~/shared/studio2/contracts.mjs'
|
||||||
|
import { defaultLibraryFolderId, isStudio2ImageEngine, studio2EngineDefaults } from '~/shared/studio2/engine-defaults.mjs'
|
||||||
|
import { resolveRequestSize } from '~/server/utils/studio2/size'
|
||||||
|
import { parsePostedLoraStack, assertImageV2LoraStack } from '~/server/utils/loras'
|
||||||
|
import { saveRecord, readRecord } from '~/server/utils/studio2/store'
|
||||||
|
import { addStudioJob, kickStudioQueue, type StudioJobPayload } from '~/server/utils/studioQueue'
|
||||||
|
import { assertAigenApiAccess } from '~/server/utils/aigenApi'
|
||||||
|
|
||||||
|
/** Same path as POST /api/aigen/generate — queue a still, return id + settings. */
|
||||||
|
export async function queueAigenGenerate(event: H3Event, body: Record<string, unknown>) {
|
||||||
|
const { owner, catalog } = assertAigenApiAccess(event)
|
||||||
|
|
||||||
|
const prompt = String(body.prompt || '').trim()
|
||||||
|
if (!prompt) {
|
||||||
|
throw createError({ statusCode: 400, statusMessage: 'A prompt is required' })
|
||||||
|
}
|
||||||
|
|
||||||
|
const engine = String(body.engine || 'flux').trim().toLowerCase() || 'flux'
|
||||||
|
if (!isStudio2ImageEngine(engine)) {
|
||||||
|
throw createError({ statusCode: 400, statusMessage: 'engine must be flux, krea, qwen21, or moss' })
|
||||||
|
}
|
||||||
|
|
||||||
|
const mode = String(body.mode || 'generate').trim().toLowerCase() || 'generate'
|
||||||
|
if (mode !== 'generate') {
|
||||||
|
throw createError({ statusCode: 400, statusMessage: 'mode must be generate' })
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaults = studio2EngineDefaults(engine)
|
||||||
|
const steps = body.steps == null || body.steps === ''
|
||||||
|
? defaults.steps
|
||||||
|
: Number(body.steps)
|
||||||
|
const cfg = body.cfg == null || body.cfg === ''
|
||||||
|
? defaults.cfg
|
||||||
|
: Number(body.cfg)
|
||||||
|
if (!Number.isFinite(steps) || !Number.isInteger(steps)) {
|
||||||
|
throw createError({ statusCode: 400, statusMessage: 'steps must be an integer' })
|
||||||
|
}
|
||||||
|
if (!Number.isFinite(cfg)) {
|
||||||
|
throw createError({ statusCode: 400, statusMessage: 'cfg must be a number' })
|
||||||
|
}
|
||||||
|
|
||||||
|
const aspect = String(body.aspect || defaults.aspect || 'auto').trim() || defaults.aspect
|
||||||
|
const folderId = defaultLibraryFolderId(catalog, body.folderId == null ? '' : String(body.folderId))
|
||||||
|
if (!folderId) {
|
||||||
|
throw createError({ statusCode: 400, statusMessage: 'Create a library folder before generating' })
|
||||||
|
}
|
||||||
|
|
||||||
|
const seedRaw = body.seed
|
||||||
|
const seedSet = seedRaw != null && String(seedRaw) !== ''
|
||||||
|
const seed = seedSet ? Number(seedRaw) : null
|
||||||
|
if (seedSet && !Number.isFinite(seed)) {
|
||||||
|
throw createError({ statusCode: 400, statusMessage: 'seed must be a number' })
|
||||||
|
}
|
||||||
|
|
||||||
|
const requestRaw = {
|
||||||
|
mode: 'generate',
|
||||||
|
engine,
|
||||||
|
folderId,
|
||||||
|
promptSections: { action: prompt },
|
||||||
|
settings: {
|
||||||
|
aspect,
|
||||||
|
steps,
|
||||||
|
cfg,
|
||||||
|
seed,
|
||||||
|
seedMode: seedSet ? 'locked' : 'random',
|
||||||
|
loraStack: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let request: any
|
||||||
|
try {
|
||||||
|
request = validateRequest(requestRaw)
|
||||||
|
} catch (e: any) {
|
||||||
|
throw createError({ statusCode: e.statusCode || 400, statusMessage: e.message })
|
||||||
|
}
|
||||||
|
|
||||||
|
request.settings.loraStack = parsePostedLoraStack(request.settings.loraStack, 'image')
|
||||||
|
request.settings.loraStack = filterLoraStackForUse(request.settings.loraStack, request.engine)
|
||||||
|
if (request.engine !== 'qwen21') assertImageV2LoraStack(request.settings.loraStack, request.engine)
|
||||||
|
assertFolderAccess(event, request.folderId)
|
||||||
|
try {
|
||||||
|
await resolveRequestSize(owner, request)
|
||||||
|
} catch (e: any) {
|
||||||
|
const message = e?.statusMessage || e?.message || 'Could not resolve size'
|
||||||
|
throw createError({
|
||||||
|
statusCode: e?.statusCode || 400,
|
||||||
|
statusMessage: message
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const id = crypto.randomUUID()
|
||||||
|
const record = {
|
||||||
|
id,
|
||||||
|
owner,
|
||||||
|
request,
|
||||||
|
state: 'waiting',
|
||||||
|
queuedAt: Date.now(),
|
||||||
|
familyId: crypto.randomUUID(),
|
||||||
|
outputs: [],
|
||||||
|
purgeResult: 'Not yet saved'
|
||||||
|
}
|
||||||
|
saveRecord(record)
|
||||||
|
void (async () => {
|
||||||
|
try {
|
||||||
|
const row = await addStudioJob({
|
||||||
|
ownerKey: owner,
|
||||||
|
kind: 'edit',
|
||||||
|
familyId: record.familyId,
|
||||||
|
payload: {
|
||||||
|
...request.settings,
|
||||||
|
engine: request.engine,
|
||||||
|
studio2Id: id,
|
||||||
|
studio2Request: structuredClone(request),
|
||||||
|
prompt: request.compiledPrompt,
|
||||||
|
folderId: request.folderId,
|
||||||
|
extensions: [],
|
||||||
|
referenceStillIds: [],
|
||||||
|
useIdentityRefs: false,
|
||||||
|
voidAutoRun: true
|
||||||
|
} as StudioJobPayload
|
||||||
|
})
|
||||||
|
saveRecord({ ...readRecord(owner, id), queueId: row.id })
|
||||||
|
} catch { /* poll / resume will pick up waiting studio2 records */ }
|
||||||
|
kickStudioQueue()
|
||||||
|
})()
|
||||||
|
|
||||||
|
return {
|
||||||
|
id,
|
||||||
|
engine: request.engine,
|
||||||
|
steps: request.settings.steps,
|
||||||
|
cfg: request.settings.cfg,
|
||||||
|
aspect: request.settings.aspect,
|
||||||
|
folderId: request.folderId,
|
||||||
|
status: 'waiting' as const
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import type { H3Event } from 'h3'
|
||||||
|
import { jobView } from '~/shared/studio2/queue-view.mjs'
|
||||||
|
import { getJob } from '~/server/utils/jobs'
|
||||||
|
import { readRecord } from '~/server/utils/studio2/store'
|
||||||
|
import { listStudioJobs } from '~/server/utils/studioQueue'
|
||||||
|
import { assertAigenApiAccess } from '~/server/utils/aigenApi'
|
||||||
|
import { publicBaseUrl } from '~/server/utils/session'
|
||||||
|
|
||||||
|
/** Same path as GET /api/aigen/jobs/:id — job state plus optional still URLs. */
|
||||||
|
export function readAigenJob(event: H3Event, idRaw: string, opts?: { absoluteStillUrl?: boolean }) {
|
||||||
|
const { owner } = assertAigenApiAccess(event)
|
||||||
|
const id = String(idRaw || '')
|
||||||
|
let record: any
|
||||||
|
try {
|
||||||
|
record = readRecord(owner, id)
|
||||||
|
} catch (e: any) {
|
||||||
|
throw createError({
|
||||||
|
statusCode: e?.statusCode || 404,
|
||||||
|
statusMessage: e?.statusMessage || 'Job not found'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const queue = listStudioJobs(owner).find(row => row.id === record.queueId)
|
||||||
|
const live = record.liveId ? getJob(record.liveId) : null
|
||||||
|
const view = jobView(record, queue, live)
|
||||||
|
const still = (record.outputs || []).find((item: any) => item?.id && item.kind !== 'clip' && item.kind !== 'track')
|
||||||
|
|| (record.outputs || []).find((item: any) => item?.id)
|
||||||
|
const stillId = still?.id ? String(still.id) : undefined
|
||||||
|
const stillUrl = stillId ? `/api/library/stills/${stillId}` : undefined
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: record.id,
|
||||||
|
state: view.state,
|
||||||
|
engine: record.request?.engine || '',
|
||||||
|
steps: record.request?.settings?.steps,
|
||||||
|
cfg: record.request?.settings?.cfg,
|
||||||
|
...(view.error ? { error: view.error } : {}),
|
||||||
|
...(stillId && stillUrl
|
||||||
|
? {
|
||||||
|
stillId,
|
||||||
|
stillUrl,
|
||||||
|
...(opts?.absoluteStillUrl
|
||||||
|
? { stillAbsoluteUrl: `${publicBaseUrl(event)}${stillUrl}` }
|
||||||
|
: {})
|
||||||
|
}
|
||||||
|
: {})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,151 @@
|
|||||||
|
import type { H3Event } from 'h3'
|
||||||
|
import { STUDIO2_IMAGE_ENGINES, studio2EngineDefaults } from '~/shared/studio2/engine-defaults.mjs'
|
||||||
|
import { aigenBearerAuthorized } from '~/server/utils/aigenApiAuth'
|
||||||
|
import { assertAigenApiAccess } from '~/server/utils/aigenApi'
|
||||||
|
import { queueAigenGenerate } from '~/server/utils/aigenGenerate'
|
||||||
|
import { readAigenJob } from '~/server/utils/aigenJob'
|
||||||
|
|
||||||
|
export const MCP_PROTOCOL_VERSION = '2025-03-26'
|
||||||
|
export const MCP_SERVER_INFO = { name: 'aigen', version: '1.0.0' }
|
||||||
|
export const MCP_SUPPORTED_PROTOCOL_VERSIONS = ['2025-03-26', '2025-06-18', '2025-11-25'] as const
|
||||||
|
|
||||||
|
const ENGINE_ENUM = [...STUDIO2_IMAGE_ENGINES]
|
||||||
|
|
||||||
|
export const MCP_TOOLS = [
|
||||||
|
{
|
||||||
|
name: 'aigen_engines',
|
||||||
|
description: 'Recommended steps, cfg, and aspect for flux, krea, qwen21, and moss.',
|
||||||
|
inputSchema: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {},
|
||||||
|
additionalProperties: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'aigen_generate',
|
||||||
|
description: 'Queue an AIGen still. Returns { id, engine, steps, cfg, aspect, folderId, status }.',
|
||||||
|
inputSchema: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
prompt: { type: 'string', description: 'Image prompt (required)' },
|
||||||
|
engine: {
|
||||||
|
type: 'string',
|
||||||
|
enum: ENGINE_ENUM,
|
||||||
|
description: 'Image engine (default flux)'
|
||||||
|
},
|
||||||
|
aspect: { type: 'string', description: 'Aspect ratio (optional; engine default if omitted)' },
|
||||||
|
folderId: { type: 'string', description: 'Library folder id (optional; Inbox/first folder if omitted)' },
|
||||||
|
steps: { type: 'integer', description: 'Sampling steps (optional)' },
|
||||||
|
cfg: { type: 'number', description: 'CFG scale (optional)' },
|
||||||
|
seed: { type: 'number', description: 'Seed (optional; random if omitted)' }
|
||||||
|
},
|
||||||
|
required: ['prompt'],
|
||||||
|
additionalProperties: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'aigen_job',
|
||||||
|
description: 'Poll an AIGen job by id. Returns state and stillUrl when done.',
|
||||||
|
inputSchema: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
id: { type: 'string', description: 'Job id from aigen_generate' }
|
||||||
|
},
|
||||||
|
required: ['id'],
|
||||||
|
additionalProperties: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
export function applyMcpCors(event: H3Event) {
|
||||||
|
const origin = String(getHeader(event, 'origin') || '').trim()
|
||||||
|
setResponseHeader(event, 'Access-Control-Allow-Origin', origin || '*')
|
||||||
|
setResponseHeader(event, 'Access-Control-Allow-Methods', 'GET, POST, OPTIONS')
|
||||||
|
setResponseHeader(event, 'Access-Control-Allow-Headers', 'Authorization, Content-Type, Accept, MCP-Protocol-Version')
|
||||||
|
setResponseHeader(event, 'Access-Control-Expose-Headers', 'Mcp-Session-Id')
|
||||||
|
setResponseHeader(event, 'Access-Control-Max-Age', '86400')
|
||||||
|
if (origin) setResponseHeader(event, 'Vary', 'Origin')
|
||||||
|
}
|
||||||
|
|
||||||
|
export function resolveMcpProtocolVersion(requested: unknown) {
|
||||||
|
const version = String(requested || '').trim()
|
||||||
|
if ((MCP_SUPPORTED_PROTOCOL_VERSIONS as readonly string[]).includes(version)) return version
|
||||||
|
return MCP_PROTOCOL_VERSION
|
||||||
|
}
|
||||||
|
|
||||||
|
export function jsonRpcError(id: unknown, code: number, message: string) {
|
||||||
|
return {
|
||||||
|
jsonrpc: '2.0',
|
||||||
|
id: id ?? null,
|
||||||
|
error: { code, message }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function jsonRpcResult(id: unknown, result: unknown) {
|
||||||
|
return {
|
||||||
|
jsonrpc: '2.0',
|
||||||
|
id: id ?? null,
|
||||||
|
result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 401 with JSON-RPC body — never a Nuxt error page, never WWW-Authenticate (no OAuth). */
|
||||||
|
export function mcpUnauthorized(event: H3Event, id: unknown = null) {
|
||||||
|
applyMcpCors(event)
|
||||||
|
setResponseStatus(event, 401)
|
||||||
|
setResponseHeader(event, 'Content-Type', 'application/json')
|
||||||
|
removeResponseHeader(event, 'WWW-Authenticate')
|
||||||
|
return jsonRpcError(id, -32001, 'Unauthorized')
|
||||||
|
}
|
||||||
|
|
||||||
|
export function mcpBearerOk(event: H3Event) {
|
||||||
|
return aigenBearerAuthorized(event)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function mcpAssertAccess(event: H3Event) {
|
||||||
|
assertAigenApiAccess(event)
|
||||||
|
}
|
||||||
|
|
||||||
|
function enginesPayload() {
|
||||||
|
const out: Record<string, { steps: number, cfg: number, aspect: string }> = {}
|
||||||
|
for (const engine of STUDIO2_IMAGE_ENGINES) {
|
||||||
|
out[engine] = studio2EngineDefaults(engine)
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
function toolTextResult(payload: unknown, isError = false) {
|
||||||
|
return {
|
||||||
|
content: [{ type: 'text', text: JSON.stringify(payload) }],
|
||||||
|
...(isError ? { isError: true } : {})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function errorMessage(err: any) {
|
||||||
|
return String(err?.statusMessage || err?.message || err || 'Tool failed')
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function callMcpTool(event: H3Event, name: string, args: Record<string, unknown>) {
|
||||||
|
if (name === 'aigen_engines') {
|
||||||
|
return toolTextResult(enginesPayload())
|
||||||
|
}
|
||||||
|
if (name === 'aigen_generate') {
|
||||||
|
try {
|
||||||
|
const result = await queueAigenGenerate(event, args)
|
||||||
|
return toolTextResult(result)
|
||||||
|
} catch (err: any) {
|
||||||
|
return toolTextResult({ error: errorMessage(err) }, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (name === 'aigen_job') {
|
||||||
|
try {
|
||||||
|
const id = String(args.id || '')
|
||||||
|
if (!id) return toolTextResult({ error: 'id is required' }, true)
|
||||||
|
const result = readAigenJob(event, id, { absoluteStillUrl: true })
|
||||||
|
return toolTextResult(result)
|
||||||
|
} catch (err: any) {
|
||||||
|
return toolTextResult({ error: errorMessage(err) }, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return toolTextResult({ error: `Unknown tool: ${name}` }, true)
|
||||||
|
}
|
||||||
@@ -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'
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,7 @@ import { composePromptParts } from '~/utils/promptParts'
|
|||||||
import { parsePostedLoraStack, listStudioLoras, persistLoraFields, ensureComfyLoraNames } from '~/server/utils/loras'
|
import { parsePostedLoraStack, listStudioLoras, persistLoraFields, ensureComfyLoraNames } from '~/server/utils/loras'
|
||||||
import { readLoraStack } from '~/utils/loras'
|
import { readLoraStack } from '~/utils/loras'
|
||||||
import { clampVideoCfg } from '~/utils/generationPresets'
|
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 { clampVideoDuration, clipPartDuration } from '~/utils/videoDuration'
|
||||||
import { createJob, emitJob, type Job } from '~/server/utils/jobs'
|
import { createJob, emitJob, type Job } from '~/server/utils/jobs'
|
||||||
import {
|
import {
|
||||||
@@ -105,10 +105,7 @@ export async function beginExtendFromClip(params: {
|
|||||||
shotIndex: (source.chainIndex || 0) + 1,
|
shotIndex: (source.chainIndex || 0) + 1,
|
||||||
familyRefs: source.permanenceRefs
|
familyRefs: source.permanenceRefs
|
||||||
})
|
})
|
||||||
const workflow = parseVideoWorkflow(source.workflow)
|
const workflow = coerceVideoWorkflow(source.workflow)
|
||||||
if (isLtxWorkflow(workflow) && !ltxWorkflowEnabled()) {
|
|
||||||
throw createError({ statusCode: 400, statusMessage: LTX_DISABLED_MESSAGE })
|
|
||||||
}
|
|
||||||
const turbo = source.turbo !== false
|
const turbo = source.turbo !== false
|
||||||
const fps = parseFps(source.fps)
|
const fps = parseFps(source.fps)
|
||||||
const cfg = parseCfg(source.cfg, turbo)
|
const cfg = parseCfg(source.cfg, turbo)
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ import {
|
|||||||
sanitizeMusicLyrics,
|
sanitizeMusicLyrics,
|
||||||
sanitizeMusicTags
|
sanitizeMusicTags
|
||||||
} from '~/utils/music'
|
} from '~/utils/music'
|
||||||
import { coerceVideoWorkflow, isXaigenStudio, parseVideoWorkflow } from '~/utils/videoModels'
|
import { coerceVideoWorkflow, parseVideoWorkflow } from '~/utils/videoModels'
|
||||||
|
|
||||||
const writeChains = new Map<string, Promise<unknown>>()
|
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',
|
task: mode === 'compose' ? parseImageV2Task(rec.task, 'scene') : mode === 'refine' ? 'refine' : mode === 'generate' ? 't2i' : 'scene',
|
||||||
prompt: sanitizePrompt(rec.prompt),
|
prompt: sanitizePrompt(rec.prompt),
|
||||||
negative: String(rec.negative || '').slice(0, 2000),
|
negative: String(rec.negative || '').slice(0, 2000),
|
||||||
snofsModel: isXaigenStudio() ? clampImageV2Strength(rec.snofsModel ?? rec.snofs_model, IMAGE_V2_SNOFS_MODEL) : 0,
|
snofsModel: clampImageV2Strength(rec.snofsModel ?? rec.snofs_model, IMAGE_V2_SNOFS_MODEL),
|
||||||
snofsClip: isXaigenStudio() ? clampImageV2Strength(rec.snofsClip ?? rec.snofs_clip, IMAGE_V2_SNOFS_CLIP) : 0,
|
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),
|
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),
|
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),
|
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 {
|
function publicPreset(preset: GenerationPreset): GenerationPreset {
|
||||||
const xaigen = isXaigenStudio()
|
|
||||||
const settings = preset.kind === 'video'
|
const settings = preset.kind === 'video'
|
||||||
? { ...preset.settings, workflow: coerceVideoWorkflow((preset.settings as VideoPresetSettings).workflow) }
|
? { ...preset.settings, workflow: coerceVideoWorkflow((preset.settings as VideoPresetSettings).workflow) }
|
||||||
: preset.kind === 'imagev2' && !xaigen
|
: preset.settings
|
||||||
? { ...preset.settings, snofsModel: 0, snofsClip: 0 }
|
|
||||||
: preset.settings
|
|
||||||
return {
|
return {
|
||||||
...preset,
|
...preset,
|
||||||
loraStack: filterLoraStackForStudio(preset.loraStack, xaigen),
|
loraStack: filterLoraStackForStudio(preset.loraStack),
|
||||||
settings
|
settings
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -234,8 +231,7 @@ export async function saveGenerationPreset(owner: string, input: {
|
|||||||
throw createError({ statusCode: 400, statusMessage: 'A preset name is required' })
|
throw createError({ statusCode: 400, statusMessage: 'A preset name is required' })
|
||||||
}
|
}
|
||||||
const kind = parseGenerationPresetKind(input.kind)
|
const kind = parseGenerationPresetKind(input.kind)
|
||||||
const xaigen = isXaigenStudio()
|
const loraStack = filterLoraStackForStudio(input.loraStack)
|
||||||
const loraStack = filterLoraStackForStudio(input.loraStack, xaigen)
|
|
||||||
const settings = sanitizeSettings(kind, input.settings)
|
const settings = sanitizeSettings(kind, input.settings)
|
||||||
const now = Date.now()
|
const now = Date.now()
|
||||||
return mutate(owner, (presets) => {
|
return mutate(owner, (presets) => {
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import { emitChainJob } from '~/server/utils/watch'
|
|||||||
import { saveStill, stillChainName } from '~/server/utils/library'
|
import { saveStill, stillChainName } from '~/server/utils/library'
|
||||||
import { comfyJobPrefix } from '~/utils/outputNames'
|
import { comfyJobPrefix } from '~/utils/outputNames'
|
||||||
import { restorePromptParts, wrappedPromptForComfy } from '~/utils/promptParts'
|
import { restorePromptParts, wrappedPromptForComfy } from '~/utils/promptParts'
|
||||||
import { isXaigenStudio } from '~/utils/videoModels'
|
|
||||||
import {
|
import {
|
||||||
imageV2GraphMode,
|
imageV2GraphMode,
|
||||||
imageV2StackSpecials,
|
imageV2StackSpecials,
|
||||||
@@ -141,7 +140,7 @@ export async function runEditV2(job: Job, params: EditV2RunParams) {
|
|||||||
const appliedStack = mergeLegacyImageV2Loras(pass?.loraStack ?? params.loraStack ?? library.loraStack, {
|
const appliedStack = mergeLegacyImageV2Loras(pass?.loraStack ?? params.loraStack ?? library.loraStack, {
|
||||||
engine,
|
engine,
|
||||||
mode: graphMode,
|
mode: graphMode,
|
||||||
xaigen: isXaigenStudio(),
|
xaigen: true,
|
||||||
snofsModel: pass?.loraStack !== undefined ? 0 : params.snofsModel,
|
snofsModel: pass?.loraStack !== undefined ? 0 : params.snofsModel,
|
||||||
snofsClip: pass?.loraStack !== undefined ? 0 : params.snofsClip,
|
snofsClip: pass?.loraStack !== undefined ? 0 : params.snofsClip,
|
||||||
consistencyModel: pass?.loraStack !== undefined ? 0 : params.consistencyModel,
|
consistencyModel: pass?.loraStack !== undefined ? 0 : params.consistencyModel,
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import { imageComfyFetch } from '~/server/utils/imageComfy'
|
|||||||
import { applyImageV2UserLoras } from '~/server/utils/loras'
|
import { applyImageV2UserLoras } from '~/server/utils/loras'
|
||||||
import { type LoraStackItem } from '~/utils/loras'
|
import { type LoraStackItem } from '~/utils/loras'
|
||||||
import { clampImageCfg, clampImageScaleMegapixels, clampImageSteps } from '~/utils/generationPresets'
|
import { clampImageCfg, clampImageScaleMegapixels, clampImageSteps } from '~/utils/generationPresets'
|
||||||
import { isXaigenStudio } from '~/utils/videoModels'
|
|
||||||
import {
|
import {
|
||||||
IMAGE_V2_KREA_CFG,
|
IMAGE_V2_KREA_CFG,
|
||||||
IMAGE_V2_KREA_CLIP,
|
IMAGE_V2_KREA_CLIP,
|
||||||
@@ -490,7 +489,7 @@ function imageV2UserStack(params: ImageV2BuildParams, engine: ImageV2Engine) {
|
|||||||
return mergeLegacyImageV2Loras(params.loraStack, {
|
return mergeLegacyImageV2Loras(params.loraStack, {
|
||||||
engine,
|
engine,
|
||||||
mode: params.mode,
|
mode: params.mode,
|
||||||
xaigen: isXaigenStudio(),
|
xaigen: true,
|
||||||
snofsModel: params.snofsModel,
|
snofsModel: params.snofsModel,
|
||||||
snofsClip: params.snofsClip,
|
snofsClip: params.snofsClip,
|
||||||
consistencyModel: params.consistencyModel,
|
consistencyModel: params.consistencyModel,
|
||||||
|
|||||||
+9
-21
@@ -1,12 +1,10 @@
|
|||||||
import { comfyConfigured, comfyFetch, getComfyHost } from '~/server/utils/comfy'
|
import { comfyConfigured, comfyFetch, getComfyHost } from '~/server/utils/comfy'
|
||||||
import { getBeastImageHost, imageComfyFetch, sameImageHost } from '~/server/utils/imageComfy'
|
import { getBeastImageHost, imageComfyFetch, sameImageHost } from '~/server/utils/imageComfy'
|
||||||
import {
|
import {
|
||||||
XAIGEN_LORA_MESSAGE,
|
|
||||||
MINIMAX_TURBO_LORA,
|
MINIMAX_TURBO_LORA,
|
||||||
filterLorasForStudio,
|
filterLorasForStudio,
|
||||||
imageLoraEngineMismatchMessage,
|
imageLoraEngineMismatchMessage,
|
||||||
imageLoraEngineOf,
|
imageLoraEngineOf,
|
||||||
isXaigenOnlyLora,
|
|
||||||
loraIdentityKey,
|
loraIdentityKey,
|
||||||
normalizeLoraName,
|
normalizeLoraName,
|
||||||
normalizeLoraStack,
|
normalizeLoraStack,
|
||||||
@@ -15,7 +13,7 @@ import {
|
|||||||
type LoraKind,
|
type LoraKind,
|
||||||
type LoraStackItem
|
type LoraStackItem
|
||||||
} from '~/utils/loras'
|
} 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 WorkflowNode = { class_type: string; inputs: Record<string, unknown>; _meta?: { title?: string } }
|
||||||
type WorkflowGraph = Record<string, WorkflowNode>
|
type WorkflowGraph = Record<string, WorkflowNode>
|
||||||
@@ -216,22 +214,21 @@ async function loadLoraCache(options: { fresh?: boolean } = {}): Promise<LoraCac
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function listStudioLoras(options: { fresh?: boolean } = {}) {
|
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
|
// `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.
|
// without a restart. Names stay Comfy-relative (slashes included) for the graph.
|
||||||
try {
|
try {
|
||||||
const listed = await loadLoraCache(options)
|
const listed = await loadLoraCache(options)
|
||||||
return {
|
return {
|
||||||
at: listed.at,
|
at: listed.at,
|
||||||
image: filterLorasForStudio(listed.image, xaigen),
|
image: filterLorasForStudio(listed.image),
|
||||||
video: filterLorasForStudio(listed.video, xaigen)
|
video: filterLorasForStudio(listed.video)
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
if (cache) {
|
if (cache) {
|
||||||
return {
|
return {
|
||||||
at: cache.at,
|
at: cache.at,
|
||||||
image: filterLorasForStudio(cache.image, xaigen),
|
image: filterLorasForStudio(cache.image),
|
||||||
video: filterLorasForStudio(cache.video, xaigen)
|
video: filterLorasForStudio(cache.video)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { at: 0, image: [] as string[], video: [] as string[] }
|
return { at: 0, image: [] as string[], video: [] as string[] }
|
||||||
@@ -267,7 +264,7 @@ export function resolveGraphLoraNames(graph: WorkflowGraph, kind?: LoraKind) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function allowedLoraNames(kind?: LoraKind) {
|
function allowedLoraNames(kind?: LoraKind) {
|
||||||
return filterLorasForStudio(cachedComfyLoraNames(kind), isXaigenStudio())
|
return filterLorasForStudio(cachedComfyLoraNames(kind))
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveUserLoraName(name: string, kind?: LoraKind) {
|
function resolveUserLoraName(name: string, kind?: LoraKind) {
|
||||||
@@ -279,9 +276,6 @@ function resolveUserLoraName(name: string, kind?: LoraKind) {
|
|||||||
export function assertLoraAllowed(raw: unknown, kind: LoraKind) {
|
export function assertLoraAllowed(raw: unknown, kind: LoraKind) {
|
||||||
const name = normalizeLoraName(raw)
|
const name = normalizeLoraName(raw)
|
||||||
if (!name) return ''
|
if (!name) return ''
|
||||||
if (isXaigenOnlyLora(name) && !isXaigenStudio()) {
|
|
||||||
throw createError({ statusCode: 400, statusMessage: XAIGEN_LORA_MESSAGE })
|
|
||||||
}
|
|
||||||
const allowed = allowedLoraNames(kind)
|
const allowed = allowedLoraNames(kind)
|
||||||
if (allowed.length) {
|
if (allowed.length) {
|
||||||
const identity = loraIdentityKey(name)
|
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. */
|
/** 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') {
|
export function applyOptionalLoraLoaders(graph: WorkflowGraph, stack?: unknown, kind: LoraKind = 'image') {
|
||||||
const loaders = Object.entries(graph).filter(([, node]) => node.class_type === LORA_LOADER)
|
const loaders = Object.entries(graph).filter(([, node]) => node.class_type === LORA_LOADER)
|
||||||
const xaigen = isXaigenStudio()
|
|
||||||
const items = normalizeLoraStack(stack)
|
const items = normalizeLoraStack(stack)
|
||||||
.filter(item => xaigen || !isXaigenOnlyLora(item.name))
|
|
||||||
.map(item => ({
|
.map(item => ({
|
||||||
...item,
|
...item,
|
||||||
name: resolveUserLoraName(item.name, kind)
|
name: resolveUserLoraName(item.name, kind)
|
||||||
}))
|
}))
|
||||||
.filter(item => item.name && (xaigen || !isXaigenOnlyLora(item.name)))
|
.filter(item => item.name)
|
||||||
if (!loaders.length) {
|
if (!loaders.length) {
|
||||||
applyUserLoraToGraph(graph, items)
|
applyUserLoraToGraph(graph, items)
|
||||||
return
|
return
|
||||||
@@ -487,14 +479,12 @@ export function applyImageV2UserLoras(
|
|||||||
) {
|
) {
|
||||||
stripExistingLoraLoaders(graph)
|
stripExistingLoraLoaders(graph)
|
||||||
|
|
||||||
const xaigen = isXaigenStudio()
|
|
||||||
const items = normalizeLoraStack(stack)
|
const items = normalizeLoraStack(stack)
|
||||||
.filter(item => xaigen || !isXaigenOnlyLora(item.name))
|
|
||||||
.map(item => ({
|
.map(item => ({
|
||||||
...item,
|
...item,
|
||||||
name: resolveUserLoraName(item.name, 'image')
|
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 wrong = items.find((item) => {
|
||||||
const tagged = imageLoraEngineOf(item.name)
|
const tagged = imageLoraEngineOf(item.name)
|
||||||
@@ -557,11 +547,9 @@ export function applyImageV2UserLoras(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function applyUserLoraToGraph(graph: WorkflowGraph, stack?: unknown) {
|
export function applyUserLoraToGraph(graph: WorkflowGraph, stack?: unknown) {
|
||||||
const xaigen = isXaigenStudio()
|
|
||||||
const items = normalizeLoraStack(stack)
|
const items = normalizeLoraStack(stack)
|
||||||
.filter(item => xaigen || !isXaigenOnlyLora(item.name))
|
|
||||||
.map(item => ({ ...item, name: resolveUserLoraName(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
|
if (!items.length) return
|
||||||
|
|
||||||
const clipLoaders = Object.entries(graph).filter(([, node]) => node.class_type === LORA_LOADER)
|
const clipLoaders = Object.entries(graph).filter(([, node]) => node.class_type === LORA_LOADER)
|
||||||
|
|||||||
@@ -273,47 +273,16 @@ async function prepareGraph(r: any) {
|
|||||||
start = await upload(r, 'start', readFileSync(dest));
|
start = await upload(r, 'start', readFileSync(dest));
|
||||||
unlinkSync(dest);
|
unlinkSync(dest);
|
||||||
}
|
}
|
||||||
if (q.engine === 'ltx') {
|
if (q.engine !== 'minimax')
|
||||||
const { buildWorkflow } = await import('../workflow');
|
throw new Error('Studio 2 video supports MiniMax H3 only.');
|
||||||
const { frameLength } = await import('../videoChain');
|
const end = await load(q.endStillId, 'end'), guides = [];
|
||||||
const { ltxWorkflowEnabled, LTX_DISABLED_MESSAGE } = await import('~/utils/videoModels');
|
for (const [i, g] of q.guides.entries())
|
||||||
if (!ltxWorkflowEnabled()) throw new Error(LTX_DISABLED_MESSAGE);
|
guides.push({ image: await load(g.stillId, `guide${i}`), frame: g.frame });
|
||||||
const textToVideo = q.mode === 'video' && !start;
|
graph = nativeVideoGraph(template, q, { hero, start, end, guides }, prefix);
|
||||||
if (!start && !textToVideo) throw new Error('Choose a start still for LTX video.');
|
await ensureComfyLoraNames('video');
|
||||||
const fps = s.fps || 24;
|
resolveGraphLoraNames(graph, 'video');
|
||||||
graph = buildWorkflow({
|
applyUserLoraToGraph(graph, s.loraStack);
|
||||||
workflow: textToVideo ? 'ltx-t2v' : 'ltx',
|
r.graphId = 'studio2_minimax_native.json';
|
||||||
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';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (q.engine === 'moss') {
|
else if (q.engine === 'moss') {
|
||||||
if (q.mode !== 'generate')
|
if (q.mode !== 'generate')
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { getJob, listJobs, emitJob, type Job } from '~/server/utils/jobs'
|
|||||||
import { listPendingJobs, patchPendingJob, readPendingJob, deletePendingJob } from '~/server/utils/pending'
|
import { listPendingJobs, patchPendingJob, readPendingJob, deletePendingJob } from '~/server/utils/pending'
|
||||||
import { getShotQueue, pendingSegmentCount } from '~/server/utils/shotQueue'
|
import { getShotQueue, pendingSegmentCount } from '~/server/utils/shotQueue'
|
||||||
import { fetchLiveQueue } from '~/server/utils/comfy'
|
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 { persistLoraFields } from '~/server/utils/loras'
|
||||||
import { resolveLoraStack } from '~/utils/loras'
|
import { resolveLoraStack } from '~/utils/loras'
|
||||||
import { persistPromptWrappers } from '~/utils/promptParts'
|
import { persistPromptWrappers } from '~/utils/promptParts'
|
||||||
@@ -1565,10 +1565,7 @@ async function startStudioJobReserved(item: StudioJob) {
|
|||||||
const { existsSync, readFileSync } = await import('node:fs')
|
const { existsSync, readFileSync } = await import('node:fs')
|
||||||
|
|
||||||
const payload = item.payload
|
const payload = item.payload
|
||||||
const workflow = parseVideoWorkflow(payload.workflow)
|
const workflow = coerceVideoWorkflow(payload.workflow)
|
||||||
if (isLtxWorkflow(workflow) && !ltxWorkflowEnabled()) {
|
|
||||||
throw new Error(LTX_DISABLED_MESSAGE)
|
|
||||||
}
|
|
||||||
const identity = allowIdentityRefs(
|
const identity = allowIdentityRefs(
|
||||||
payload.useIdentityRefs,
|
payload.useIdentityRefs,
|
||||||
payload.permanenceRefs,
|
payload.permanenceRefs,
|
||||||
|
|||||||
@@ -7,11 +7,10 @@ import { buildIdentityPrompt } from '~/utils/identityPrompt'
|
|||||||
import { applyUserLoraToGraph, resolveGraphLoraNames } from '~/server/utils/loras'
|
import { applyUserLoraToGraph, resolveGraphLoraNames } from '~/server/utils/loras'
|
||||||
import type { LoraStackItem } from '~/utils/loras'
|
import type { LoraStackItem } from '~/utils/loras'
|
||||||
import {
|
import {
|
||||||
|
coerceVideoWorkflow,
|
||||||
isLtxWorkflow,
|
isLtxWorkflow,
|
||||||
isTextToVideo,
|
isTextToVideo,
|
||||||
LTX_DISABLED_MESSAGE,
|
|
||||||
LTX_NEGATIVE,
|
LTX_NEGATIVE,
|
||||||
ltxWorkflowEnabled,
|
|
||||||
parseVideoWorkflow,
|
parseVideoWorkflow,
|
||||||
type VideoWorkflowId
|
type VideoWorkflowId
|
||||||
} from '~/utils/videoModels'
|
} from '~/utils/videoModels'
|
||||||
@@ -81,10 +80,7 @@ function templateFor(id: VideoWorkflowId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function buildWorkflow(params: GenerateParams) {
|
export function buildWorkflow(params: GenerateParams) {
|
||||||
const version = parseVideoWorkflow(params.workflow)
|
const version = coerceVideoWorkflow(params.workflow)
|
||||||
if (isLtxWorkflow(version) && !ltxWorkflowEnabled()) {
|
|
||||||
throw new Error(LTX_DISABLED_MESSAGE)
|
|
||||||
}
|
|
||||||
if (isLtxWorkflow(version)) return buildLtxWorkflow(params, version)
|
if (isLtxWorkflow(version)) return buildLtxWorkflow(params, version)
|
||||||
|
|
||||||
const graph = structuredClone(templateFor(version === 't2v' ? 'v1' : version === 'v2' ? 'v2' : 'v1'))
|
const graph = structuredClone(templateFor(version === 't2v' ? 'v1' : version === 'v2' ? 'v2' : 'v1'))
|
||||||
|
|||||||
@@ -29,14 +29,13 @@ export function restoreInput(item) {
|
|||||||
const saved = structuredClone(item.studio2 || item)
|
const saved = structuredClone(item.studio2 || item)
|
||||||
return { ...saved, lockFace:saved.lockFace !== false, lockOutfit:saved.lockOutfit !== false, hideInput:!!saved.hideInput, settings:structuredClone(saved.settings || {}), promptSections: sectionsFrom(saved.promptSections || { action: item.prompt || saved.compiledPrompt || '' }) }
|
return { ...saved, lockFace:saved.lockFace !== false, lockOutfit:saved.lockOutfit !== false, hideInput:!!saved.hideInput, settings:structuredClone(saved.settings || {}), promptSections: sectionsFrom(saved.promptSections || { action: item.prompt || saved.compiledPrompt || '' }) }
|
||||||
}
|
}
|
||||||
export function validateRequest(raw, xaigen = false) {
|
export function validateRequest(raw) {
|
||||||
raw = applyPhotosToRequest(raw || {})
|
raw = applyPhotosToRequest(raw || {})
|
||||||
const fail = message => { throw Object.assign(new Error(message), {statusCode:400}) }
|
const fail = message => { throw Object.assign(new Error(message), {statusCode:400}) }
|
||||||
const mode = raw.mode || 'generate', engine = raw.engine || 'flux'
|
const mode = raw.mode || 'generate', engine = raw.engine || 'flux'
|
||||||
if (!['generate','edit','compose','refine','iterate','video','extend'].includes(mode)) fail('Unknown task.')
|
if (!['generate','edit','compose','refine','iterate','video','extend'].includes(mode)) fail('Unknown task.')
|
||||||
const video = ['video','extend'].includes(mode)
|
const video = ['video','extend'].includes(mode)
|
||||||
if (!(video ? ['minimax','ltx'] : ['flux','krea','qwen21','moss']).includes(engine)) fail('Engine does not support this task.')
|
if (!(video ? ['minimax'] : ['flux','krea','qwen21','moss']).includes(engine)) fail('Engine does not support this task.')
|
||||||
if (engine === 'ltx' && !xaigen) fail('LTX is available only in xAIGen.')
|
|
||||||
if (engine === 'krea' && ['edit','compose','iterate'].includes(mode)) fail('Sticky hero edits require Klein. Krea remains available for Generate and masked Refine; no engine fallback is performed.')
|
if (engine === 'krea' && ['edit','compose','iterate'].includes(mode)) fail('Sticky hero edits require Klein. Krea remains available for Generate and masked Refine; no engine fallback is performed.')
|
||||||
if (engine === 'qwen21' && !['generate', 'edit'].includes(mode)) fail('Qwen 2.1 supports Generate and Edit.')
|
if (engine === 'qwen21' && !['generate', 'edit'].includes(mode)) fail('Qwen 2.1 supports Generate and Edit.')
|
||||||
if (engine === 'moss' && mode !== 'generate') fail('MOSS-Image is text-to-image only.')
|
if (engine === 'moss' && mode !== 'generate') fail('MOSS-Image is text-to-image only.')
|
||||||
|
|||||||
+18
-18
@@ -33,7 +33,7 @@ export function resolveSize(aspect, source, fallback = {width:1344,height:768},
|
|||||||
|
|
||||||
export { ASPECT_IDS }
|
export { ASPECT_IDS }
|
||||||
|
|
||||||
export function bindClip(form, clip, xaigen = false, memory) {
|
export function bindClip(form, clip, memory) {
|
||||||
if (!clip?.id) return form
|
if (!clip?.id) return form
|
||||||
const saved = clip.studio2 || clip.job || {}
|
const saved = clip.studio2 || clip.job || {}
|
||||||
const settings = saved.settings || clip.settings || {}
|
const settings = saved.settings || clip.settings || {}
|
||||||
@@ -44,14 +44,14 @@ export function bindClip(form, clip, xaigen = false, memory) {
|
|||||||
try { next.settings[key] = typeof structuredClone === 'function' ? structuredClone(settings[key]) : JSON.parse(JSON.stringify(settings[key])) }
|
try { next.settings[key] = typeof structuredClone === 'function' ? structuredClone(settings[key]) : JSON.parse(JSON.stringify(settings[key])) }
|
||||||
catch { next.settings[key] = settings[key] }
|
catch { next.settings[key] = settings[key] }
|
||||||
}
|
}
|
||||||
next.engine = xaigen && (saved.engine || clip.engine)==='ltx' ? 'ltx' : 'minimax'
|
next.engine = 'minimax'
|
||||||
if (saved.identityStillId) next.identityStillId = saved.identityStillId
|
if (saved.identityStillId) next.identityStillId = saved.identityStillId
|
||||||
for (const key of ['lockFace','lockOutfit']) if (typeof saved[key] === 'boolean') next[key] = saved[key]
|
for (const key of ['lockFace','lockOutfit']) if (typeof saved[key] === 'boolean') next[key] = saved[key]
|
||||||
return restoreLoras(next,settings.loraStack,xaigen,memory)
|
return restoreLoras(next,settings.loraStack,memory)
|
||||||
}
|
}
|
||||||
export function restoreAsset(form, item, xaigen = false, memory) {
|
export function restoreAsset(form, item, memory) {
|
||||||
if (item.kind==='clip' || item.studio2?.kind==='video') {
|
if (item.kind==='clip' || item.studio2?.kind==='video') {
|
||||||
const next=bindClip(form,item,xaigen,memory)
|
const next=bindClip(form,item,memory)
|
||||||
const seed=item.studio2?.settings?.seed ?? item.settings?.seed ?? item.seed
|
const seed=item.studio2?.settings?.seed ?? item.settings?.seed ?? item.seed
|
||||||
if (seed != null) next.settings.seed=seed
|
if (seed != null) next.settings.seed=seed
|
||||||
next.settings.seedMode='random'
|
next.settings.seedMode='random'
|
||||||
@@ -65,16 +65,16 @@ export function restoreAsset(form, item, xaigen = false, memory) {
|
|||||||
next.imageAId=item.id
|
next.imageAId=item.id
|
||||||
next.startClipId=''
|
next.startClipId=''
|
||||||
next.settings.aspect=item.studio2?.settings?.aspect || item.settings?.aspect || 'auto'
|
next.settings.aspect=item.studio2?.settings?.aspect || item.settings?.aspect || 'auto'
|
||||||
return restoreLoras(next,item.studio2?.settings?.loraStack ?? item.settings?.loraStack,xaigen,memory)
|
return restoreLoras(next,item.studio2?.settings?.loraStack ?? item.settings?.loraStack,memory)
|
||||||
}
|
}
|
||||||
export function extendSelected(form, clip, xaigen = false, memory) {
|
export function extendSelected(form, clip, memory) {
|
||||||
const next = { ...form, settings:{...form.settings}, mode: 'extend', engine: xaigen && form.engine === 'ltx' ? 'ltx' : 'minimax' }
|
const next = { ...form, settings:{...form.settings}, mode: 'extend', engine: 'minimax' }
|
||||||
const target = clip?.id ? clip : null
|
const target = clip?.id ? clip : null
|
||||||
if (!target?.id) return restoreLoras(next,loraUse(form)===loraUse(next)?form.settings?.loraStack:[],xaigen,memory)
|
if (!target?.id) return restoreLoras(next,loraUse(form)===loraUse(next)?form.settings?.loraStack:[],memory)
|
||||||
// Already bound to this clip: switching task must not stomp the user's overrides
|
// Already bound to this clip: switching task must not stomp the user's overrides
|
||||||
// (locks, CFG, etc.) by re-copying the clip's saved settings over them.
|
// (locks, CFG, etc.) by re-copying the clip's saved settings over them.
|
||||||
if (form.startClipId === target.id) return restoreLoras(next,loraUse(form)===loraUse(next)?form.settings?.loraStack:[],xaigen,memory)
|
if (form.startClipId === target.id) return restoreLoras(next,loraUse(form)===loraUse(next)?form.settings?.loraStack:[],memory)
|
||||||
try { return bindClip(next, target, xaigen, memory) }
|
try { return bindClip(next, target, memory) }
|
||||||
catch { return { ...next, startClipId: target.id } }
|
catch { return { ...next, startClipId: target.id } }
|
||||||
}
|
}
|
||||||
export function changeSource(form) {
|
export function changeSource(form) {
|
||||||
@@ -85,7 +85,7 @@ export function useAsHero(form, item) { return {...form,identityStillId:item.id}
|
|||||||
export function useAsSource(form, item) { return {...form,imageAId:item.id} }
|
export function useAsSource(form, item) { return {...form,imageAId:item.id} }
|
||||||
|
|
||||||
/** Hydrate the live bench from a saved Studio 2 request (Load). Does not enqueue. */
|
/** Hydrate the live bench from a saved Studio 2 request (Load). Does not enqueue. */
|
||||||
export function hydrateStudio2Job(form, saved, { stillIds = new Set(), clipIds = new Set(), xaigen = false, memory } = {}) {
|
export function hydrateStudio2Job(form, saved, { stillIds = new Set(), clipIds = new Set(), memory } = {}) {
|
||||||
const src = structuredClone(saved?.studio2 || saved || {})
|
const src = structuredClone(saved?.studio2 || saved || {})
|
||||||
const missing = []
|
const missing = []
|
||||||
const keepStill = (id, label) => {
|
const keepStill = (id, label) => {
|
||||||
@@ -104,8 +104,8 @@ export function hydrateStudio2Job(form, saved, { stillIds = new Set(), clipIds =
|
|||||||
}
|
}
|
||||||
const modeRaw = src.mode === 'iterate' ? 'edit' : src.mode
|
const modeRaw = src.mode === 'iterate' ? 'edit' : src.mode
|
||||||
const mode = ['generate','edit','compose','refine','video','extend','music'].includes(modeRaw) ? modeRaw : 'edit'
|
const mode = ['generate','edit','compose','refine','video','extend','music'].includes(modeRaw) ? modeRaw : 'edit'
|
||||||
let engine = src.engine === 'moss' ? 'moss' : src.engine === 'qwen21' ? 'qwen21' : src.engine === 'krea' ? 'krea' : src.engine === 'ltx' ? 'ltx' : src.engine === 'minimax' ? 'minimax' : 'flux'
|
let engine = src.engine === 'moss' ? 'moss' : src.engine === 'qwen21' ? 'qwen21' : src.engine === 'krea' ? 'krea' : src.engine === 'minimax' ? 'minimax' : 'flux'
|
||||||
if (['video','extend'].includes(mode)) engine = xaigen && engine === 'ltx' ? 'ltx' : 'minimax'
|
if (['video','extend'].includes(mode)) engine = 'minimax'
|
||||||
else if (engine === 'minimax' || engine === 'ltx') engine = 'flux'
|
else if (engine === 'minimax' || engine === 'ltx') engine = 'flux'
|
||||||
const settings = structuredClone(src.settings || {})
|
const settings = structuredClone(src.settings || {})
|
||||||
const aspect = ASPECT_IDS.has(settings.aspect) ? settings.aspect : 'auto'
|
const aspect = ASPECT_IDS.has(settings.aspect) ? settings.aspect : 'auto'
|
||||||
@@ -146,15 +146,15 @@ export function hydrateStudio2Job(form, saved, { stillIds = new Set(), clipIds =
|
|||||||
loraStack
|
loraStack
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { form: restoreLoras(next, loraStack, xaigen, memory), missing: missing[0] || '', warnings: missing }
|
return { form: restoreLoras(next, loraStack, memory), missing: missing[0] || '', warnings: missing }
|
||||||
}
|
}
|
||||||
|
|
||||||
export function restoreAll(form,item,xaigen=false,memory) {
|
export function restoreAll(form,item,memory) {
|
||||||
const restored=restoreInput(item),next={...form,...restored,settings:{...form.settings,...restored.settings,seedMode:'random'}}
|
const restored=restoreInput(item),next={...form,...restored,settings:{...form.settings,...restored.settings,seedMode:'random'}}
|
||||||
if(item.kind==='clip') return {...bindClip(next,item,xaigen,memory),mode:'extend'}
|
if(item.kind==='clip') return {...bindClip(next,item,memory),mode:'extend'}
|
||||||
next.mode=restored.mode==='iterate'?'edit':restored.mode || 'edit'
|
next.mode=restored.mode==='iterate'?'edit':restored.mode || 'edit'
|
||||||
next.engine=restored.engine==='moss'?'moss':restored.engine==='qwen21'?'qwen21':restored.engine==='krea'?'krea':'flux'
|
next.engine=restored.engine==='moss'?'moss':restored.engine==='qwen21'?'qwen21':restored.engine==='krea'?'krea':'flux'
|
||||||
next.imageAId=item.id
|
next.imageAId=item.id
|
||||||
next.startClipId=''
|
next.startClipId=''
|
||||||
return restoreLoras(next,item.studio2?.settings?.loraStack ?? item.settings?.loraStack,xaigen,memory)
|
return restoreLoras(next,item.studio2?.settings?.loraStack ?? item.settings?.loraStack,memory)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,21 +2,21 @@ import {filterLoraStackForUse} from '../../utils/loras.ts'
|
|||||||
|
|
||||||
export function loraUse(form) {
|
export function loraUse(form) {
|
||||||
const video=['video','extend'].includes(form.mode)
|
const video=['video','extend'].includes(form.mode)
|
||||||
if (video) return form.engine==='ltx'?'ltx':'minimax'
|
if (video) return 'minimax'
|
||||||
if (form.engine==='qwen21') return 'qwen21'
|
if (form.engine==='qwen21') return 'qwen21'
|
||||||
if (form.engine==='moss') return 'moss'
|
if (form.engine==='moss') return 'moss'
|
||||||
return form.engine==='krea'?'krea':'flux'
|
return form.engine==='krea'?'krea':'flux'
|
||||||
}
|
}
|
||||||
|
|
||||||
// One controller per bench. Storage is optional (SSR/private browsing still works).
|
// One controller per bench. Storage is optional (SSR/private browsing still works).
|
||||||
export function createLoraMemory(xaigen, storage) {
|
export function createLoraMemory(storage) {
|
||||||
const stacks={}
|
const stacks={}
|
||||||
let active=null
|
let active=null
|
||||||
const key=`studio2-lora-stacks:${xaigen?'xaigen':'aigen'}`
|
const key='studio2-lora-stacks:aigen'
|
||||||
try { Object.assign(stacks,JSON.parse(storage?.getItem(key)||'{}')) } catch {}
|
try { Object.assign(stacks,JSON.parse(storage?.getItem(key)||'{}')) } catch {}
|
||||||
const load=use=>filterLoraStackForUse(stacks[use],use,xaigen)
|
const load=use=>filterLoraStackForUse(stacks[use],use)
|
||||||
const save=(use,stack)=>{
|
const save=(use,stack)=>{
|
||||||
stacks[use]=filterLoraStackForUse(stack,use,xaigen)
|
stacks[use]=filterLoraStackForUse(stack,use)
|
||||||
try { storage?.setItem(key,JSON.stringify(stacks)) } catch {}
|
try { storage?.setItem(key,JSON.stringify(stacks)) } catch {}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
@@ -31,7 +31,7 @@ export function createLoraMemory(xaigen, storage) {
|
|||||||
},
|
},
|
||||||
restore(form,stack) {
|
restore(form,stack) {
|
||||||
const use=loraUse(form)
|
const use=loraUse(form)
|
||||||
form.settings.loraStack=stack?.length ? filterLoraStackForUse(stack,use,xaigen) : load(use)
|
form.settings.loraStack=stack?.length ? filterLoraStackForUse(stack,use) : load(use)
|
||||||
active=use
|
active=use
|
||||||
save(use,form.settings.loraStack)
|
save(use,form.settings.loraStack)
|
||||||
return form
|
return form
|
||||||
@@ -39,8 +39,8 @@ export function createLoraMemory(xaigen, storage) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function restoreLoras(form, stack, xaigen=false, memory) {
|
export function restoreLoras(form, stack, memory) {
|
||||||
if(memory) return memory.restore(form,stack)
|
if(memory) return memory.restore(form,stack)
|
||||||
form.settings.loraStack=filterLoraStackForUse(stack,loraUse(form),xaigen)
|
form.settings.loraStack=filterLoraStackForUse(stack,loraUse(form))
|
||||||
return form
|
return form
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,8 @@ export function reconcileSelection(selected, assets) {
|
|||||||
return list.find(a => a.id === selected.id) || list.at(-1) || null
|
return list.find(a => a.id === selected.id) || list.at(-1) || null
|
||||||
}
|
}
|
||||||
export function activeJobs(jobs) { return jobs.filter(j=>['waking','enhancing','submitting','rendering','saving'].includes(j.state)) }
|
export function activeJobs(jobs) { return jobs.filter(j=>['waking','enhancing','submitting','rendering','saving'].includes(j.state)) }
|
||||||
export function previewHidden(asset, revealed, xaigen) {
|
export function previewHidden(_asset, _revealed) {
|
||||||
if (!xaigen || !asset?.id) return false
|
return false
|
||||||
return !revealed?.has?.(asset.id)
|
|
||||||
}
|
}
|
||||||
/** A reported imageCount of 0 is an empty folder. Do not replace it with a local list length. */
|
/** A reported imageCount of 0 is an empty folder. Do not replace it with a local list length. */
|
||||||
export function folderImageCount(folder, localStillCount = 0) {
|
export function folderImageCount(folder, localStillCount = 0) {
|
||||||
|
|||||||
@@ -48,13 +48,20 @@ test('aigen generate request validates like Studio 2 with recommended krea steps
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('aigen routes exist, stay on the studio-2 enqueue path, and 404 on xAIGen', () => {
|
test('aigen routes exist, stay on the studio-2 enqueue path, and 404 on xAIGen', () => {
|
||||||
const generate = readFileSync(join(root, 'server/api/aigen/generate.post.ts'), 'utf8')
|
const generateRoute = readFileSync(join(root, 'server/api/aigen/generate.post.ts'), 'utf8')
|
||||||
const job = readFileSync(join(root, 'server/api/aigen/jobs/[id].get.ts'), 'utf8')
|
const generate = readFileSync(join(root, 'server/utils/aigenGenerate.ts'), 'utf8')
|
||||||
|
const jobRoute = readFileSync(join(root, 'server/api/aigen/jobs/[id].get.ts'), 'utf8')
|
||||||
|
const job = readFileSync(join(root, 'server/utils/aigenJob.ts'), 'utf8')
|
||||||
const auth = readFileSync(join(root, 'server/utils/aigenApi.ts'), 'utf8')
|
const auth = readFileSync(join(root, 'server/utils/aigenApi.ts'), 'utf8')
|
||||||
|
const authPaths = readFileSync(join(root, 'server/utils/aigenApiAuth.ts'), 'utf8')
|
||||||
const middleware = readFileSync(join(root, 'server/middleware/auth.ts'), 'utf8')
|
const middleware = readFileSync(join(root, 'server/middleware/auth.ts'), 'utf8')
|
||||||
|
const mcp = readFileSync(join(root, 'server/routes/mcp.ts'), 'utf8')
|
||||||
|
const mcpUtil = readFileSync(join(root, 'server/utils/aigenMcp.ts'), 'utf8')
|
||||||
const nuxt = readFileSync(join(root, 'nuxt.config.ts'), 'utf8')
|
const nuxt = readFileSync(join(root, 'nuxt.config.ts'), 'utf8')
|
||||||
const bench = readFileSync(join(root, 'components/studio2/Bench.vue'), 'utf8')
|
const bench = readFileSync(join(root, 'components/studio2/Bench.vue'), 'utf8')
|
||||||
|
|
||||||
|
assert.match(generateRoute, /queueAigenGenerate/)
|
||||||
|
assert.match(jobRoute, /readAigenJob/)
|
||||||
assert.match(generate, /assertAigenApiAccess/)
|
assert.match(generate, /assertAigenApiAccess/)
|
||||||
assert.match(generate, /validateRequest/)
|
assert.match(generate, /validateRequest/)
|
||||||
assert.match(generate, /addStudioJob/)
|
assert.match(generate, /addStudioJob/)
|
||||||
@@ -65,11 +72,41 @@ test('aigen routes exist, stay on the studio-2 enqueue path, and 404 on xAIGen',
|
|||||||
assert.match(auth, /assertAigenFeature/)
|
assert.match(auth, /assertAigenFeature/)
|
||||||
assert.match(job, /stillUrl/)
|
assert.match(job, /stillUrl/)
|
||||||
assert.match(job, /stillId/)
|
assert.match(job, /stillId/)
|
||||||
|
assert.match(job, /stillAbsoluteUrl/)
|
||||||
assert.match(middleware, /aigenBearerAuthorized/)
|
assert.match(middleware, /aigenBearerAuthorized/)
|
||||||
assert.match(middleware, /aigenApiPathAllowed/)
|
assert.match(middleware, /aigenApiPathAllowed/)
|
||||||
|
assert.match(middleware, /\/\.well-known\/oauth-authorization-server/)
|
||||||
|
assert.match(middleware, /\/\.well-known\/openid-configuration/)
|
||||||
|
assert.match(middleware, /\/\.well-known\/oauth-protected-resource/)
|
||||||
|
assert.match(authPaths, /path === '\/mcp'/)
|
||||||
|
assert.match(mcp, /mcpBearerOk/)
|
||||||
|
assert.match(mcp, /text\/event-stream/)
|
||||||
|
assert.match(mcp, /tools\/list/)
|
||||||
|
assert.match(mcp, /tools\/call/)
|
||||||
|
assert.match(mcp, /resolveMcpProtocolVersion/)
|
||||||
|
assert.match(mcp, /tools\/call[\s\S]*mcpBearerOk|mcpBearerOk[\s\S]*tools\/call/)
|
||||||
|
assert.doesNotMatch(mcp, /405.*GET|Method Not Allowed[\s\S]*GET/)
|
||||||
|
assert.match(mcpUtil, /aigen_engines/)
|
||||||
|
assert.match(mcpUtil, /aigen_generate/)
|
||||||
|
assert.match(mcpUtil, /aigen_job/)
|
||||||
|
assert.match(mcpUtil, /queueAigenGenerate/)
|
||||||
|
assert.match(mcpUtil, /readAigenJob/)
|
||||||
|
assert.match(mcpUtil, /removeResponseHeader\(event,\s*'WWW-Authenticate'\)/)
|
||||||
|
assert.doesNotMatch(mcpUtil, /authorization_servers/)
|
||||||
|
assert.match(mcpUtil, /2025-06-18/)
|
||||||
assert.match(nuxt, /aigenApiKey:\s*process\.env\.AIGEN_API_KEY/)
|
assert.match(nuxt, /aigenApiKey:\s*process\.env\.AIGEN_API_KEY/)
|
||||||
assert.match(bench, /studio2EngineDefaults/)
|
assert.match(bench, /studio2EngineDefaults/)
|
||||||
assert.match(generate, /assertAigenApiAccess/)
|
|
||||||
|
const as = readFileSync(join(root, 'server/routes/.well-known/oauth-authorization-server.get.ts'), 'utf8')
|
||||||
|
const oidc = readFileSync(join(root, 'server/routes/.well-known/openid-configuration.get.ts'), 'utf8')
|
||||||
|
const opr = readFileSync(join(root, 'server/routes/.well-known/oauth-protected-resource.get.ts'), 'utf8')
|
||||||
|
const oprMcp = readFileSync(join(root, 'server/routes/.well-known/oauth-protected-resource/mcp.get.ts'), 'utf8')
|
||||||
|
assert.match(as, /not found/)
|
||||||
|
assert.match(oidc, /not found/)
|
||||||
|
assert.match(opr, /not found/)
|
||||||
|
assert.match(oprMcp, /not found/)
|
||||||
|
assert.doesNotMatch(opr, /authorization_servers/)
|
||||||
|
assert.doesNotMatch(oprMcp, /authorization_servers/)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('defaultLibraryFolderId prefers Inbox then the first folder', () => {
|
test('defaultLibraryFolderId prefers Inbox then the first folder', () => {
|
||||||
|
|||||||
@@ -19,14 +19,13 @@ test('engine folders decide engine and site, filename prefixes stay a fallback',
|
|||||||
assert.equal(isXaigenOnlyLora(krea), true)
|
assert.equal(isXaigenOnlyLora(krea), true)
|
||||||
assert.equal(imageLoraEngineOf(krea), 'krea')
|
assert.equal(imageLoraEngineOf(krea), 'krea')
|
||||||
assert.deepEqual(inferLoraUse(krea), ['krea'])
|
assert.deepEqual(inferLoraUse(krea), ['krea'])
|
||||||
assert.deepEqual(filterLorasForStudio([krea], false), [])
|
assert.deepEqual(filterLorasForStudio([krea]), [krea])
|
||||||
assert.deepEqual(filterLorasForStudio([krea], true), [krea])
|
|
||||||
assert.deepEqual(filterLorasForImageEngine([krea, flux], 'krea'), [krea])
|
assert.deepEqual(filterLorasForImageEngine([krea, flux], 'krea'), [krea])
|
||||||
|
|
||||||
assert.equal(isXaigenOnlyLora(flux), false)
|
assert.equal(isXaigenOnlyLora(flux), false)
|
||||||
assert.equal(imageLoraEngineOf(flux), 'flux')
|
assert.equal(imageLoraEngineOf(flux), 'flux')
|
||||||
assert.deepEqual(inferLoraUse(flux), ['flux'])
|
assert.deepEqual(inferLoraUse(flux), ['flux'])
|
||||||
assert.deepEqual(filterLorasForStudio([flux], false), [flux])
|
assert.deepEqual(filterLorasForStudio([flux]), [flux])
|
||||||
|
|
||||||
assert.equal(isXaigenOnlyLora(flat), false)
|
assert.equal(isXaigenOnlyLora(flat), false)
|
||||||
assert.equal(imageLoraEngineOf(flat), 'krea')
|
assert.equal(imageLoraEngineOf(flat), 'krea')
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ test('moss is generate-only with its own steps and CFG',()=>{
|
|||||||
assert.equal(q.turbo,false)
|
assert.equal(q.turbo,false)
|
||||||
assert.equal(q.enhancePrompt,false)
|
assert.equal(q.enhancePrompt,false)
|
||||||
assert.deepEqual(q.settings.loraStack,[{name:'klein-anime.safetensors'}])
|
assert.deepEqual(q.settings.loraStack,[{name:'klein-anime.safetensors'}])
|
||||||
assert.deepEqual(filterLoraStackForUse(q.settings.loraStack,'moss',true),[])
|
assert.deepEqual(filterLoraStackForUse(q.settings.loraStack,'moss'),[])
|
||||||
assert.deepEqual(filterLorasForUse(['moss-style.safetensors','klein-anime.safetensors','krea-look.safetensors'],'moss'),['moss-style.safetensors'])
|
assert.deepEqual(filterLorasForUse(['moss-style.safetensors','klein-anime.safetensors','krea-look.safetensors'],'moss'),['moss-style.safetensors'])
|
||||||
assert.equal(loraMatchesImageEngine('moss-style.safetensors','moss'),true)
|
assert.equal(loraMatchesImageEngine('moss-style.safetensors','moss'),true)
|
||||||
assert.equal(loraMatchesImageEngine('klein-anime.safetensors','moss'),false)
|
assert.equal(loraMatchesImageEngine('klein-anime.safetensors','moss'),false)
|
||||||
|
|||||||
@@ -13,16 +13,16 @@ test('engine token matrix uses paths and names, omits unknown and system picker
|
|||||||
for(const current of ['flux','krea','minimax','ltx']) assert.equal(filterLorasForUse([name+'.safetensors'],current).length,use===current?1:0)
|
for(const current of ['flux','krea','minimax','ltx']) assert.equal(filterLorasForUse([name+'.safetensors'],current).length,use===current?1:0)
|
||||||
}
|
}
|
||||||
const restricted=['xaigen-klein.safetensors','XAIgen-MiniMax.safetensors','xiagen-Krea.safetensors']
|
const restricted=['xaigen-klein.safetensors','XAIgen-MiniMax.safetensors','xiagen-Krea.safetensors']
|
||||||
assert.deepEqual(filterLorasForStudio(restricted,false),[])
|
assert.deepEqual(filterLorasForStudio(restricted),restricted)
|
||||||
assert.deepEqual(filterLoraStackForUse(stack('xaigen-klein'),'flux',false),[])
|
assert.deepEqual(filterLoraStackForUse(stack('xaigen-klein'),'flux'),stack('xaigen-klein'))
|
||||||
assert.deepEqual(filterLoraStackForUse(stack('LTX'),'ltx',false),[])
|
assert.deepEqual(filterLoraStackForUse(stack('LTX'),'ltx'),stack('LTX'))
|
||||||
for(const [name,use] of [['minimax_h3_fl2v_turbo_8step_v1.0_comfyui_bf16','minimax'],['ltx-2.3-22b-distilled','ltx'],['Flux2-Klein-9B-consistency-V2','flux']]) assert.deepEqual(filterLorasForUse([name+'.safetensors'],use),[])
|
for(const [name,use] of [['minimax_h3_fl2v_turbo_8step_v1.0_comfyui_bf16','minimax'],['ltx-2.3-22b-distilled','ltx'],['Flux2-Klein-9B-consistency-V2','flux']]) assert.deepEqual(filterLorasForUse([name+'.safetensors'],use),[])
|
||||||
assert.deepEqual(filterLoraStackForUse(stack('unlabelled'),'flux',true),stack('unlabelled'))
|
assert.deepEqual(filterLoraStackForUse(stack('unlabelled'),'flux'),stack('unlabelled'))
|
||||||
})
|
})
|
||||||
|
|
||||||
function bench() {
|
function bench() {
|
||||||
const data=new Map(),storage={getItem:k=>data.get(k),setItem:(k,v)=>data.set(k,v)}
|
const data=new Map(),storage={getItem:k=>data.get(k),setItem:(k,v)=>data.set(k,v)}
|
||||||
const memory=createLoraMemory(true,storage)
|
const memory=createLoraMemory(storage)
|
||||||
const form=reactive({mode:'generate',engine:'flux',settings:{loraStack:[]}})
|
const form=reactive({mode:'generate',engine:'flux',settings:{loraStack:[]}})
|
||||||
const stop=watch(()=>[loraUse(form),form.settings.loraStack],()=>memory.sync(form),{deep:true,flush:'sync'})
|
const stop=watch(()=>[loraUse(form),form.settings.loraStack],()=>memory.sync(form),{deep:true,flush:'sync'})
|
||||||
memory.sync(form)
|
memory.sync(form)
|
||||||
@@ -35,8 +35,6 @@ test('reactive task switches remember four independent stacks and both strengths
|
|||||||
form.mode='video';form.engine='minimax'
|
form.mode='video';form.engine='minimax'
|
||||||
assert.deepEqual(form.settings.loraStack,[])
|
assert.deepEqual(form.settings.loraStack,[])
|
||||||
form.settings.loraStack=stack('MiniMax_style')
|
form.settings.loraStack=stack('MiniMax_style')
|
||||||
form.engine='ltx';assert.deepEqual(form.settings.loraStack,[])
|
|
||||||
form.settings.loraStack=stack('LTX_style')
|
|
||||||
form.mode='edit';form.engine='flux'
|
form.mode='edit';form.engine='flux'
|
||||||
assert.equal(form.settings.loraStack[0].name,'klein_car_bee.safetensors')
|
assert.equal(form.settings.loraStack[0].name,'klein_car_bee.safetensors')
|
||||||
assert.equal(form.settings.loraStack[0].strengthClip,.8)
|
assert.equal(form.settings.loraStack[0].strengthClip,.8)
|
||||||
@@ -46,7 +44,7 @@ test('reactive task switches remember four independent stacks and both strengths
|
|||||||
assert.deepEqual(form.settings.loraStack,stack('MiniMax_style'))
|
assert.deepEqual(form.settings.loraStack,stack('MiniMax_style'))
|
||||||
Object.assign(form,useAsHero(form,{id:'image'}),useAsSource(form,{id:'source'}))
|
Object.assign(form,useAsHero(form,{id:'image'}),useAsSource(form,{id:'source'}))
|
||||||
assert.deepEqual(form.settings.loraStack,stack('MiniMax_style'))
|
assert.deepEqual(form.settings.loraStack,stack('MiniMax_style'))
|
||||||
const fresh=createLoraMemory(true,storage),other={mode:'generate',engine:'krea',settings:{loraStack:[]}}
|
const fresh=createLoraMemory(storage),other={mode:'generate',engine:'krea',settings:{loraStack:[]}}
|
||||||
fresh.sync(other);assert.deepEqual(other.settings.loraStack,stack('Krea_style'))
|
fresh.sync(other);assert.deepEqual(other.settings.loraStack,stack('Krea_style'))
|
||||||
stop()
|
stop()
|
||||||
})
|
})
|
||||||
@@ -54,16 +52,16 @@ test('Use as input and Extend copy saved stacks, filter wrong engines, and fall
|
|||||||
const {form,memory,stop}=bench()
|
const {form,memory,stop}=bench()
|
||||||
form.settings.loraStack=stack('klein_remembered')
|
form.settings.loraStack=stack('klein_remembered')
|
||||||
const still={id:'still',kind:'still',studio2:{engine:'flux',mode:'edit',settings:{loraStack:[...stack('klein_saved'),...stack('MiniMax_wrong')]}}}
|
const still={id:'still',kind:'still',studio2:{engine:'flux',mode:'edit',settings:{loraStack:[...stack('klein_saved'),...stack('MiniMax_wrong')]}}}
|
||||||
Object.assign(form,restoreAll(form,still,true,memory))
|
Object.assign(form,restoreAll(form,still,memory))
|
||||||
assert.deepEqual(form.settings.loraStack,stack('klein_saved'))
|
assert.deepEqual(form.settings.loraStack,stack('klein_saved'))
|
||||||
const clip={id:'clip',kind:'clip',studio2:{engine:'minimax',settings:{loraStack:[...stack('MiniMax_saved'),...stack('klein_wrong')]}}}
|
const clip={id:'clip',kind:'clip',studio2:{engine:'minimax',settings:{loraStack:[...stack('MiniMax_saved'),...stack('klein_wrong')]}}}
|
||||||
Object.assign(form,extendSelected(form,clip,true,memory))
|
Object.assign(form,extendSelected(form,clip,memory))
|
||||||
assert.deepEqual(form.settings.loraStack,stack('MiniMax_saved'))
|
assert.deepEqual(form.settings.loraStack,stack('MiniMax_saved'))
|
||||||
Object.assign(form,restoreAll(form,{...still,studio2:{...still.studio2,settings:{loraStack:[]}}},true,memory))
|
Object.assign(form,restoreAll(form,{...still,studio2:{...still.studio2,settings:{loraStack:[]}}},memory))
|
||||||
assert.deepEqual(form.settings.loraStack,stack('klein_saved'))
|
assert.deepEqual(form.settings.loraStack,stack('klein_saved'))
|
||||||
Object.assign(form,bindClip(form,{id:'empty',settings:{loraStack:[]}},true,memory))
|
Object.assign(form,bindClip(form,{id:'empty',settings:{loraStack:[]}},memory))
|
||||||
assert.deepEqual(form.settings.loraStack,stack('MiniMax_saved'))
|
assert.deepEqual(form.settings.loraStack,stack('MiniMax_saved'))
|
||||||
const legacy=restoreAsset(form,{id:'old-still',kind:'still',engine:'krea',settings:{loraStack:stack('Krea_saved')}},true,memory)
|
const legacy=restoreAsset(form,{id:'old-still',kind:'still',engine:'krea',settings:{loraStack:stack('Krea_saved')}},memory)
|
||||||
assert.equal(legacy.engine,'krea');assert.deepEqual(legacy.settings.loraStack,stack('Krea_saved'))
|
assert.equal(legacy.engine,'krea');assert.deepEqual(legacy.settings.loraStack,stack('Krea_saved'))
|
||||||
stop()
|
stop()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,24 +1,17 @@
|
|||||||
import { isXaigenStudio } from '~/utils/videoModels'
|
|
||||||
|
|
||||||
const PREF_KEY = 'aigen-notify-complete'
|
const PREF_KEY = 'aigen-notify-complete'
|
||||||
const TAG = 'aigen-generation-complete'
|
const TAG = 'aigen-generation-complete'
|
||||||
|
|
||||||
function appName() {
|
function appName() {
|
||||||
try {
|
try {
|
||||||
const pub = useRuntimeConfig().public as { instanceName?: string; studio?: string }
|
const pub = useRuntimeConfig().public as { instanceName?: string }
|
||||||
return String(pub.instanceName || (isXaigenStudio(pub) ? 'xAIGen' : 'AIGen'))
|
return String(pub.instanceName || 'AIGen')
|
||||||
} catch {
|
} catch {
|
||||||
return 'AIGen'
|
return 'AIGen'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function appIcon() {
|
function appIcon() {
|
||||||
try {
|
return '/favicon-aigen.svg'
|
||||||
const pub = useRuntimeConfig().public as { instanceName?: string; studio?: string }
|
|
||||||
return isXaigenStudio(pub) ? '/favicon.svg' : '/favicon-aigen.svg'
|
|
||||||
} catch {
|
|
||||||
return '/favicon-aigen.svg'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function generationNotifySupported() {
|
export function generationNotifySupported() {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
type ImageV2Mode,
|
type ImageV2Mode,
|
||||||
type ImageV2Task
|
type ImageV2Task
|
||||||
} from '~/utils/imageV2'
|
} from '~/utils/imageV2'
|
||||||
import { isXaigenStudio, type VideoWorkflowId } from '~/utils/videoModels'
|
import type { VideoWorkflowId } from '~/utils/videoModels'
|
||||||
import { restorePromptParts } from '~/utils/promptParts'
|
import { restorePromptParts } from '~/utils/promptParts'
|
||||||
|
|
||||||
export type StillGenerationKind = 'image' | 'imagev2'
|
export type StillGenerationKind = 'image' | 'imagev2'
|
||||||
@@ -102,7 +102,7 @@ function formatLoras(stack?: LoraStackItem[], name?: string) {
|
|||||||
function stillDisplayLoraStack(settings: StillGenerationSettings) {
|
function stillDisplayLoraStack(settings: StillGenerationSettings) {
|
||||||
let stack = normalizeLoraStack(settings.loraStack || settings.loraName)
|
let stack = normalizeLoraStack(settings.loraStack || settings.loraName)
|
||||||
const { snofs } = imageV2StackSpecials(stack, settings.engine)
|
const { snofs } = imageV2StackSpecials(stack, settings.engine)
|
||||||
if (!snofs && isXaigenStudio() && (settings.snofsModel || settings.snofsClip)) {
|
if (!snofs && (settings.snofsModel || settings.snofsClip)) {
|
||||||
const name = imageV2ConceptLoraName(settings.engine || 'flux')
|
const name = imageV2ConceptLoraName(settings.engine || 'flux')
|
||||||
if (name) stack = upsertImageV2Lora(stack, name, settings.snofsModel ?? 0, settings.snofsClip ?? 0)
|
if (name) stack = upsertImageV2Lora(stack, name, settings.snofsModel ?? 0, settings.snofsClip ?? 0)
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-8
@@ -232,22 +232,21 @@ export function loraStacksEqual(a?: unknown, b?: unknown) {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
/** User LoRA picker only. `xaigen-*` names are visible only on xAIGen. */
|
/** User LoRA picker: dedupe Comfy-relative paths; all site trees stay visible on AIGen. */
|
||||||
export function filterLorasForStudio(names: string[], xaigenStudio: boolean) {
|
export function filterLorasForStudio(names: string[]) {
|
||||||
const seen = new Set<string>()
|
const seen = new Set<string>()
|
||||||
const out: string[] = []
|
const out: string[] = []
|
||||||
for (const raw of names) {
|
for (const raw of names) {
|
||||||
const name = String(raw || '').trim()
|
const name = String(raw || '').trim()
|
||||||
if (!name || seen.has(name)) continue
|
if (!name || seen.has(name)) continue
|
||||||
if (!xaigenStudio && isXaigenOnlyLora(name)) continue
|
|
||||||
seen.add(name)
|
seen.add(name)
|
||||||
out.push(name)
|
out.push(name)
|
||||||
}
|
}
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
export function filterLoraStackForStudio(stack: unknown, xaigenStudio: boolean) {
|
export function filterLoraStackForStudio(stack: unknown) {
|
||||||
return normalizeLoraStack(stack).filter(item => xaigenStudio || !isXaigenOnlyLora(item.name))
|
return normalizeLoraStack(stack)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Klein / Flux.2 Klein adapters. Must not load on a Krea graph. */
|
/** Klein / Flux.2 Klein adapters. Must not load on a Krea graph. */
|
||||||
@@ -363,9 +362,8 @@ export function loraMatchesUse(name: string, use: LoraUse) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Saved stacks may contain unlabelled adapters; never carry a known wrong engine. */
|
/** Saved stacks may contain unlabelled adapters; never carry a known wrong engine. */
|
||||||
export function filterLoraStackForUse(stack: unknown, use: LoraUse, xaigen: boolean) {
|
export function filterLoraStackForUse(stack: unknown, use: LoraUse) {
|
||||||
if (use === 'ltx' && !xaigen) return []
|
return filterLoraStackForStudio(stack).filter(item => {
|
||||||
return filterLoraStackForStudio(stack, xaigen).filter(item => {
|
|
||||||
if (isSystemGraphLora(item.name)) return false
|
if (isSystemGraphLora(item.name)) return false
|
||||||
const folder = loraEngineFolder(item.name)
|
const folder = loraEngineFolder(item.name)
|
||||||
if (folder) return folder === use
|
if (folder) return folder === use
|
||||||
|
|||||||
+16
-35
@@ -1,6 +1,11 @@
|
|||||||
export type VideoEngineId = 'minimax' | 'ltx'
|
export const LTX_NEGATIVE =
|
||||||
|
'blurry, low quality, jitter, deformed, static frame, freeze, watermark, bad anatomy, text, subtitles'
|
||||||
|
export const LTX_DISTILLED_LORA = 'ltx-2.3-22b-distilled.safetensors'
|
||||||
|
|
||||||
|
export type VideoEngineId = 'minimax'
|
||||||
export type VideoStartId = 'still' | 'text'
|
export type VideoStartId = 'still' | 'text'
|
||||||
export type MiniMaxGraphId = 'v1' | 'v2'
|
export type MiniMaxGraphId = 'v1' | 'v2'
|
||||||
|
/** Legacy `ltx` / `ltx-t2v` ids may still appear on old library rows; they coerce to MiniMax. */
|
||||||
export type VideoWorkflowId = 'v1' | 'v2' | 't2v' | 'ltx' | 'ltx-t2v'
|
export type VideoWorkflowId = 'v1' | 'v2' | 't2v' | 'ltx' | 'ltx-t2v'
|
||||||
|
|
||||||
export function parseVideoWorkflow(raw: unknown): VideoWorkflowId {
|
export function parseVideoWorkflow(raw: unknown): VideoWorkflowId {
|
||||||
@@ -12,27 +17,8 @@ export function parseVideoWorkflow(raw: unknown): VideoWorkflowId {
|
|||||||
return 'v1'
|
return 'v1'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const LTX_DISABLED_MESSAGE = 'LTX Pink Cherry is not available on this instance'
|
|
||||||
|
|
||||||
export function isXaigenStudio(publicConfig?: { studio?: unknown; instanceName?: unknown }) {
|
|
||||||
let pub = publicConfig
|
|
||||||
if (!pub) {
|
|
||||||
try {
|
|
||||||
pub = useRuntimeConfig().public as { studio?: unknown; instanceName?: unknown }
|
|
||||||
} catch {
|
|
||||||
pub = {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return /^xaigen$/i.test(String(pub.studio || '').trim())
|
|
||||||
|| /xaigen/i.test(String(pub.instanceName || '').trim())
|
|
||||||
}
|
|
||||||
|
|
||||||
export function ltxWorkflowEnabled(publicConfig?: { studio?: unknown; instanceName?: unknown }) {
|
|
||||||
return isXaigenStudio(publicConfig)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function videoEngineOf(id: VideoWorkflowId): VideoEngineId {
|
export function videoEngineOf(id: VideoWorkflowId): VideoEngineId {
|
||||||
return id.startsWith('ltx') ? 'ltx' : 'minimax'
|
return 'minimax'
|
||||||
}
|
}
|
||||||
|
|
||||||
export function videoStartOf(id: VideoWorkflowId): VideoStartId {
|
export function videoStartOf(id: VideoWorkflowId): VideoStartId {
|
||||||
@@ -40,7 +26,7 @@ export function videoStartOf(id: VideoWorkflowId): VideoStartId {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function isLtxWorkflow(id: VideoWorkflowId) {
|
export function isLtxWorkflow(id: VideoWorkflowId) {
|
||||||
return videoEngineOf(id) === 'ltx'
|
return String(id || '').startsWith('ltx')
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isTextToVideo(id: VideoWorkflowId) {
|
export function isTextToVideo(id: VideoWorkflowId) {
|
||||||
@@ -52,30 +38,25 @@ export function minimaxGraphOf(id: VideoWorkflowId): MiniMaxGraphId {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function workflowForExtension(id: VideoWorkflowId): VideoWorkflowId {
|
export function workflowForExtension(id: VideoWorkflowId): VideoWorkflowId {
|
||||||
if (id === 't2v') return 'v1'
|
if (id === 't2v' || id === 'ltx-t2v') return 'v1'
|
||||||
if (id === 'ltx-t2v') return 'ltx'
|
if (isLtxWorkflow(id)) return 'v1'
|
||||||
return id
|
return id
|
||||||
}
|
}
|
||||||
|
|
||||||
export function composeVideoWorkflow(engine: VideoEngineId, start: VideoStartId, graph: MiniMaxGraphId = 'v1'): VideoWorkflowId {
|
export function composeVideoWorkflow(_engine: VideoEngineId, start: VideoStartId, graph: MiniMaxGraphId = 'v1'): VideoWorkflowId {
|
||||||
if (engine === 'ltx') return start === 'text' ? 'ltx-t2v' : 'ltx'
|
|
||||||
if (start === 'text') return 't2v'
|
if (start === 'text') return 't2v'
|
||||||
return graph === 'v2' ? 'v2' : 'v1'
|
return graph === 'v2' ? 'v2' : 'v1'
|
||||||
}
|
}
|
||||||
|
|
||||||
export function coerceVideoWorkflow(raw: unknown, allowLtx?: boolean): VideoWorkflowId {
|
/** Remap retired LTX workflows onto MiniMax. */
|
||||||
|
export function coerceVideoWorkflow(raw: unknown): VideoWorkflowId {
|
||||||
const id = parseVideoWorkflow(raw)
|
const id = parseVideoWorkflow(raw)
|
||||||
if ((allowLtx ?? ltxWorkflowEnabled()) || !isLtxWorkflow(id)) return id
|
if (!isLtxWorkflow(id)) return id
|
||||||
return composeVideoWorkflow('minimax', videoStartOf(id), 'v1')
|
return composeVideoWorkflow('minimax', videoStartOf(id), 'v1')
|
||||||
}
|
}
|
||||||
|
|
||||||
export function defaultVideoSteps(turbo: boolean, workflow: string = 'v1') {
|
export function defaultVideoSteps(turbo: boolean, workflow: string = 'v1') {
|
||||||
const id = parseVideoWorkflow(workflow)
|
const id = coerceVideoWorkflow(workflow)
|
||||||
if (!turbo) return isLtxWorkflow(id) ? 12 : 20
|
if (!turbo) return 20
|
||||||
if (isLtxWorkflow(id)) return 8
|
|
||||||
return id === 'v2' ? 6 : 8
|
return id === 'v2' ? 6 : 8
|
||||||
}
|
}
|
||||||
|
|
||||||
export const LTX_UNET = 'PinkCherry_FineTune_int8_v1_8_LTX23.safetensors'
|
|
||||||
export const LTX_DISTILLED_LORA = 'ltx-2.3-22b-distilled-lora-384-1.1.safetensors'
|
|
||||||
export const LTX_NEGATIVE = 'blurry, low quality, jitter, deformed, static frame, freeze, watermark, bad anatomy, text, subtitles'
|
|
||||||
|
|||||||
Reference in New Issue
Block a user