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.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Paid models: the newest cloud models run on an account's own key
Adarshdd133b1e07fb
diff --git a/src/components/studio/hub-chrome.tsx b/src/components/studio/hub-chrome.tsxindex 22e4cd2d..4fe73cb7 100644--- a/src/components/studio/hub-chrome.tsx+++ b/src/components/studio/hub-chrome.tsx@@ -5,6 +5,7 @@ import { usePathname, useRouter } from "next/navigation";import { createContext, Suspense, useCallback, useContext, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";import { createPortal } from "react-dom";import { PhoneNavButton } from "@/components/nav/phone-nav-button";+import { OwnSetupMark } from "@/components/own-setup";import { EngineSwitch } from "@/components/studio/engine-switch";import { useEngine, useLikelyVisitor } from "@/lib/api";import { HUB_MODES, HUB_TITLE, hubOfPath, modeHref, modeOfPath, type HubKind } from "@/lib/hubs";@@ -157,6 +158,7 @@ function HubTabs({{...onAttr(on)}>{m.label}+ {m.ownSetup && <OwnSetupMark setup={m.ownSetup} />}<TabWaiting onWaiting={onWaiting} /></Link>);diff --git a/src/lib/catalog/hosted-untested.ts b/src/lib/catalog/hosted-untested.tsindex 401db36b..def035fd 100644--- a/src/lib/catalog/hosted-untested.ts+++ b/src/lib/catalog/hosted-untested.ts@@ -1,12 +1,15 @@/*** Hosted routes whose requests have not yet been sent with a real key: their payloads follow the providers' schemas- * and are unit-tested, but no live call has passed. They run for the owner; for an account (on its own fal.ai or- * Replicate key) they open once a live call passes and the entry is taken off these lists. Until then a visitor's run- * is refused (`own-gpu-tool`, generations.ts) and the models are left out of its pickers (hostedUntestedSummary).+ * and are unit-tested, but no live call has passed. An entry is taken off these lists once a live call passes.+ *+ * Until then they run on a visitor's own key like any paid model: an account sees them in its pickers and runs them on+ * its key, and own-setup.ts (ownSetupOnly) labels them "Use your own fal.ai key" (or Replicate's). A visitor's cloud+ * run only ever sends its own key (provider-keys.ts cloudKey), so this studio's keys never run one. The owner runs+ * them as before.* Pure data and logic (client and server).*/import type { AccessSummary } from "../model-access";-import type { Engine, ModelDef, ModelRoute } from "./types";+import type { ModelDef, ModelRoute } from "./types";/** Endpoints, on any model that uses them. */export const HOSTED_UNTESTED_ENDPOINTS: ReadonlySet<string> = new Set([@@ -66,34 +69,21 @@ export const HOSTED_UNTESTED_MODELS: ReadonlySet<string> = new Set(["fuobe-animaconst hosted = (r: Pick<ModelRoute, "provider">) => r.provider === "fal" || r.provider === "replicate";/** Whether this route of this model is a hosted call that hasn't been sent with a real key yet. */-export function hostedUntested(modelId: string, route: Pick<ModelRoute, "provider" | "endpoint">): boolean {+export function isHostedUntested(modelId: string, route: Pick<ModelRoute, "provider" | "endpoint">): boolean {return hosted(route) && (HOSTED_UNTESTED_ENDPOINTS.has(route.endpoint) || HOSTED_UNTESTED_MODELS.has(modelId));}/**- * A visitor's picker summary with these left out: a model with nothing else to run on is off; a Fuobe Original whose- * cloud half is all untested keeps its other engine.+ * Whether a visitor's run must leave this route out: never now. A visitor's run of an untested route goes on its own+ * key, as any paid model's does, and own-setup.ts labels it. Kept for the run planner's call (generations.ts+ * triedRoutes), which reads `true` as "leave it out".*/-export function hostedUntestedSummary(models: ModelDef[], base: AccessSummary | undefined): AccessSummary {- const off = new Set(base?.off ?? []);- const engines: Record<string, Engine[]> = { ...(base?.engines ?? {}) };- for (const m of models) {- if (off.has(m.id) || !m.routes.some((r) => hostedUntested(m.id, r))) continue;- const left = m.routes.filter((r) => !hostedUntested(m.id, r));- if (!left.length) {- off.add(m.id);- continue;- }- if (m.engines && m.engines.length > 1 && !left.some(hosted)) {- const on = (engines[m.id] ?? m.engines).filter((e) => e !== "cloud");- if (on.length) engines[m.id] = on;- else off.add(m.id);- }- }- return { off: [...off], ...(Object.keys(engines).length && { engines }) };-}+export const hostedUntested: (modelId: string, route: Pick<ModelRoute, "provider" | "endpoint">) => boolean = () => false;-/** Whether this route of this model is a hosted call that hasn't been sent with a real key yet (own-setup.ts). */-export function isHostedUntested(modelId: string, route: Pick<ModelRoute, "provider" | "endpoint">): boolean {- return hosted(route) && (HOSTED_UNTESTED_ENDPOINTS.has(route.endpoint) || HOSTED_UNTESTED_MODELS.has(modelId));+/**+ * A visitor's picker summary: the untested routes are no longer left out (they run on the visitor's own key, labelled+ * by own-setup.ts), so it is the summary it was given. Kept for /api/status's call (account-gpu.ts visitorStatus).+ */+export function hostedUntestedSummary(_models: ModelDef[], base: AccessSummary | undefined): AccessSummary {+ return { off: [...(base?.off ?? [])], ...(base?.engines && Object.keys(base.engines).length && { engines: { ...base.engines } }) };}diff --git a/src/lib/hubs.ts b/src/lib/hubs.tsindex 6c0a7e67..b1ee6e47 100644--- a/src/lib/hubs.ts+++ b/src/lib/hubs.ts@@ -15,6 +15,8 @@ export interface HubMode {ownerOnly?: true;/** The mode's tool runs on a self-hosted Fuobe only: the hub's engine badge says so to anyone but the owner (EngineSwitch). */selfHostedOnly?: true;+ /** The mode runs with the visitor's own setup (an own-setup.ts id): its tab carries the label's icon. */+ ownSetup?: string;}export const HUB_TITLE: Record<HubKind, string> = { upscale: "Upscale", audio: "Audio", "video-tools": "Video tools" };@@ -40,7 +42,7 @@ export const HUB_MODES: Record<HubKind, HubMode[]> = {{ id: "split", label: "Split soundtrack", selfHostedOnly: true },{ id: "sfx", label: "Sound effects" },{ id: "music", label: "Music" },- { id: "song", label: "Extend & remix", ownerOnly: true },+ { id: "song", label: "Extend & remix", ownSetup: "mureka-extend" },{ id: "loop", label: "Loop / extend" },{ id: "join", label: "Join" },{ id: "video", label: "Sound for video" },diff --git a/tests/hosted-untested.test.ts b/tests/hosted-untested.test.tsindex 0ddd4afc..af8b8566 100644--- a/tests/hosted-untested.test.ts+++ b/tests/hosted-untested.test.ts@@ -3,9 +3,9 @@ import { TINY_MP4 } from "./helpers/fake-comfy-runner";import { tempDir } from "./helpers/temp-dir";/**- * Hosted routes no live call has passed yet (src/lib/catalog/hosted-untested.ts) run for the owner only: an account's- * run of one, even on its own fal.ai key, answers 403 own-gpu-tool before anything is sent, and its pickers leave the- * model out. A Fuobe Original whose cloud half is untested keeps its open engine.+ * Hosted routes no live call has passed yet (src/lib/catalog/hosted-untested.ts) run on a visitor's own key: an+ * account with a fal.ai key gets them in its pickers and its run goes on that key; one without the key is asked for it+ * (403 add-key), never refused. The owner runs them as before. own-setup.ts labels them "Use your own fal.ai key".*/const dir = tempDir("fuobe-hosted-untested-");@@ -27,29 +27,33 @@ const keys = await import("@/server/account-keys");const generationsRoute = await import("@/app/api/generations/route");const { saveFile } = await import("@/server/storage");const { MODELS, getModel } = await import("@/lib/catalog");-const { HOSTED_UNTESTED_ENDPOINTS, HOSTED_UNTESTED_MODELS, hostedUntested, hostedUntestedSummary } = await import("@/lib/catalog/hosted-untested");+const { HOSTED_UNTESTED_ENDPOINTS, HOSTED_UNTESTED_MODELS, hostedUntested, hostedUntestedSummary, isHostedUntested } = await import("@/lib/catalog/hosted-untested");+const { ownSetupOnly } = await import("@/lib/own-setup");const { visitorStatus } = await import("@/server/account-gpu");const { HUB_MODES } = await import("@/lib/hubs");let cookie = "";let account = "";+let keylessCookie = "";beforeAll(() => {auth.setPassword("install password");account = auth.createAccount("[email protected]", "long enough").id;keys.saveAccountKey(account, "fal", "acct-fal-untested");cookie = `${auth.SESSION_COOKIE}=${auth.createSession(account).value}`;+ const keyless = auth.createAccount("[email protected]", "long enough").id;+ keylessCookie = `${auth.SESSION_COOKIE}=${auth.createSession(keyless).value}`;});afterAll(() => {globalThis.fetch = realFetch;globalThis.__fuobeTestDiskFree = undefined;});-const post = (body: unknown) => {+const post = (body: unknown, who: string | null = cookie, preview = true) => {const text = JSON.stringify(body);return generationsRoute.POST(- new Request("http://localhost:3000/api/generations", {+ new Request(`http://localhost:3000/api/generations${preview ? "?preview=1" : ""}`, {method: "POST",- headers: { cookie, host: "localhost:3000", "content-type": "application/json", "content-length": String(Buffer.byteLength(text)) },+ headers: { ...(who && { cookie: who }), host: "localhost:3000", "content-type": "application/json", "content-length": String(Buffer.byteLength(text)) },body: text,}) as never,);@@ -61,20 +65,32 @@ describe("hosted routes without a live call", () => {// The song tools' upload is a call inside a run, not a route of its own.for (const e of HOSTED_UNTESTED_ENDPOINTS) if (e !== "mureka/api/files/upload") expect(endpoints.has(e), e).toBe(true);for (const id of HOSTED_UNTESTED_MODELS) expect(getModel(id), id).toBeDefined();- expect(hostedUntested("anything", { provider: "comfyui", endpoint: "minimax/h3-lite" })).toBe(false);- expect(hostedUntested("fuobe-animation", { provider: "comfyui", endpoint: "wan22-inbetween-anisora" })).toBe(false);+ expect(isHostedUntested("anything", { provider: "comfyui", endpoint: "minimax/h3-lite" })).toBe(false);+ expect(isHostedUntested("fuobe-animation", { provider: "comfyui", endpoint: "wan22-inbetween-anisora" })).toBe(false);+ expect(isHostedUntested("lyria-3-5", { provider: "fal", endpoint: "google/lyria-3.5" })).toBe(true);+ // A visitor's run leaves none of them out any more.+ expect(hostedUntested("lyria-3-5", { provider: "fal", endpoint: "google/lyria-3.5" })).toBe(false);});it.each([["mureka-stems", { feature: "song-tools" }],["lyria-3-5", { feature: "audio" }],["elevenlabs-music-2-5", { feature: "audio" }],- ] as const)("refuses an account's %s run on its own key, sending nothing", async (modelId, extra) => {+ ] as const)("prices an account's %s run on its own fal.ai key", async (modelId, extra) => {const song = saveFile({ data: Buffer.from("ID3song"), contentType: "audio/mpeg", source: "upload", accountId: account }).url;- fetched.length = 0;const r = await post({ ...extra, modelId, engine: "cloud", prompt: "a slow jazz song", ...(modelId === "mureka-stems" && { inputs: { audio: song } }) });- expect(r.status, await r.clone().text()).toBe(403);- expect((await r.json()).code).toBe("own-gpu-tool");+ expect(r.status, await r.clone().text()).toBe(200);+ expect((await r.json()).route.provider).toBe("fal");+ expect(ownSetupOnly(modelId)).toEqual({ need: "key", provider: "fal" });+ });++ it("asks an account without a key for it, and a guest to sign up; nothing is sent", async () => {+ fetched.length = 0;+ const keyless = await post({ feature: "audio", modelId: "lyria-3-5", engine: "cloud", prompt: "a slow jazz song" }, keylessCookie, false);+ expect(keyless.status, await keyless.clone().text()).toBe(403);+ expect((await keyless.json()).code).not.toBe("own-gpu-tool");+ const guest = await post({ feature: "audio", modelId: "lyria-3-5", engine: "cloud", prompt: "a slow jazz song" }, null, false);+ expect(guest.status).toBe(401);expect(fetched.filter((u) => /fal\.(run|ai|media)/.test(u))).toHaveLength(0);});@@ -88,17 +104,21 @@ describe("hosted routes without a live call", () => {);expect(r.status, await r.clone().text()).toBe(200);const priced = await post({ feature: "audio", modelId: "lyria-3-5", engine: "cloud", prompt: "a slow jazz song" });- expect(priced.status).toBe(403);+ expect(priced.status).toBe(200);});- it("leaves them out of an account's pickers; an Original keeps its open engine", async () => {+ it("keeps them in an account's pickers, both engines of an Original too, and opens Extend & remix", async () => {const summary = hostedUntestedSummary(MODELS, undefined);- for (const id of ["mureka-extend", "mureka-remix", "mureka-stems", "lyria-3-5", "vidu-q4", "tripo-p2", "minimax-h3-max-turbo"]) expect(summary.off, id).toContain(id);- expect(summary.off).not.toContain("fuobe-animation");- expect(summary.engines?.["fuobe-animation"]).toEqual(["open"]);+ for (const id of ["mureka-extend", "mureka-remix", "mureka-stems", "lyria-3-5", "vidu-q4", "tripo-p2", "minimax-h3-max-turbo", "fuobe-animation"]) expect(summary.off, id).not.toContain(id);+ expect(summary.engines?.["fuobe-animation"]).toBeUndefined();const status = await visitorStatus(auth.accountById(account)!);- expect(status.access?.off).toContain("mureka-stems");- expect(HUB_MODES.audio.find((m) => m.id === "song")?.ownerOnly).toBe(true);+ expect(status.access?.off ?? []).not.toContain("mureka-stems");+ const song = HUB_MODES.audio.find((m) => m.id === "song");+ expect(song?.ownerOnly).toBeUndefined();+ expect(song?.ownSetup).toBe("mureka-extend");+ // The Original's cloud half needs the key; its open half runs as before.+ expect(ownSetupOnly("fuobe-animation")).toBeNull();+ expect(ownSetupOnly("fuobe-animation", "cloud")).toEqual({ need: "key", provider: "fal" });});});@@ -129,12 +149,10 @@ describe("Kandinsky 6.0, Kandinsky VSR, Bria's green screen and its guided cut-ofor (const [endpoint] of ROUTES) expect(HOSTED_UNTESTED_ENDPOINTS.has(endpoint), endpoint).toBe(true);});- it.each(ROUTES)("refuses an account's run on %s on its own key, sending nothing", async (_endpoint, ask) => {- fetched.length = 0;+ it.each(ROUTES)("prices an account's run on %s on its own key", async (endpoint, ask) => {const r = await post({ ...ask(account), engine: "cloud" });- expect(r.status, await r.clone().text()).toBe(403);- expect((await r.json()).code).toBe("own-gpu-tool");- expect(fetched.filter((u) => /fal\.(run|ai|media)/.test(u))).toHaveLength(0);+ expect(r.status, await r.clone().text()).toBe(200);+ expect((await r.json()).route).toEqual({ provider: "fal", endpoint });});it.each(ROUTES)("runs %s for the owner", async (endpoint, ask) => {@@ -155,9 +173,10 @@ describe("Kandinsky 6.0, Kandinsky VSR, Bria's green screen and its guided cut-o}});- it("leaves the cloud models out of an account's pickers and keeps their open halves", () => {+ it("keeps the cloud models and their open halves in an account's pickers, the cloud ones labelled", () => {const summary = hostedUntestedSummary(MODELS, undefined);- for (const id of ["kandinsky-6", "kandinsky-vsr", "bria-green-screen", "bria-guided-cutout"]) expect(summary.off, id).toContain(id);- for (const id of ["oss-kandinsky6", "oss-kandinsky6-vsr", "oss-video-key-corridorkey", "oss-matte-feynobg"]) expect(summary.off, id).not.toContain(id);+ for (const id of ["kandinsky-6", "kandinsky-vsr", "bria-green-screen", "bria-guided-cutout", "oss-kandinsky6", "oss-kandinsky6-vsr", "oss-video-key-corridorkey", "oss-matte-feynobg"]) expect(summary.off, id).not.toContain(id);+ for (const id of ["kandinsky-6", "kandinsky-vsr", "bria-green-screen", "bria-guided-cutout"]) expect(ownSetupOnly(id), id).toEqual({ need: "key", provider: "fal" });+ for (const id of ["oss-kandinsky6-vsr", "oss-video-key-corridorkey", "oss-matte-feynobg"]) expect(ownSetupOnly(id), id).toBeNull();});});diff --git a/tests/nav-bar.test.ts b/tests/nav-bar.test.tsindex d1009b28..a2f056a9 100644--- a/tests/nav-bar.test.ts+++ b/tests/nav-bar.test.ts@@ -174,7 +174,7 @@ describe("the launcher's columns", () => {expect(subs("marketing")).toEqual(["Click to Ad", "Ads Studio", "Ad Multiplier"]);expect(subs("genjutsu")).toEqual(["Motion transfer", "Character swap", "Object swap", "Restyle", "Insert", "Finish"]);expect(subs("upscale")).toEqual(["Image", "Video", "FPS Boost", "SDR to HDR", "Export"]);- expect(subs("audio")).toEqual(["Speech", "Dialogue", "Voice change", "See all 14"]);+ expect(subs("audio")).toEqual(["Speech", "Dialogue", "Voice change", "See all 15"]);expect(subs("video-tools")).toEqual(["Relight", "Captions", "Remove object", "See all 11"]);for (const w of ["Click to Ad", "Ads Studio", "Ad Multiplier", "Motion transfer", "FPS Boost"]) expect(words(html)).toContain(w);// Under a hairline, quieter than a row, with no picture and no line of their own (nav-subs.css: 24 px@@ -183,7 +183,7 @@ describe("the launcher's columns", () => {expect(sub).toContain("text-muted-foreground");expect(html).toMatch(/<ul[^>]*class="nav-subs /);// A "See all N" says whose.- expect(html).toContain('aria-label="See all 14 in Audio"');+ expect(html).toContain('aria-label="See all 15 in Audio"');});it("labels the groups, and every link has its studio's real cover in a box of fixed size", () => {diff --git a/tests/nav-subfeatures.test.ts b/tests/nav-subfeatures.test.tsindex b0c68e14..f7b59585 100644--- a/tests/nav-subfeatures.test.ts+++ b/tests/nav-subfeatures.test.ts@@ -116,7 +116,7 @@ describe("the catalogue of studio features", () => {describe("who sees a studio's features", () => {it("keeps the owner's own modes the owner's, in every place", () => {- for (const id of ["genjutsu-picture", "cinema-blockout", "canvas-skills", "assist-memory", "assist-scheduled", "audio-song", "video-tools-restore"]) {+ for (const id of ["genjutsu-picture", "cinema-blockout", "canvas-skills", "assist-memory", "assist-scheduled", "video-tools-restore"]) {expect(entry(id)!.visibility, id).toEqual(["owner"]);for (const kind of VISITORS) expect(entriesFor(kind).some((e) => e.id === id), `${kind}: ${id}`).toBe(false);}