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
Merge branch 'r4/model-access' into claude/fuobe-parity-4
Claude093f224eabfb
diff --cc src/components/photodump/photodump-view.tsxindex 5d11e453,1486243e..dc64535f--- a/src/components/photodump/photodump-view.tsx+++ b/src/components/photodump/photodump-view.tsx@@@ -11,8 -11,9 +11,9 @@@ import { Input } from "@/components/ui/import { EngineSwitch } from "@/components/studio/engine-switch";import { fileToList, type SlotValue } from "@/components/studio/media-slot";import { radioKeys, radioTab } from "@/components/studio/radio-keys";- import { useElements, useEngine, useGenerations } from "@/lib/api";+ import { useElements, useEngine, useGenerations, useModelAccess } from "@/lib/api";+ import { keepOffered, offered } from "@/lib/model-access";-import { customPack, DEFAULT_ASPECT, MAX_PACK_REFS, MAX_SELFIE_MB, PACKS, PHOTODUMP_ASPECTS, PHOTODUMP_MODELS, type Pack } from "@/lib/catalog/packs";+import { customPack, DEFAULT_ASPECT, MAX_PACK_REFS, MAX_SELFIE_MB, PACKS, PHOTODUMP_ASPECTS, PHOTODUMP_MODELS, PHOTODUMP_SOUL, soulIdOf, type Pack } from "@/lib/catalog/packs";import type { Generation } from "@/lib/catalog/types";import { timeAgo } from "@/lib/format";import { cn } from "@/lib/utils";@@@ -178,12 -180,14 +179,14 @@@ export function PhotodumpView()// The Model choice follows the engine: a pick the other engine had counts as Auto (one radio is always checked).const elements = useElements();const character = subjectMode === "character" ? elements.data?.find((e) => e.id === elementId) : undefined;- const choices: (string | undefined)[] = [undefined, ...PHOTODUMP_MODELS[engine]];+ // Models switched off in Settings → Models & licences leave the choices (Auto picks among the ones on).+ const access = useModelAccess();+ const choices: (string | undefined)[] = [undefined, ...keepOffered(PHOTODUMP_MODELS[engine], (m) => offered(access, m, engine))];const unavailable = (m?: string): string | null => {- if (m !== "oss-z-image-turbo") return null;- if (pack?.custom) return "Your own packs recreate each reference photo with Qwen-Image-Edit";- if (!character) return "Needs a character with a trained LoRA";- return character.loras.some((l) => l.modelId === "oss-z-image-turbo" && l.engine === "open" && !l.referenceId) ? null : `${character.name} has no trained LoRA yet`;+ if (m !== PHOTODUMP_SOUL) return null;+ if (pack?.custom) return "Your own packs recreate each reference photo with an edit model";+ if (!character) return "Needs a character with a trained Soul ID";+ return soulIdOf({ kind: "element", handle: character.handle, name: character.name, references: character.references, loras: character.loras }, engine) ? null : `${character.name} has no Soul ID yet`;};const pick = choices.includes(modelPick) && !unavailable(modelPick) ? modelPick : undefined;const body = pack && subjectReadydiff --cc src/lib/catalog/plan.tsindex 74d402f7,5a8f1f94..882d6fde--- a/src/lib/catalog/plan.ts+++ b/src/lib/catalog/plan.ts@@@ -261,21 -255,16 +261,14 @@@ export function planGeneration...(r.grade && { grade: r.grade }),...(r.overlay && { overlay: r.overlay }),};- // characterStrength is Fuobe's setting, not the provider's.- if ("characterStrength" in extra) {- const rest = { ...extra };- delete rest.characterStrength;- params = { ...params, extra: Object.keys(rest).length ? rest : undefined };- }- } else if (req.loras?.length) loras = [...req.loras, ...loras];+ } else if (req.loras?.length) {+ // An @character's trained LoRA on FLUX, klein, Krea or any other model: at the character strength's scale, as on Soul.+ const own = charStrength === undefined ? req.loras : req.loras.map((l) => ({ ...l, strength: characterScale(charStrength) }));+ loras = [...own, ...loras];+ }// A LoRA at strength 0 changes nothing: leave it out, so preset strength 0 is the preset's prompt alone (and its file isn't needed).const kept = loras.filter((l) => (l.strength ?? 1) !== 0);- // Its trigger word goes with it: an open motion's template starts with its LoRA's trigger ("e13c7r1c electricity- // effect. …", see withOssLoras), which means nothing to the model without the LoRA.- const keptTriggers = new Set(kept.map((l) => l.trigger).filter(Boolean));- for (const l of loras) {- if ((l.strength ?? 1) !== 0 || !l.trigger || keptTriggers.has(l.trigger)) continue;- const lead = [". ", ", ", " "].map((sep) => l.trigger + sep).find((t) => prompt.startsWith(t));- if (lead) prompt = prompt.slice(lead.length);- }+ prompt = withoutTriggers(prompt, loras.filter((l) => !kept.includes(l)), kept);loras = kept;// Multi-shot: the clip is as long as its shots, and models without per-shot prompts get them written out.@@@ -585,9 -589,9 +593,9 @@@ export function routeLoras(route: Pick<const applied = fitLoras(loras, route).loras;const field = routeLoraField(route);const why = (l: LoraRef) => {- if (localOnly(l)) return "its licence doesn't allow hosting, so it runs only on your GPU";+ if (localOnly(l)) return "it is licensed for your GPU only, and Settings → Models & licences keeps such LoRAs off the cloud";if (gated(l) && !l.hostedUrl) return "it is in a gated Hugging Face repo, so it runs only on your GPU";- if (!cloudPath(l) && !needsToken(l.url)) return "no URL to send to the LoRA endpoint";+ if (!cloudPath(l) && !needsToken(l.url) && !l.own) return "no URL to send to the LoRA endpoint";if (!field) return "this route takes no LoRAs";return field.shape === "experts" ? "this API takes one LoRA per expert" : `this API takes up to ${loraCapacity(field)} LoRAs`;};diff --cc src/lib/catalog/types.tsindex 738cb5c5,b02b2acc..b92db990--- a/src/lib/catalog/types.ts+++ b/src/lib/catalog/types.ts@@@ -758,11 -741,11 +758,16 @@@ export interface LoraRef*/version?: string;licence?: LoraLicence;+ /**+ * The user's own trained LoRA (Fuobe Soul ID): Fuobe keeps the file, so a run copies it into ComfyUI's folder or+ * sends it to the cloud provider itself (src/server/loras.ts), whichever engine trained it.+ */+ own?: true;+ /**+ * Set by the server on a run's LoRAs while Settings → Models & licences keeps LoRAs licensed for your GPU only+ * off the cloud: a cloud route then leaves such a LoRA out (localOnly). Without it they are sent like any other.+ */+ keepOnGpu?: true;}/** Scale limits of a LoRA field. */diff --cc src/server/loras.tsindex 5c9d5738,ef218361..a54cd49c--- a/src/server/loras.ts+++ b/src/server/loras.ts@@@ -343,12 -334,8 +345,12 @@@ export async function prepareCloudLorasfor (const l of loras) {const entry = libraryEntry(l);const name = loraName(l);- // The library's licence counts even when the ref carries none: a GPU-only file never reaches a provider.- if (localOnly(l)) throw new LoraError(`${name} runs only on your GPU (its licence doesn't allow hosting it)`);+ // Only while the admin keeps GPU-only LoRAs on the GPU (fitLoras has left it out of a cloud run already).+ if (localOnly(l)) throw new LoraError(`${name} is licensed for your GPU only, and Settings → Models & licences keeps such LoRAs off the cloud`);+ if (l.own && !l.hostedUrl) {+ out.push(await sendOwnLora(l, target, upload, onProgress));+ continue;+ }if (cloudPath(l)) {out.push(l);continue;@@@ -404,84 -393,16 +408,94 @@@return out;}+// ---------------------------------------------------------------------------+// The user's own trained LoRAs (Fuobe Soul ID)++/** Where Fuobe keeps the LoRAs its trainings made (fuobe/<handle>-<id>.safetensors under it). */+export const TRAINED_DIR = LORA_CACHE_DIR;++/** Fuobe's own copy of a trained LoRA, when it has one. */+export function ownCopy(file: string): string | null {+ try {+ const p = lorasPath(TRAINED_DIR, file);+ return fs.existsSync(p) ? p : null;+ } catch {+ return null;+ }+}++/**+ * Keep a trained LoRA in Fuobe's own folder: copied from a file on this machine (AI-Toolkit's output, ComfyUI's+ * folder) or downloaded from the trainer's URL (fal storage, which states no hash: the length must match).+ */+export async function keepTrainedLora(file: string, from: { path?: string; url?: string }): Promise<string> {+ const dest = lorasPath(TRAINED_DIR, file);+ await fs.promises.mkdir(path.dirname(dest), { recursive: true });+ if (from.path) {+ // Asynchronous: a LoRA of a few hundred MB doesn't hold up the server while it copies.+ if (path.resolve(from.path) !== dest) await fs.promises.copyFile(from.path, dest);+ return dest;+ }+ if (!from.url) throw new LoraError(`Nowhere to copy ${file} from`);+ return (await downloadLora({ file, url: from.url }, TRAINED_DIR)).path;+}++/** Record the URL a trainer left a LoRA at (fal's own storage), so cloud runs use it while it lives. */+export function recordTrainedMirror(file: string, target: "fal" | "replicate", url: string): void {+ const own = ownCopy(file);+ recordCopy({+ file,+ target,+ sourceUrl: url,+ version: null,+ hostedUrl: url,+ sha256: own ? sha256File(own) : null,+ sizeBytes: own ? fs.statSync(own).size : null,+ licence: { own: true },+ });+}++/**+ * A trained LoRA on its way to fal or Replicate: the copy already there while it lives (fal's from the training, or+ * one Fuobe sent), else Fuobe's copy sent once (the user's own LoRA, trained on their photos: no licence stops it),+ * else the trainer's URL as a last try. A LoRA only ComfyUI has can't go.+ */+async function sendOwnLora(l: LoraRef, target: "fal" | "replicate", upload: (data: Buffer, name: string) => Promise<string>, onProgress?: (m: string) => void): Promise<LoraRef> {+ const name = loraName(l);+ const cached = getCopy(l.file, target);+ if (cached?.hostedUrl && Date.now() - cached.createdAt < MIRROR_TTL_MS[target]) return { ...l, hostedUrl: cached.hostedUrl };+ const comfyDir = getSetting("comfyLorasDir");+ const inComfy = (() => {+ if (!comfyDir) return null;+ try {+ const p = lorasPath(comfyDir, l.file);+ return fs.existsSync(p) ? p : null;+ } catch {+ return null;+ }+ })();+ const local = ownCopy(l.file) ?? inComfy;+ if (local) {+ onProgress?.(`Sending ${name} to ${target === "fal" ? "fal.ai" : "Replicate"} (once)`);+ const data = fs.readFileSync(local);+ const hostedUrl = await upload(data, path.basename(l.file));+ recordCopy({ file: l.file, target, sourceUrl: `fuobe:${l.file}`, version: null, hostedUrl, sha256: crypto.createHash("sha256").update(data).digest("hex"), sizeBytes: data.length, licence: { own: true } });+ return { ...l, hostedUrl };+ }+ if (l.url) return { ...l, hostedUrl: l.url };+ throw new LoraError(`${name} exists only on your GPU's machine, so it can't run in the cloud: run it on your GPU, or train it in the cloud`);+}++ /**+ * What a mirror records about the hosting right it was copied under (nothing when civitai lists "Rent"): civitai+ * didn't answer, so it is unknown, or civitai lists no "Rent" and the admin lets such LoRAs go to the cloud.+ */+ function hostingNote(now: string[] | null): string | undefined {+ if (!now) return "copied without civitai's current permissions: civitai didn't answer, so its hosting right wasn't confirmed";+ if (!now.includes("Rent")) return "copied without civitai's “Rent” permission: Settings → Models & licences lets LoRAs licensed for your GPU only go to the cloud";+ return undefined;+ }+/*** Download a library LoRA into the LoRA folder ahead of a run (Settings → LoRAs). Returns the copy recorded.*/