Split prompts into pre/prompt/post and tidy the AIGen video form.

Keep wrappers off the library mid-prompt so Use as input and Extend restore the same split, send stills to xAIGen as hidden inputs, and stop the two-column library from growing with the list.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-09-01 18:39:02 -05:00
co-authored by Cursor
parent ed04dcfee3
commit f788fd4bb4
22 changed files with 753 additions and 199 deletions
@@ -0,0 +1,38 @@
import { readFileSync } from 'node:fs'
import { isXaigenStudio } from '~/utils/videoModels'
import { assertLibraryOwner, getStill, stillPath } from '~/server/utils/library'
export default defineEventHandler(async (event) => {
if (isXaigenStudio()) {
throw createError({ statusCode: 404, statusMessage: 'Not found' })
}
const config = useRuntimeConfig()
const url = String(config.backupStudioUrl || process.env.BACKUP_STUDIO_URL || '').replace(/\/$/, '')
const token = String(config.backupStudioToken || process.env.BACKUP_STUDIO_TOKEN || '').trim()
if (!url || !token) {
throw createError({ statusCode: 503, statusMessage: 'Backup studio is not configured' })
}
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 || 'Backup studio refused the still'
})
}
return { ok: true }
})