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.

Models & licences: switched-off models leave every listing and picker, and automatic picks fall back

Claude2c3e38a53b83
diff --git a/src/app/api/models/route.ts b/src/app/api/models/route.ts
index a626d9b9..06f9b58d 100644
--- a/src/app/api/models/route.ts
+++ b/src/app/api/models/route.ts
@@ -7,6 +7,7 @@ import { findModels, MODEL_KINDS, toModelInfo } from "@/lib/model-list";
import { AUDIO_STUDIO, DIALOGUE_STUDIO, EDIT_STUDIO, IMAGE_STUDIO, VIDEO_STUDIO } from "@/lib/studios";
import { provider } from "@/server/providers";
import { llmBackends } from "@/server/providers/llm";
+import { offeredDefault, offeredModels } from "@/server/model-access";
import { engineMode, getSetting } from "@/server/settings";
/** A provider for one of its routes is set up. */
@@ -46,7 +47,8 @@ const DEFAULTS: Record<string, { cloud?: string; open?: string }> = {
* cloud), op, q (words that must all match), hidden=1 (chain helpers too). Models of an engine the
* install has switched off (Settings → Engine mode) are left out. `defaults` are the studios' own
* picks per engine (DEFAULTS); each item says whether its provider is `connected` and how a run
- * goes today (`runs`, which follows Settings → Demo mode).
+ * goes today (`runs`, which follows Settings → Demo mode). Models switched off in Settings → Models & licences
+ * are left out, and a default that is off gives way to the next model that is on.
*/
export async function GET(request: Request) {
await connection();
@@ -62,11 +64,14 @@ export async function GET(request: Request) {
// that engine's model (its routes, its price), else it is listed once with both.
const only = (engine as Engine | undefined) ?? (mode === "both" ? undefined : mode);
// The install's only engine counts as asked for: an Original's operations there are that engine's.
- const list = findModels(MODELS, { kind: kind as MediaKind | undefined, engine: only, op: op as Operation | undefined, q: p.get("q") ?? undefined, hidden: p.get("hidden") === "1" })
+ // Settings → Models & licences: what is switched off isn't listed, and each model lists the routes that are on.
+ const list = findModels(offeredModels(MODELS), { kind: kind as MediaKind | undefined, engine: only, op: op as Operation | undefined, q: p.get("q") ?? undefined, hidden: p.get("hidden") === "1" })
.filter((m) => mode === "both" || runsOn(m, mode))
.map((m) => (only ? onEngine(m, only) : m));
+ // A default that is switched off gives way to the next model that is on and does the same job.
+ const pick = (id: string | undefined, e: Engine) => offeredDefault(id, e);
const defaults = Object.fromEntries(
- Object.entries(DEFAULTS).map(([k, ids]) => [k, { ...(mode !== "open" && ids.cloud && { cloud: ids.cloud }), ...(mode !== "cloud" && ids.open && { open: ids.open }) }]),
+ Object.entries(DEFAULTS).map(([k, ids]) => [k, { ...(mode !== "open" && ids.cloud && { cloud: pick(ids.cloud, "cloud") }), ...(mode !== "cloud" && ids.open && { open: pick(ids.open, "open") }) }]),
);
const demoMode = getSetting("demoMode");
return Response.json({ engineMode: mode, demoMode, defaults, items: list.map((m) => ({ ...toModelInfo(m), connected: connected(m), runs: runsAs(m, demoMode) })) });
diff --git a/src/app/api/status/route.ts b/src/app/api/status/route.ts
index 5bc0820c..5e51ffb4 100644
--- a/src/app/api/status/route.ts
+++ b/src/app/api/status/route.ts
@@ -3,6 +3,7 @@ import { PROVIDERS } from "@/server/providers";
import { comfyRam, probeComfy } from "@/server/providers/comfyui";
import { nothingConnected, type EngineModeName } from "@/lib/connections";
import { getSetting, setSetting } from "@/server/settings";
+import { offeredSummary } from "@/server/model-access";
/** Which providers are usable right now — drives badges, the demo-mode notice and Home's first-run guide. */
export async function GET() {
@@ -17,6 +18,7 @@ export async function GET() {
]),
);
const engineMode = getSetting("engineMode") as EngineModeName;
+ const access = offeredSummary();
// The first time something this engine mode generates with is connected, the first-run guide has
// done its job: remember it, so a ComfyUI that is offline one morning doesn't bring "Get started" back.
let onboarded = getSetting("onboarded") === "1";
@@ -30,5 +32,7 @@ export async function GET() {
engineMode,
cloudProvider: getSetting("cloudProvider"),
onboarded,
+ // Settings → Models & licences: the models switched off, so pickers leave them out (absent while everything is on).
+ ...(access && { access }),
});
}
diff --git a/src/components/canvas/nodes.tsx b/src/components/canvas/nodes.tsx
index b36d0ea9..ce78cc58 100644
--- a/src/components/canvas/nodes.tsx
+++ b/src/components/canvas/nodes.tsx
@@ -69,7 +69,8 @@ import { ResponsivePanel } from "@/components/studio/responsive-panel";
import { VoiceRecorder } from "@/components/studio/voice-recorder";
import { toast } from "sonner";
import { useQuery, useQueryClient } from "@tanstack/react-query";
-import { useAssets, useClipFacts as useFileFacts, useElements } from "@/lib/api";
+import { useAssets, useClipFacts as useFileFacts, useElements, useModelAccess } from "@/lib/api";
+import { offered } from "@/lib/model-access";
import { dualEngine, onEngine } from "@/lib/catalog/engines";
import {
CANVAS_TEXT_MAX,
@@ -680,8 +681,16 @@ const GeneratorNode = memo(function GeneratorNode({ id, type: flowType, data, se
// The picker opens on the node's own engine (or the install's only one); its switch browses the other.
const [browseEngine, setBrowseEngine] = useState<Engine | null>(null);
const pickerEngine: Engine = g.mode !== "both" ? g.mode : (browseEngine ?? model?.engine ?? g.engine);
- // A Fuobe Original is listed on the engine being browsed (it runs on both).
- const choices = useMemo(() => modelChoices(node).map((m) => onEngine(m, pickerEngine)), [node, pickerEngine]);
+ // A Fuobe Original is listed on the engine being browsed (it runs on both). Models switched off in Settings →
+ // Models & licences aren't offered (a node already on one says so when it runs).
+ const access = useModelAccess();
+ const choices = useMemo(
+ () =>
+ modelChoices(node)
+ .filter((m) => offered(access, m.id, pickerEngine))
+ .map((m) => onEngine(m, pickerEngine)),
+ [node, pickerEngine, access],
+ );
const error = v.runError ?? v.error;
// Handles change with the model and op: tell React Flow to re-measure them (React Flow measures new nodes itself).
diff --git a/src/components/cinema/prompt-bar.tsx b/src/components/cinema/prompt-bar.tsx
index aee2edd9..eb74f68a 100644
--- a/src/components/cinema/prompt-bar.tsx
+++ b/src/components/cinema/prompt-bar.tsx
@@ -42,7 +42,8 @@ import { PromptInput, ELEMENT_ICONS, type PromptInputHandle } from "@/components
import { ShotsEditor } from "@/components/studio/shots-editor";
import { ResponsivePanel } from "@/components/studio/responsive-panel";
import { useEdgeFade } from "@/components/studio/use-edge-fade";
-import { uploadFile, useAssets, useStatus } from "@/lib/api";
+import { uploadFile, useAssets, useModelAccess, useStatus } from "@/lib/api";
+import { offered } from "@/lib/model-access";
import { getModel } from "@/lib/catalog";
import {
BATCH,
@@ -438,7 +439,12 @@ export function PromptBar(props: PromptBarProps) {
};
const modelKey = `${draft.mode}:${engine}` as const;
- const modelList = CINEMA_MODELS[draft.mode][engine];
+ // Models switched off in Settings → Models & licences leave the menu, and the pick falls back to the next one on
+ // (with all of them off the menu stays, and a run says which switch to turn back on).
+ const access = useModelAccess();
+ const allModels = CINEMA_MODELS[draft.mode][engine];
+ const onModels = allModels.filter((id) => offered(access, id, engine));
+ const modelList = onModels.length ? onModels : allModels;
// The model picked in the menu (a take may run on another: Fuobe DoP for a move's Wan camera LoRA, a references edit…).
const chosen = draft.models[modelKey];
const picked = chosen && modelList.includes(chosen) ? chosen : modelList[0];
diff --git a/src/components/command-palette.tsx b/src/components/command-palette.tsx
index 5f85e839..1f7e22e3 100644
--- a/src/components/command-palette.tsx
+++ b/src/components/command-palette.tsx
@@ -1,7 +1,7 @@
"use client";
import { useQuery } from "@tanstack/react-query";
-import { Bell, Clapperboard, Cpu, Film, KeyRound, Layers, LayoutGrid, Loader2, Plus, Server, Settings2, ShieldCheck, Sparkles, Wand2, type LucideIcon } from "lucide-react";
+import { Bell, Clapperboard, Cpu, Film, KeyRound, Layers, LayoutGrid, Loader2, Plus, Scale, Server, Settings2, ShieldCheck, Sparkles, Wand2, type LucideIcon } from "lucide-react";
import { useRouter } from "next/navigation";
import { createContext, lazy, Suspense, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
import { NAV } from "@/components/nav-items";
@@ -9,7 +9,7 @@ import { MediaThumb } from "@/components/studio/result-media";
import { CommandDialog, CommandEmpty, CommandGroup, CommandItem, CommandList } from "@/components/ui/command";
import { Kbd } from "@/components/ui/kbd";
import { Command as CommandPrimitive } from "cmdk";
-import { useEngineMode, useGenerations } from "@/lib/api";
+import { useEngineMode, useGenerations, useModelAccess } from "@/lib/api";
import type { Generation } from "@/lib/catalog/types";
import { indexEntries, KIND_LABELS, rankPalette, type PaletteEntry, type PaletteIndex, type PaletteKind } from "@/lib/command-search";
import { useModKey } from "@/lib/keys";
@@ -46,11 +46,18 @@ export function CommandPaletteProvider({ children }: { children: React.ReactNode
}
/** Settings sections the palette jumps to (ids in settings-form.tsx). */
-const SETTINGS: { id: string; label: string; icon: LucideIcon; keywords: string }[] = [
+const SETTINGS: { id: string; label: string; icon: LucideIcon; keywords: string; href?: string }[] = [
{ id: "cloud", label: "API keys", icon: KeyRound, keywords: "fal replicate higgsfield paid cloud connect" },
{ id: "comfyui", label: "ComfyUI server", icon: Server, keywords: "open source gpu url connect local" },
{ id: "engine", label: "Engine mode", icon: Cpu, keywords: "open source cloud both" },
{ id: "loras", label: "LoRAs", icon: Layers, keywords: "lora folder civitai key looks motions effects download licence" },
+ {
+ id: "models",
+ label: "Models & licences",
+ icon: Scale,
+ keywords: "licence license commercial non-commercial switch off turn on admin providers node packs allow block",
+ href: "/settings/models",
+ },
{ id: "text-ai", label: "Prompt enhancement", icon: Sparkles, keywords: "claude ollama enhancer llm" },
{ id: "notifications", label: "Notifications", icon: Bell, keywords: "browser done alerts" },
{ id: "security", label: "Password and API tokens", icon: ShieldCheck, keywords: "security sign in mcp token" },
@@ -65,7 +72,7 @@ const SETTING_ENTRIES: (PaletteEntry & { icon: LucideIcon })[] = SETTINGS.map((s
kind: "setting",
label: s.label,
hint: "Settings",
- href: `/settings#${s.id}`,
+ href: s.href ?? `/settings#${s.id}`,
keywords: s.keywords,
icon: s.icon,
}));
@@ -134,6 +141,7 @@ function PaletteBody({ onPick, onOpenRecent, onClose }: { onPick: (e: PaletteEnt
const query = q;
const dq = useDebounced(q.trim(), 200);
const mode = useEngineMode();
+ const access = useModelAccess();
// The apps, motions, effects and models load on first open (and stay for the session).
const index = useQuery({
queryKey: ["palette-index"],
@@ -141,7 +149,7 @@ function PaletteBody({ onPick, onOpenRecent, onClose }: { onPick: (e: PaletteEnt
staleTime: Infinity,
});
const recent = useGenerations({ q: dq || undefined, limit: 5, statuses: ["succeeded"] }, { keepPrevious: true });
- const entries = useMemo(() => [...PAGES, ...SETTING_ENTRIES, ...(index.data ? indexEntries(index.data, mode) : [])], [index.data, mode]);
+ const entries = useMemo(() => [...PAGES, ...SETTING_ENTRIES, ...(index.data ? indexEntries(index.data, mode, access) : [])], [index.data, mode, access]);
const groups = useMemo(() => rankPalette(entries, query), [entries, query]);
const recentItems = (recent.data ?? []).filter((g) => g.outputs[0]);
const searching = !!query.trim();
diff --git a/src/components/models-table.tsx b/src/components/models-table.tsx
index e7d4076a..31456a76 100644
--- a/src/components/models-table.tsx
+++ b/src/components/models-table.tsx
@@ -5,7 +5,9 @@ import { useSearchParams } from "next/navigation";
import { memo, Suspense, useDeferredValue, useEffect, useMemo, useRef, useState } from "react";
import { useProgressive } from "@/components/use-progressive";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
-import { useEngine } from "@/lib/api";
+import Link from "next/link";
+import { useEngine, useModelAccess } from "@/lib/api";
+import { offered } from "@/lib/model-access";
import type { Engine, MediaKind } from "@/lib/catalog/types";
import { enginesLabel, modelSearchText, type ModelRow } from "@/lib/model-rows";
import { cn } from "@/lib/utils";
@@ -115,11 +117,18 @@ export function ModelsTable({ models }: { models: ModelRow[] }) {
const [kind, setKind] = useState<MediaKind | "all">("all");
const [q, setQ] = useState("");
const term = useDeferredValue(q.trim().toLowerCase());
- const index = useMemo(() => models.map((m) => [m, modelSearchText(m)] as const), [models]);
+ // Settings → Models & licences: what is switched off leaves the list (an Original stays for the engine still on).
+ const access = useModelAccess();
+ const on = useMemo(() => (access ? models.filter((m) => offered(access, m.id)) : models), [models, access]);
+ const switchedOff = models.length - on.length;
+ const index = useMemo(() => on.map((m) => [m, modelSearchText(m)] as const), [on]);
const kinds = useMemo(() => [...new Set(models.map((m) => m.kind))], [models]);
const list = useMemo(
- () => index.filter(([m, text]) => (engine === "all" || m.engines.includes(engine)) && (kind === "all" || m.kind === kind) && (!term || text.includes(term))).map(([m]) => m),
- [index, engine, kind, term],
+ () =>
+ index
+ .filter(([m, text]) => (engine === "all" || (m.engines.includes(engine) && offered(access, m.id, engine))) && (kind === "all" || m.kind === kind) && (!term || text.includes(term)))
+ .map(([m]) => m),
+ [index, engine, kind, term, access],
);
// 40 rows in the page's HTML, the rest as you scroll.
const { shown, hasMore, moreFrom, sentinel, left } = useProgressive(list.length, `${engine}|${kind}|${term}`, 40, 60);
@@ -166,6 +175,15 @@ export function ModelsTable({ models }: { models: ModelRow[] }) {
{list.length} models
</span>
</div>
+ {switchedOff > 0 && (
+ <p className="text-[13px] text-muted-foreground">
+ {switchedOff} {switchedOff === 1 ? "model is" : "models are"} turned off in{" "}
+ <Link href="/settings/models" className="text-brand-text underline-offset-2 hover:underline">
+ Settings → Models &amp; licences
+ </Link>
+ .
+ </p>
+ )}
<div className="overflow-x-auto rounded-xl border">
<table className="w-full text-left text-[13px]">
<thead className="bg-muted/50 text-[12px] text-muted-foreground">
diff --git a/src/components/studio/catalog.tsx b/src/components/studio/catalog.tsx
index d4f99140..10bfb839 100644
--- a/src/components/studio/catalog.tsx
+++ b/src/components/studio/catalog.tsx
@@ -2,8 +2,9 @@
import { createContext, useContext, useEffect, useMemo, useState, useSyncExternalStore } from "react";
import { onEngine } from "@/lib/catalog/engines";
-import type { ModelDef, Preset } from "@/lib/catalog/types";
-import { useEngine } from "@/lib/api";
+import type { Engine, ModelDef, Preset } from "@/lib/catalog/types";
+import { useEngine, useModelAccess } from "@/lib/api";
+import { offered } from "@/lib/model-access";
import type { StudioCatalog } from "@/lib/studio-catalog";
import type { StudioConfig } from "./studio-context";
@@ -50,6 +51,8 @@ export interface CatalogApi {
presets: { motion: Preset[]; effect: Preset[] } | null;
/** True once the full catalog chunk has arrived. */
complete: boolean;
+ /** Whether Settings → Models & licences offers the model (on this engine): `models` leaves the others out. */
+ offered: (id: string, engine?: Engine) => boolean;
}
const Ctx = createContext<CatalogApi | null>(null);
@@ -65,6 +68,7 @@ export function CatalogProvider({ catalog, config, children }: { catalog?: Studi
// A Fuobe Original runs on both engines: the studio sees it as it runs on the engine switched to (its routes,
// its price or "Free"), so it is in both engines' model lists.
const [engine] = useEngine();
+ const access = useModelAccess();
// Studios rendered from client code (an element's page) have no server slice: compute it from the lazy chunk.
const [lazy, setLazy] = useState<StudioCatalog | null>(null);
useEffect(() => {
@@ -77,8 +81,11 @@ export function CatalogProvider({ catalog, config, children }: { catalog?: Studi
}, [catalog, config]);
const slice = catalog ?? lazy;
const value = useMemo<CatalogApi>(() => {
- const models = (slice?.models ?? []).map((m) => onEngine(m, engine));
- const index = new Map([...models, ...(slice?.lookup ?? [])].map((m) => [m.id, m]));
+ // Models switched off in Settings → Models & licences leave the lists (an Original, the engine it's off on); a
+ // lookup by id still finds them, so a generation that ran on one keeps its name.
+ const all = (slice?.models ?? []).map((m) => onEngine(m, engine));
+ const models = access ? all.filter((m) => offered(access, m.id, engine)) : all;
+ const index = new Map([...all, ...(slice?.lookup ?? [])].map((m) => [m.id, m]));
const view = (m: ModelDef | undefined) => (m ? onEngine(m, engine) : undefined);
return {
ready: !!slice,
@@ -87,7 +94,8 @@ export function CatalogProvider({ catalog, config, children }: { catalog?: Studi
getPreset: (id) => (config.preset?.id === id ? config.preset : fullCatalog?.getPreset(id)),
presets: fullCatalog ? { motion: fullCatalog.MOTIONS, effect: fullCatalog.EFFECTS } : null,
complete: !!fullCatalog,
+ offered: (id, e) => offered(access, id, e),
};
- }, [slice, fullCatalog, config.preset, engine]);
+ }, [slice, fullCatalog, config.preset, engine, access]);
return <Ctx.Provider value={value}>{children}</Ctx.Provider>;
}
diff --git a/src/components/studio/composer.tsx b/src/components/studio/composer.tsx
index ad1362db..a91a28e0 100644
--- a/src/components/studio/composer.tsx
+++ b/src/components/studio/composer.tsx
@@ -300,6 +300,18 @@ export function Composer({ docked }: { docked: boolean }) {
setDraft((d) => (d.modelId !== model.id ? {} : { modelId: m.id, params: { ...m.defaults, ...route, numOutputs: d.params.numOutputs, enhancePrompt: d.params.enhancePrompt }, ...lookCleared(model, m) }));
}, [engine, model, preset, config.defaultModels, setDraft, catalog]);
+ // Settings → Models & licences switched the model off (a default, a remembered pick, a Reuse, a link): the composer
+ // moves to the studio's default on this engine, else the first model of its list that is on, and says so. With
+ // none on, Generate says what to turn on (accessError).
+ const offModel = model && !catalog.offered(model.id, engine) ? model : undefined;
+ const fallback = offModel ? [config.defaultModels[engine], ...models.filter((m) => m.engine === engine).map((m) => m.id)].find((id) => !!id && catalog.offered(id, engine) && !!catalog.getModel(id)) : undefined;
+ useEffect(() => {
+ if (!offModel || !fallback || lockedModel) return;
+ const m = catalog.getModel(fallback)!;
+ setDraft((d) => (d.modelId !== offModel.id ? {} : { modelId: m.id, params: { ...m.defaults, numOutputs: d.params.numOutputs, enhancePrompt: d.params.enhancePrompt }, ...lookCleared(offModel, m) }));
+ toast(`${offModel.name} is turned off in Settings → Models & licences, so this uses ${m.name}`, { id: "model-access" });
+ }, [offModel, fallback, lockedModel, catalog, setDraft]);
+
// A camera motion or effect runs on its Original on this engine (Fuobe DoP): picking one moves the composer there,
// with the move's own settings (Focus Change: 6 s, silent). Another video model can be picked after it; it takes
// the move's words. A move whose cloud route is a partner model's words leaves the person's model as it is.
@@ -386,8 +398,9 @@ export function Composer({ docked }: { docked: boolean }) {
// A cloud-only install refuses open models, and with demo mode off nothing else runs it, so Generate says why.
const comfyMissing = !!config.comfyOnly && !!status && (engineMode === "cloud" || !status.providers.comfyui?.configured);
const comfyBlock = comfyMissing && model?.engine === "open" && (engineMode === "cloud" || status?.demoMode === "off") ? "Needs ComfyUI: see the note below" : null;
+ const accessError = offModel && (!fallback || lockedModel) ? `${offModel.name} is turned off in Settings → Models & licences` : null;
const engineError =
- (lockedModel && preset && !(engine === "open" ? preset.open : preset.cloud) ? `${preset.name} has no ${engine === "open" ? "open-source" : "cloud"} version yet` : null) ?? comfyBlock;
+ (lockedModel && preset && !(engine === "open" ? preset.open : preset.cloud) ? `${preset.name} has no ${engine === "open" ? "open-source" : "cloud"} version yet` : null) ?? accessError ?? comfyBlock;
let op: Operation | undefined;
let cost: number | null = null;
let planError: string | null = null;
diff --git a/src/lib/api.ts b/src/lib/api.ts
index a2d0005d..799e0ce8 100644
--- a/src/lib/api.ts
+++ b/src/lib/api.ts
@@ -27,6 +27,7 @@ import {
} from "./generation-stream";
import { cursorAfter, filterToSearch, type AssetUse, type FeedFilter, type Folder } from "./library";
import type { ShareCreated, ShareInfo, ShareListItem, SharePatch, ShareRequest } from "./share";
+import type { AccessSummary } from "./model-access";
export interface Asset {
id: string;
@@ -812,6 +813,8 @@ export interface StatusInfo {
cloudProvider: string;
/** The first-run guide was put away, or something the engine mode generates with was connected once. */
onboarded?: boolean;
+ /** Settings → Models & licences: what is switched off (absent while everything is on). */
+ access?: AccessSummary;
}
/** A connection test's answer (POST /api/providers/test). */
@@ -934,6 +937,16 @@ export function useEngineMode(): EngineMode {
return serverMode ?? cached;
}
+/**
+ * What Settings → Models & licences switched off, for pickers to leave out (src/lib/model-access.ts offered()).
+ * Undefined until hydrated and while everything is on; the server refuses an off model either way.
+ */
+export function useModelAccess(): AccessSummary | undefined {
+ const hydrated = useHydrated();
+ const access = useStatus().data?.access;
+ return hydrated ? access : undefined;
+}
+
export function useEngine(): [Engine, (e: Engine) => void, EngineMode] {
const mode = useEngineMode();
const engine = useSyncExternalStore(
diff --git a/src/lib/command-search.ts b/src/lib/command-search.ts
index e704dcb5..23fde64a 100644
--- a/src/lib/command-search.ts
+++ b/src/lib/command-search.ts
@@ -2,6 +2,7 @@
* The ⌘K palette's search (pure, so it's testable): a forgiving word match, and the matches grouped
* by kind, best first. The palette (src/components/command-palette.tsx) renders what this returns.
*/
+import { offered, type AccessSummary } from "./model-access";
export type PaletteKind = "page" | "setting" | "app" | "motion" | "effect" | "model" | "recent";
@@ -181,7 +182,7 @@ export interface PaletteModel {
* The palette's entries from the index, for one engine mode: with one engine locked in Settings, a
* preset needs a route on that engine and a model must be on it, as in the galleries and pickers.
*/
-export function indexEntries(index: PaletteIndex, mode: "both" | "cloud" | "open"): PaletteEntry[] {
+export function indexEntries(index: PaletteIndex, mode: "both" | "cloud" | "open", access?: AccessSummary): PaletteEntry[] {
const runs = (p: PalettePreset) => mode === "both" || p[mode];
const presets = (list: PalettePreset[], kind: "app" | "motion" | "effect", href: (id: string) => string) =>
list.filter(runs).map((p): PaletteEntry => ({ key: `${kind}:${p.id}`, kind, label: p.name, hint: p.category, href: href(p.id) }));
@@ -190,7 +191,8 @@ export function indexEntries(index: PaletteIndex, mode: "both" | "cloud" | "open
...presets(index.motions, "motion", (id) => `/video?preset=${id}`),
...presets(index.effects, "effect", (id) => `/video?preset=${id}`),
...index.models
- .filter((m) => mode === "both" || (m.engines ?? [m.engine]).includes(mode))
+ // Settings → Models & licences: a model switched off isn't offered here either.
+ .filter((m) => (mode === "both" || (m.engines ?? [m.engine]).includes(mode)) && offered(access, m.id, mode === "both" ? undefined : mode))
.map((m): PaletteEntry => {
const both = (m.engines?.length ?? 0) > 1;
return {
diff --git a/src/server/assist/agent.ts b/src/server/assist/agent.ts
index 7441e5b9..5a6100d3 100644
--- a/src/server/assist/agent.ts
+++ b/src/server/assist/agent.ts
@@ -28,6 +28,7 @@ import {
import type { Engine, Generation, MediaKind } from "@/lib/catalog/types";
import { db } from "../db";
import { getGeneration } from "../generations";
+import { offeredDefault } from "../model-access";
import { engineMode, getSetting } from "../settings";
import { getSkill } from "../skills";
import { readRef } from "../storage";
@@ -836,7 +837,8 @@ export function offlinePlan(message: string, preferred: Engine, hint?: SkillMeta
const aspect = /\b(vertical|portrait|9:16|reels?|tiktok|stories|story format)\b/.test(t) ? "9:16" : /\b(square|1:1)\b/.test(t) ? "1:1" : /\b(wide|landscape|16:9|widescreen)\b/.test(t) ? "16:9" : hint?.aspect;
const seconds = secondsAsked(t);
const withSound = /\b(with|plus|and) (sound|audio|sfx|sound effects)\b/.test(t);
- const pick = (d: { cloud: string; open: string }) => (engine === "open" && d.open ? d.open : d.cloud);
+ // A studio's default, or the next model that is on when Settings → Models & licences switched it off.
+ const pick = (d: { cloud: string; open: string }) => offeredDefault(engine === "open" && d.open ? d.open : d.cloud, engine === "open" && d.open ? "open" : "cloud")!;
const textModel = engine === "open" ? "oss-text-llm" : "text-llm";
const styled = (p: string) => (hint?.style ? `${p}. ${hint.style}` : p);
// The video settings a clip takes from the words: its length (one the model lists) and its own sound.
@@ -1015,7 +1017,7 @@ function latestStills(messages: MessageList): { stills: { url: string; g: Genera
/** Animate one picked still with the default video model. */
function animateTake(still: { url: string; g: Generation }, take: number, preferred: Engine, said: string): { tool: string; input: Record<string, unknown>; say: string } {
const engine = engineFor(preferred);
- const modelId = engine === "open" ? VIDEO_STUDIO.defaultModels.open : VIDEO_STUDIO.defaultModels.cloud;
+ const modelId = offeredDefault(engine === "open" ? VIDEO_STUDIO.defaultModels.open : VIDEO_STUDIO.defaultModels.cloud, engine)!;
const subject = (still.g.request.prompt ?? "").trim().replace(/[.\s]+$/, "") || "The picture";
const duration = fitDuration(modelId, secondsAsked(said.toLowerCase()));
return {
diff --git a/src/server/assist/tools.ts b/src/server/assist/tools.ts
index 3e3c3741..c40256b9 100644
--- a/src/server/assist/tools.ts
+++ b/src/server/assist/tools.ts
@@ -3,6 +3,7 @@ import type Anthropic from "@anthropic-ai/sdk";
import { nanoid } from "nanoid";
import { z } from "zod";
import { getModel, modelsFor } from "@/lib/catalog";
+import { offeredModels } from "../model-access";
import { dualEngine, runsOn } from "@/lib/catalog/engines";
import { OPERATION_LABELS, type ChainSlot, type GenerationRequest, type MediaKind, type ModelDef, type Operation } from "@/lib/catalog/types";
import { type PlannedJob, totalCost } from "@/lib/assist";
@@ -93,7 +94,8 @@ const searchModels = defineTool({
}),
async run({ kind, task, query }, ctx) {
const mode = engineMode();
- let list = modelsFor({ kind: kind as MediaKind, ops: task ? [task as Operation] : undefined, engine: mode === "both" ? "all" : mode });
+ // Only what Settings → Models & licences offers, each model with the routes that are on.
+ let list = offeredModels(modelsFor({ kind: kind as MediaKind, ops: task ? [task as Operation] : undefined, engine: mode === "both" ? "all" : mode }));
if (query) {
const words = query.toLowerCase().split(/\s+/).filter(Boolean);
const scored = list.map((m) => {
diff --git a/src/server/cinema-generate.ts b/src/server/cinema-generate.ts
index 91d75f7d..80ae5518 100644
--- a/src/server/cinema-generate.ts
+++ b/src/server/cinema-generate.ts
@@ -18,13 +18,14 @@ import { createGenerations, previewGeneration } from "./generations";
import { encodePng } from "./png";
import { engineMode, getSetting } from "./settings";
import { saveFile } from "./storage";
+import { isOffered } from "./model-access";
/**
* What this install can run right now (cloud fallbacks such as reading a take's first frame, the workflows it has, a
* camera LoRA that downloads from civitai, which fal gets only with the user's civitai key).
*/
export function cinemaContext(): CinemaContext {
- return { cloudAllowed: engineMode() !== "open", has: (id) => !!getModel(id), civitai: !!getSetting("civitaiKey") };
+ return { cloudAllowed: engineMode() !== "open", has: (id) => !!getModel(id) && isOffered(id), civitai: !!getSetting("civitaiKey") };
}
declare global {
diff --git a/src/server/model-access.ts b/src/server/model-access.ts
index ac6727ae..5a671015 100644
--- a/src/server/model-access.ts
+++ b/src/server/model-access.ts
@@ -1,6 +1,6 @@
import "server-only";
import { MODELS } from "@/lib/catalog";
-import { onEngine } from "@/lib/catalog/engines";
+import { onEngine, providerEngine } from "@/lib/catalog/engines";
import { libraryEntry, loraName } from "@/lib/catalog/loras";
import type { Engine, LoraRef, ModelDef, ModelRoute } from "@/lib/catalog/types";
import type { ManifestWorkflow } from "@/lib/comfy";
@@ -161,6 +161,20 @@ export function pickOffered(ids: (string | undefined)[], engine?: Engine): strin
throw new Error(first ? offReason(first) : `No model for this is turned on in ${ACCESS_PLACE}`);
}
+/**
+ * A default that is on, else the next model that is on and does the same job on this engine (same kind, an
+ * operation in common, not a hidden helper), else the default itself: a run of it then refuses, naming the switch
+ * to turn back on. Assist's own picks and the studios' defaults in /api/models go through it.
+ */
+export function offeredDefault(id: string | undefined, engine: Engine): string | undefined {
+ if (!id || isOffered(id, engine)) return id;
+ const own = MODELS.find((m) => m.id === id);
+ if (!own) return id;
+ const ops = new Set(onEngine(own, engine).routes.map((r) => r.op));
+ const next = MODELS.find((m) => !m.hidden && m.id !== id && m.kind === own.kind && isOffered(m.id, engine) && onEngine(offeredModel(m)!, engine).routes.some((r) => ops.has(r.op) && providerEngine(r.provider) === engine));
+ return next?.id ?? id;
+}
+
/** The summary the browser filters its pickers with (undefined while everything is on). */
export function offeredSummary(): AccessSummary | undefined {
return summarize(MODELS, readAccess(), factsOf);
diff --git a/src/server/photodump.ts b/src/server/photodump.ts
index 79d2f59f..10a0d9c0 100644
--- a/src/server/photodump.ts
+++ b/src/server/photodump.ts
@@ -25,6 +25,7 @@ import { createGenerations, getGeneration, pickOutput, previewGeneration } from
import { trashGenerations } from "./library";
import { higgsfieldKey } from "./providers/higgsfield";
import { engineMode } from "./settings";
+import { isOffered } from "./model-access";
/**
* Photodump / Instadump, Fashion Factory and Character Sheet runs: plan with the pure pack logic
@@ -81,7 +82,7 @@ export function deleteUserPack(id: string): boolean {
/** What this install can do, for the pure planners. */
export function planCaps(): PlanCaps {
- return { higgsfield: !!higgsfieldKey() && engineMode() !== "open", has: (id) => !!getModel(id) };
+ return { higgsfield: !!higgsfieldKey() && engineMode() !== "open", has: (id) => !!getModel(id) && isOffered(id) };
}
/** The engine a run uses: the one asked for, unless Settings locks the other. */
diff --git a/tests/model-access-listings.test.ts b/tests/model-access-listings.test.ts
new file mode 100644
index 00000000..1df52b52
--- /dev/null
+++ b/tests/model-access-listings.test.ts
@@ -0,0 +1,90 @@
+import fs from "node:fs";
+import os from "node:os";
+import path from "node:path";
+import { afterAll, beforeEach, describe, expect, it, vi } from "vitest";
+import { indexEntries } from "@/lib/command-search";
+import { paletteIndex } from "@/lib/palette-index";
+
+/**
+ * Settings → Models & licences in the places that list or pick models: GET /api/models (the CLI's list and the
+ * studios' defaults), /api/status (what the browser filters its pickers with), Assist's and MCP's search_models,
+ * the ⌘K palette, Assist's own picks, and POST /api/generations (the API refuses a model that is off).
+ */
+
+vi.mock("next/server", async (importOriginal) => ({ ...(await importOriginal<typeof import("next/server")>()), connection: async () => {} }));
+
+const dir = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-access-listings-"));
+process.env.FUOBE_DATA_DIR = dir;
+process.env.COMFYUI_URL = "http://127.0.0.1:9";
+process.env.OLLAMA_URL = "http://127.0.0.1:9";
+const { GET: listModels } = await import("@/app/api/models/route");
+const { GET: status } = await import("@/app/api/status/route");
+const { POST: postGeneration } = await import("@/app/api/generations/route");
+const { changeAccess } = await import("@/server/model-access");
+const tools = await import("@/server/assist/tools");
+const { offlinePlan } = await import("@/server/assist/agent");
+const { setSetting } = await import("@/server/settings");
+afterAll(() => fs.rmSync(dir, { recursive: true, force: true }));
+
+type Body = { defaults: Record<string, { cloud?: string; open?: string }>; items: { id: string; engines: string[] }[] };
+const models = async (query = "") => (await (await listModels(new Request(`http://localhost/api/models${query}`))).json()) as Body;
+
+beforeEach(() => {
+ changeAccess([{ kind: "reset" }]);
+ setSetting("engineMode", "both");
+ setSetting("demoMode", "on");
+});
+
+describe("Models & licences in listings and picks", () => {
+ it("lists only what is on, and a studio default that is off gives way to the next model that is on", async () => {
+ const before = await models("?kind=image");
+ expect(before.items.map((m) => m.id)).toContain("nano-banana-pro");
+ expect(before.defaults.image.cloud).toBe("nano-banana-pro");
+ changeAccess([{ kind: "model", id: "nano-banana-pro", on: false }]);
+ const after = await models("?kind=image");
+ expect(after.items.map((m) => m.id)).not.toContain("nano-banana-pro");
+ expect(after.defaults.image.cloud).toBeTruthy();
+ expect(after.defaults.image.cloud).not.toBe("nano-banana-pro");
+ // A whole licence class: the paid APIs. Fuobe Soul stays, on your GPU.
+ changeAccess([{ kind: "class", id: "paid-api", on: false }]);
+ const open = await models("?kind=image");
+ expect(open.items.every((m) => m.engines.every((e) => e === "open"))).toBe(true);
+ expect(open.items.find((m) => m.id === "fuobe-soul")?.engines).toEqual(["open"]);
+ });
+
+ it("tells the browser what is off through /api/status, and nothing while everything is on", async () => {
+ expect(((await (await status()).json()) as { access?: unknown }).access).toBeUndefined();
+ changeAccess([{ kind: "provider", id: "higgsfield", on: false }, { kind: "class", id: "research", on: false }]);
+ const body = (await (await status()).json()) as { access: { off: string[] } };
+ expect(body.access.off).toContain("oss-reactor");
+ expect(body.access.off.length).toBeGreaterThan(5);
+ });
+
+ it("leaves switched-off models out of Assist's and MCP's search_models", async () => {
+ const ids = async () => (JSON.parse((await tools.executeTool("search_models", { kind: "image" }, { engine: "cloud" })).content as string).models as { id: string }[]).map((m) => m.id);
+ expect(await ids()).toContain("nano-banana-pro");
+ changeAccess([{ kind: "model", id: "nano-banana-pro", on: false }]);
+ expect(await ids()).not.toContain("nano-banana-pro");
+ });
+
+ it("picks Assist's model past one that is off", () => {
+ const plan = () => (offlinePlan("a photo of a red bicycle", "cloud")!.input.jobs as { model_id: string }[])[0].model_id;
+ expect(plan()).toBe("nano-banana-pro");
+ changeAccess([{ kind: "model", id: "nano-banana-pro", on: false }]);
+ expect(plan()).not.toBe("nano-banana-pro");
+ });
+
+ it("leaves switched-off models out of the ⌘K palette", () => {
+ const index = paletteIndex();
+ const has = (access?: { off: string[] }) => indexEntries(index, "both", access).some((e) => e.key === "model:nano-banana-pro");
+ expect(has()).toBe(true);
+ expect(has({ off: ["nano-banana-pro"] })).toBe(false);
+ });
+
+ it("refuses a model that is off through the API, naming the switch", async () => {
+ changeAccess([{ kind: "class", id: "non-commercial", on: false }]);
+ const res = await postGeneration(new Request("http://localhost/api/generations?preview=1", { method: "POST", body: JSON.stringify({ feature: "image", modelId: "oss-flux1-dev", prompt: "a cat" }) }));
+ expect(res.status).toBe(422);
+ expect(((await res.json()) as { error: string }).error).toMatch(/^FLUX\.1 \[dev\] is turned off in Settings → Models & licences \(Non-commercial is switched off\)/);
+ });
+});