Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Shared contract for round 3: new operations, text and 3D outputs, LLM provider id, prompt/voice chain slots

Claude38337a5b882d
diff --git a/src/app/api/generations/route.ts b/src/app/api/generations/route.ts
index a2056520..46128bcf 100644
--- a/src/app/api/generations/route.ts
+++ b/src/app/api/generations/route.ts
@@ -38,6 +38,13 @@ const RequestSchema = z.object({
voice: z.string().max(200).optional(),
dialogue: z.array(z.object({ text: z.string().max(5000), voice: z.string().max(200).optional() })).max(200).optional(),
targetLanguage: z.string().max(80).optional(),
+ startTime: z.number().min(0).max(36_000).optional(),
+ endTime: z.number().min(0).max(36_000).optional(),
+ fps: z.number().positive().max(240).optional(),
+ palette: z.array(z.string().regex(/^#?[0-9a-fA-F]{6}$/)).max(16).optional(),
+ styleId: z.string().max(200).optional(),
+ sourceLanguage: z.string().max(80).optional(),
+ numLayers: z.number().int().min(1).max(20).optional(),
extra: z.record(z.string(), z.unknown()).optional(),
})
.optional(),
diff --git a/src/components/assist-view.tsx b/src/components/assist-view.tsx
index 58dedb90..37b66ce6 100644
--- a/src/components/assist-view.tsx
+++ b/src/components/assist-view.tsx
@@ -1,6 +1,6 @@
"use client";
-import { ArrowUp, AudioLines, Bot, Check, CircleAlert, Clapperboard, Cpu, History, ImageIcon, Loader2, Paperclip, Plus, Search, Sparkles, Trash2, Video, X } from "lucide-react";
+import { ArrowUp, AudioLines, Bot, Box, Check, CircleAlert, Clapperboard, Cpu, FileText, History, ImageIcon, Loader2, Paperclip, Plus, Search, Sparkles, Trash2, Video, X } from "lucide-react";
import Link from "next/link";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { useEffect, useMemo, useRef, useState } from "react";
@@ -27,7 +27,7 @@ const SUGGESTIONS = [
"A 10-second vertical video of a fox running through snow, with sound",
];
-const KIND_ICON: Record<MediaKind | "storyboard", typeof ImageIcon> = { image: ImageIcon, video: Video, audio: AudioLines, storyboard: Clapperboard };
+const KIND_ICON: Record<MediaKind | "storyboard", typeof ImageIcon> = { image: ImageIcon, video: Video, audio: AudioLines, text: FileText, model3d: Box, storyboard: Clapperboard };
const AGENT_LABEL: Record<AssistThread["agent"], string> = { claude: "Claude", ollama: "Local LLM", offline: "Offline planner" };
const AGENT_HINT: Record<AssistThread["agent"], string> = {
diff --git a/src/components/studio/media-slot.tsx b/src/components/studio/media-slot.tsx
index 3c66e339..706a8549 100644
--- a/src/components/studio/media-slot.tsx
+++ b/src/components/studio/media-slot.tsx
@@ -24,6 +24,8 @@ const ACCEPT: Record<MediaKind, string> = {
image: "image/png,image/jpeg,image/webp,image/gif",
video: "video/mp4,video/webm,video/quicktime",
audio: "audio/mpeg,audio/wav,audio/x-wav,audio/ogg,audio/flac,audio/mp4,audio/webm",
+ text: "text/plain,.txt,.srt,.vtt",
+ model3d: ".glb,.gltf,model/gltf-binary",
};
const MAX_MB = 200;
diff --git a/src/lib/catalog/types.ts b/src/lib/catalog/types.ts
index 13603477..e4db470b 100644
--- a/src/lib/catalog/types.ts
+++ b/src/lib/catalog/types.ts
@@ -10,7 +10,8 @@
export type Engine = "cloud" | "open";
-export type MediaKind = "image" | "video" | "audio";
+/** "text" = transcripts, translations, scripts (OutputFile.text); "model3d" = a .glb mesh. */
+export type MediaKind = "image" | "video" | "audio" | "text" | "model3d";
export type Operation =
| "t2i" // text → image
@@ -46,7 +47,17 @@ export type Operation =
| "relight-video" // video → the same shot under new lighting
| "concat" // several clips → one video, in order
| "frame" // video → one of its frames (the last, for extending)
- | "color-match"; // image or video + reference image → recoloured to the reference's palette
+ | "color-match" // image or video + reference image → recoloured to the reference's palette
+ | "layers" // image → its layers as RGBA images (OutputFile.meta: name, z, bbox)
+ | "text-layers" // image → the background with the text removed + the text blocks (OutputFile.meta.textBlocks)
+ | "trim" // video → the part between params.startTime and params.endTime
+ | "transcribe" // audio or video → timed text (OutputFile.text, OutputFile.meta.cues)
+ | "captions" // video → the same video with burned-in captions
+ | "mux" // video + audio → the video with that soundtrack
+ | "image-to-3d" // image → a 3D model (.glb), optionally a turntable video
+ | "separate-audio" // audio or video → voice and background stems
+ | "translate" // text → the same text in params.targetLanguage (LLM)
+ | "write"; // brief → text (LLM: scripts, ad copy, shot lists)
export const OPERATION_LABELS: Record<Operation, string> = {
t2i: "Text to image",
@@ -83,6 +94,16 @@ export const OPERATION_LABELS: Record<Operation, string> = {
concat: "Join clips",
frame: "Extract frame",
"color-match": "Match colors",
+ layers: "Layers",
+ "text-layers": "Text layers",
+ trim: "Trim video",
+ transcribe: "Transcribe",
+ captions: "Captions",
+ mux: "Add soundtrack",
+ "image-to-3d": "Image to 3D",
+ "separate-audio": "Separate voice",
+ translate: "Translate",
+ write: "Write",
};
export const OPERATION_OUTPUT: Record<Operation, MediaKind> = {
@@ -120,9 +141,20 @@ export const OPERATION_OUTPUT: Record<Operation, MediaKind> = {
concat: "video",
frame: "image",
"color-match": "image",
+ layers: "image",
+ "text-layers": "image",
+ trim: "video",
+ transcribe: "text",
+ captions: "video",
+ mux: "video",
+ "image-to-3d": "model3d",
+ "separate-audio": "audio",
+ translate: "text",
+ write: "text",
};
-export type ProviderId = "fal" | "replicate" | "higgsfield" | "openai" | "google" | "comfyui" | "mock" | "local";
+/** "llm" runs text steps (translate, write) on the configured LLM (Claude or Ollama) inside the server. */
+export type ProviderId = "fal" | "replicate" | "higgsfield" | "openai" | "google" | "comfyui" | "mock" | "local" | "llm";
/** Duration encodings differ between APIs ("5" vs 5 vs "5s"). */
export interface DurationField {
@@ -183,6 +215,18 @@ export interface FieldMap {
draft?: string;
/** Field that takes the draft id to finish. */
draftId?: string;
+ /** Trim: where the kept part starts and ends (seconds × multiplier). */
+ startTime?: DurationField;
+ endTime?: DurationField;
+ /** Frames per second (frame sampling, images to video). */
+ fps?: string;
+ /** Colour palette: hex strings converted to the API's shape. */
+ palette?: { key: string; format: "hex" | "rgb-object" | "rgb-array" | "ideogram" };
+ /** A saved style id (Recraft styles, Soul 2.0 moodboards). */
+ styleId?: string;
+ /** How many layers to split an image into. */
+ numLayers?: string;
+ sourceLanguage?: string;
/** Static fields always sent (e.g. safety checker switches). */
fixed?: Record<string, unknown>;
}
@@ -281,6 +325,19 @@ export interface GenParams {
draft?: boolean;
/** Finish this draft at full quality (op "finalize"). */
draftId?: string;
+ /** Trim: the part of the input video to keep, in seconds. */
+ startTime?: number;
+ endTime?: number;
+ /** Output / sampling frame rate. */
+ fps?: number;
+ /** Colour palette as hex strings ("#1a2b3c"), Soul HEX / Cinema Studio palettes. */
+ palette?: string[];
+ /** A saved style id (Recraft style, Soul 2.0 moodboard). */
+ styleId?: string;
+ /** Language of the source speech (transcribe, dub); omit to detect. */
+ sourceLanguage?: string;
+ /** Layer decomposition: how many layers to ask for. */
+ numLayers?: number;
/** Free-form advanced params forwarded to the provider payload. */
extra?: Record<string, unknown>;
}
@@ -338,7 +395,12 @@ export interface GenerationRequest {
}
export interface ChainSlot {
- slot: "images" | "endImage" | "video" | "videos" | "audio";
+ /**
+ * "prompt" takes the dependency's text output (OutputFile.text): it replaces "{text}" in the
+ * request's prompt, or becomes the prompt when there is no placeholder.
+ * "voiceAudio" clones the voice of the dependency's audio output.
+ */
+ slot: "images" | "endImage" | "video" | "videos" | "audio" | "voiceAudio" | "prompt";
/** For list slots: put it before or after the request's own items (default last). */
position?: "first" | "last";
}
@@ -362,6 +424,13 @@ export type GenerationStatus = "queued" | "running" | "succeeded" | "failed" | "
export interface OutputFile {
url: string;
+ /** Text outputs (transcribe, translate, write): the content, also saved as a file at `url`. */
+ text?: string;
+ /**
+ * Structured extras a provider returned with this file: a layer's {name, z, bbox: [x, y, w, h]},
+ * transcript cues [{start, end, text}], text blocks, a 3D model's preview…
+ */
+ meta?: Record<string, unknown>;
/** Draft renders: the id to finish this take at full quality. */
draftId?: string;
kind: MediaKind;
diff --git a/src/server/generations.ts b/src/server/generations.ts
index fcea919c..02a50be6 100644
--- a/src/server/generations.ts
+++ b/src/server/generations.ts
@@ -279,15 +279,34 @@ function slotsFor(req: GenerationRequest, n: number): ChainSlot[] {
return Array.from({ length: n }, () => ({ slot: "images" as const, position: req.chainFrom ?? "last" }));
}
-const SLOT_KIND: Record<ChainSlot["slot"], MediaKind> = { images: "image", endImage: "image", video: "video", videos: "video", audio: "audio" };
+const SLOT_KIND: Record<ChainSlot["slot"], MediaKind> = {
+ images: "image",
+ endImage: "image",
+ video: "video",
+ videos: "video",
+ audio: "audio",
+ voiceAudio: "audio",
+ prompt: "text",
+};
function placeholderFor(s: ChainSlot): string {
- return SLOT_KIND[s.slot] === "image" ? "/api/files/placeholder.png" : SLOT_KIND[s.slot] === "video" ? "/api/files/placeholder.mp4" : "/api/files/placeholder.wav";
+ const kind = SLOT_KIND[s.slot];
+ if (kind === "text") return "Placeholder text from an earlier step";
+ return kind === "image" ? "/api/files/placeholder.png" : kind === "video" ? "/api/files/placeholder.mp4" : "/api/files/placeholder.wav";
}
-/** Put the dependencies' outputs into the request's inputs, slot by slot (lists keep dependency order). */
+/** What a chained step takes from a dependency's output: the file URL, or the text for "prompt". */
+function chainValue(o: OutputFile | undefined, s: ChainSlot): string | undefined {
+ return s.slot === "prompt" ? o?.text : o?.url;
+}
+
+/**
+ * Put the dependencies' outputs into the request's inputs, slot by slot (lists keep dependency order).
+ * A "prompt" slot gets the dependency's text: it fills "{text}" in the prompt, or becomes the prompt.
+ */
export function withChainInputs(req: GenerationRequest, urls: string[]): GenerationRequest {
const inputs = { ...req.inputs };
+ let prompt = req.prompt;
const slots = slotsFor(req, urls.length);
for (const k of ["images", "videos"] as const) {
const at = (pos: "first" | "last") => slots.flatMap((s, i) => (s.slot === k && (s.position ?? "last") === pos ? [urls[i]] : []));
@@ -296,9 +315,10 @@ export function withChainInputs(req: GenerationRequest, urls: string[]): Generat
if (first.length || last.length) inputs[k] = [...first, ...(inputs[k] ?? []), ...last];
}
slots.forEach((s, i) => {
- if (s.slot !== "images" && s.slot !== "videos") inputs[s.slot] = urls[i];
+ if (s.slot === "prompt") prompt = prompt?.includes("{text}") ? prompt.replaceAll("{text}", urls[i]) : urls[i];
+ else if (s.slot !== "images" && s.slot !== "videos") inputs[s.slot] = urls[i];
});
- return { ...req, inputs };
+ return { ...req, prompt, inputs };
}
/** Launch dependent jobs whose inputs finished; fail the ones whose inputs failed. */
@@ -319,7 +339,7 @@ async function advanceDependents(): Promise<void> {
continue;
}
if (deps.some((d) => d!.status !== "succeeded")) continue;
- const urls = deps.map((d, i) => (JSON.parse(d!.outputs_json) as OutputFile[]).find((o) => o.kind === SLOT_KIND[slots[i].slot])?.url);
+ const urls = deps.map((d, i) => chainValue((JSON.parse(d!.outputs_json) as OutputFile[]).find((o) => o.kind === SLOT_KIND[slots[i].slot]), slots[i]));
if (urls.some((u) => !u)) {
update(r.id, { status: "failed", error: `${earlier} has no ${SLOT_KIND[slots[urls.findIndex((u) => !u)].slot]} to use`, message: null, completed_at: Date.now() });
continue;
diff --git a/src/server/providers/index.ts b/src/server/providers/index.ts
index 56499da3..bd5c107b 100644
--- a/src/server/providers/index.ts
+++ b/src/server/providers/index.ts
@@ -43,6 +43,7 @@ export const PROVIDERS: Record<ProviderId, ProviderAdapter> = {
local: localProvider,
openai: notImplemented("openai", "OpenAI"),
google: notImplemented("google", "Google"),
+ llm: notImplemented("llm", "LLM"),
};
export function provider(id: ProviderId): ProviderAdapter {