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.

Runs: Genjutsu's makers and Clean the voice first sent directly run on an account's own GPU or key

Adarsh7bce89165e60
diff --git a/src/app/api/generations/route.ts b/src/app/api/generations/route.ts
index 2cf1a24e..57efad4b 100644
--- a/src/app/api/generations/route.ts
+++ b/src/app/api/generations/route.ts
@@ -1,5 +1,5 @@
import { connection } from "next/server";
-import { ACTIVE_RUNS_CODE, CONNECT_GPU_HEADER, CONNECT_NEEDS_HEADER, GUEST_RUN_MESSAGE, OWN_GPU_TOOL_MESSAGE } from "@/lib/guest-access";
+import { ACTIVE_RUNS_CODE, CONNECT_GPU_HEADER, CONNECT_NEEDS_HEADER, GUEST_RUN_MESSAGE } from "@/lib/guest-access";
import { missingFilesMessage } from "@/lib/missing-files";
import { ADD_KEY_HEADER } from "@/lib/your-keys";
import { requestViewer, validToken } from "@/server/auth";
@@ -9,10 +9,6 @@ import { getSetting } from "@/server/settings";
import { RUNS_ON_COMPUTER_NOTE } from "@/lib/relay";
import { OPERATION_LABELS } from "@/lib/catalog/types";
import { ANY_ANGLE } from "@/lib/catalog/any-angle";
-import { directRunFeatures } from "@/lib/catalog/genjutsu";
-import { genjutsuLive } from "@/server/genjutsu-live";
-import { soundLive } from "@/server/sound-live";
-import { wantsVoiceFirst } from "@/lib/av/voice-first";
import { relightRunTitle } from "@/lib/relight/engine";
import { ACCOUNT_LIMITS, ACCOUNT_MESSAGES, accountTotalBytes, accountUsage, diskHasRoom, filesFullMessage } from "@/server/account-files";
import { accountInputProblem } from "@/server/account-inputs";
@@ -86,18 +82,10 @@ export async function POST(request: Request) {
const asked = relightTitle ? { ...sent, title: relightTitle } : sent;
// Public sign-up: an account runs on its own ComfyUI or its own fal.ai or Replicate key, never the install's providers.
// Without a key of its own it stays on the open engine; with one, the engine it asked for.
- // Genjutsu's new makers open one by one (src/server/genjutsu-live.ts): sent here directly, a maker that hasn't opened
- // runs for the owner only, as on the Genjutsu page.
- if (viewer.kind !== "owner") {
- // "Clean the voice first" opens to visitors once it has passed a real run (src/server/sound-live.ts).
- if (wantsVoiceFirst(asked) && !soundLive()["clean-voice-first"]) return refuse(403, OWN_GPU_TOOL_MESSAGE, { code: "own-gpu-tool" });
- const extra = asked.params?.extra?.openjutsu;
- const needs = directRunFeatures(asked.modelId, extra && typeof extra === "object" ? (extra as Record<string, unknown>) : {});
- if (needs) {
- const live = genjutsuLive();
- if (needs.some((f) => !live[f])) return refuse(403, OWN_GPU_TOOL_MESSAGE, { code: "own-gpu-tool" });
- }
- }
+ // Genjutsu's new makers and "Clean the voice first", until each passes on this studio's GPU, run on a visitor's own GPU
+ // or key only (src/lib/own-setup.ts), as on the Genjutsu page: an account's run goes there (accountRun answers Connect
+ // your GPU or Add your key when it has neither), a run on this install's GPUs is refused with the setup's label
+ // (hosted-run.ts poolGate), and a guest signs up first. Never this studio's own GPU for a visitor.
let req = account ? { ...asked, account: account.id, engine: accountEngineMode(account.id) === "open" ? ("open" as const) : asked.engine } : { ...asked, account: undefined };
const onOwn = <T,>(fn: () => T): T => (account ? asAccount(account.id, fn) : fn());
// A visitor's price check: priced as it would run, as that visitor (an account: its own GPU and keys; a guest: the open
diff --git a/src/components/captions/captions-studio.tsx b/src/components/captions/captions-studio.tsx
index 6ac5f284..c011b157 100644
--- a/src/components/captions/captions-studio.tsx
+++ b/src/components/captions/captions-studio.tsx
@@ -153,7 +153,8 @@ function Editor({ video, restored, onReplace }: { video: SlotValue; restored: Sa
const [source, setSource] = useState("auto");
const [quick, setQuick] = useState(false);
// "Clean the voice first": on for a video's speech on your GPU, off in the cloud (it adds a paid step there).
- const voiceFirstShown = useVoiceFirstShown();
+ // Shown to every visitor: until it passes on this studio's GPU it runs on their own GPU or key, labelled so.
+ const voiceFirstShown = useVoiceFirstShown(true);
const voiceFirstLive = useVoiceFirstLive();
const [voiceFirst, setVoiceFirst] = useState<boolean | null>(null);
const cleanFirst = voiceFirstShown && (voiceFirst ?? (engine === "open" && voiceFirstDefault("video", voiceFirstLive)));
diff --git a/src/components/studio/composer.tsx b/src/components/studio/composer.tsx
index aa7ec362..54f4b3ac 100644
--- a/src/components/studio/composer.tsx
+++ b/src/components/studio/composer.tsx
@@ -291,7 +291,8 @@ export function Composer({ docked }: { docked: boolean }) {
const voice = useClipFacts(voiceRef).data;
// "Clean the voice first" (Transcribe, Lipsync): the recording or the video's speech apart from its music and effects
// before the model hears it. On for a video's speech on your GPU, off for a recording (src/lib/av/voice-first.ts).
- const voiceFirstShown = useVoiceFirstShown();
+ // Shown to every visitor: until it passes on this studio's GPU it runs on their own GPU or key, labelled so.
+ const voiceFirstShown = useVoiceFirstShown(true);
const voiceFirstLive = useVoiceFirstLive();
const [voiceFirstAsked, setVoiceFirstAsked] = useState<boolean | null>(null);
const voiceFirstKind: "audio" | "video" | null = !config.voiceFirst ? null : typed.slots.audio?.ref ? "audio" : typed.slots.video?.ref && config.ops.includes("transcribe") ? "video" : null;
diff --git a/tests/genjutsu-openjutsu-access.test.ts b/tests/genjutsu-openjutsu-access.test.ts
index 36657fc3..8a18fec6 100644
--- a/tests/genjutsu-openjutsu-access.test.ts
+++ b/tests/genjutsu-openjutsu-access.test.ts
@@ -101,10 +101,14 @@ describe("Genjutsu's Openjutsu features before and after they open", () => {
expect((await r.json()).error ?? "").not.toBe(NOT_HERE);
});
- it("the new makers' models sent straight to /api/generations run for the owner only", async () => {
+ it("the new makers' models sent straight to /api/generations run on an account's own GPU, never this studio's", async () => {
process.env.FUOBE_PUBLIC_SIGNUP = "1";
- const cookie = auth.createSession(auth.createAccount(`oj${++n}@example.com`, "long enough").id).value;
+ const account = auth.createAccount(`oj${++n}@example.com`, "long enough").id;
+ const cookie = auth.createSession(account).value;
const owner = auth.createSession().value;
+ // The account's own clip, so nothing but the place stops its run.
+ const mine = saveFile({ data: fs.readFileSync(path.join(__dirname, "fixtures/shorts-12s.mp4")), contentType: "video/mp4", source: "upload", name: "mine.mp4", accountId: account }).url;
+ const own = (b: { inputs: { video: string; images?: string[] } }) => ({ ...b, inputs: { video: mine, ...(b.inputs.images && { images: b.inputs.images.map(() => mine) }) } });
const runs = [
{ feature: "genjutsu", modelId: "oss-h3-group-swap", op: "group-swap", inputs: { video: clip, images: [clip] } },
{ feature: "genjutsu", modelId: "oss-h3-scene-edit", op: "scene-edit", inputs: { video: clip }, params: { extra: { openjutsu: { action: "remove" } } } },
@@ -128,17 +132,19 @@ describe("Genjutsu's Openjutsu features before and after they open", () => {
for (const b of runs) {
const open = directRunFeatures(b.modelId, (b.params?.extra?.openjutsu ?? {}) as Record<string, unknown>)!.every((f) => live[f]);
for (const [who, preview] of [[cookie, false], [cookie, true], [undefined, true]] as const) {
- const r = await send(b, who, preview);
+ const r = await send(who ? own(b) : b, who, preview);
const j = await r.json();
- // A feature that passed goes past the gate (other rules may still stop it: here the clip isn't the visitor's).
- if (open) {
- expect(j.code ?? "", `${b.modelId} ${who ? "account" : "guest"}${preview ? " price check" : ""}`).not.toBe("own-gpu-tool");
- continue;
- }
- expect(r.status, `${b.modelId} ${who ? "account" : "guest"}${preview ? " price check" : ""}`).toBe(403);
- expect(j.code).toBe("own-gpu-tool");
- expect(j.error).toBe(access.OWN_GPU_TOOL_MESSAGE);
+ const label = `${b.modelId} ${who ? "account" : "guest"}${preview ? " price check" : ""}`;
+ // Never "isn't available here": it runs on the visitor's own setup.
+ expect(j.code ?? "", label).not.toBe("own-gpu-tool");
+ if (open || preview) continue;
+ // An account with no GPU of its own is asked to connect one: its run goes nowhere else.
+ expect(r.status, label).toBe(403);
+ expect(j.code, label).toBe("connect-gpu");
+ expect(r.headers.get(access.CONNECT_GPU_HEADER), label).toBe("1");
}
+ // A guest's run: sign up first.
+ expect((await send(b)).status, b.modelId).toBe(401);
// The owner's request isn't refused by the gate (it may still fail later: no ComfyUI here).
const r = await send(b, owner, true);
expect(((await r.json()) as { code?: string }).code ?? "", b.modelId).not.toBe("own-gpu-tool");