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
About & licences: every open model's licence, its catches, and the notices to show
Claudec79fb8559539
diff --git a/src/app/(studio)/settings/about/loading.tsx b/src/app/(studio)/settings/about/loading.tsxnew file mode 100644index 00000000..f803f1cf--- /dev/null+++ b/src/app/(studio)/settings/about/loading.tsx@@ -0,0 +1,5 @@+import { PageSkeleton } from "@/components/skeletons";++export default function Loading() {+ return <PageSkeleton title="About & licences" />;+}diff --git a/src/app/(studio)/settings/about/page.tsx b/src/app/(studio)/settings/about/page.tsxnew file mode 100644index 00000000..a67cbbc1--- /dev/null+++ b/src/app/(studio)/settings/about/page.tsx@@ -0,0 +1,125 @@+import fs from "node:fs/promises";+import path from "node:path";+import { ArrowLeft, ExternalLink } from "lucide-react";+import type { Metadata } from "next";+import Link from "next/link";+import { LicencesView } from "@/components/licences-view";+import { PageHeader, PageShell } from "@/components/page-shell";+import { MODELS } from "@/lib/catalog";+import type { Manifest } from "@/lib/comfy";+import { FUOBE_REPO } from "@/lib/connections";+import { buildLicenceList } from "@/lib/licences";++export const metadata: Metadata = { title: "About & licences" };++async function readJson<T>(...parts: string[]): Promise<T | null> {+ try {+ return JSON.parse(await fs.readFile(path.join(process.cwd(), ...parts), "utf8")) as T;+ } catch {+ return null;+ }+}++/** Fuobe's version and every open model's licence, from package.json, the ComfyUI manifest and the catalog. */+async function readAbout() {+ "use cache";+ const [pkg, manifest] = await Promise.all([readJson<{ version?: string }>("package.json"), readJson<Manifest & { comfyuiVersion?: string }>("workflows", "comfyui", "manifest.json")]);+ const workflows = manifest?.workflows ?? [];+ return {+ version: pkg?.version ?? "dev",+ comfyui: manifest?.comfyuiVersion,+ builtAt: manifest?.generatedAt?.slice(0, 10),+ workflowCount: workflows.length,+ list: buildLicenceList(+ MODELS.map((m) => ({ id: m.id, name: m.name, vendor: m.vendor, kind: m.kind, hidden: m.hidden, routes: m.routes.map((r) => ({ provider: r.provider, endpoint: r.endpoint })) })),+ workflows.map((w) => ({ id: w.id, title: w.title, capability: w.capability, license: w.license })),+ ),+ };+}++function Fact({ label, children }: { label: string; children: React.ReactNode }) {+ return (+ <div className="min-w-0">+ <dt className="text-[12px] text-muted-foreground">{label}</dt>+ <dd className="mt-0.5 text-[14px] [overflow-wrap:anywhere]">{children}</dd>+ </div>+ );+}++export default async function Page() {+ const about = await readAbout();+ const { list } = about;+ return (+ <PageShell>+ <Link href="/settings" className="mb-3 inline-flex items-center gap-1.5 rounded-md text-[13px] text-muted-foreground hover:text-foreground">+ <ArrowLeft className="size-3.5" /> Settings+ </Link>+ <PageHeader+ title="About & licences"+ description="Fuobe's code is open source. The open models it runs on your GPU each have their own licence: most allow commercial use, some don't, and a few leave out some countries. Paid models follow the terms of the provider you connect."+ />++ <dl className="grid grid-cols-1 gap-4 rounded-2xl border p-5 sm:grid-cols-2 lg:grid-cols-4">+ <Fact label="Fuobe">Version {about.version}</Fact>+ <Fact label="Source code">+ <a href={FUOBE_REPO} target="_blank" rel="noreferrer" className="inline-flex items-center gap-1 text-brand-text underline underline-offset-2">+ GitHub <ExternalLink className="size-3" aria-hidden />+ <span className="sr-only">(opens in a new tab)</span>+ </a>+ </Fact>+ <Fact label="Open engine">+ {about.workflowCount} ComfyUI workflows{about.comfyui ? `, built for ComfyUI ${about.comfyui}` : ""}+ {about.builtAt ? <span className="text-muted-foreground"> · {about.builtAt}</span> : null}+ </Fact>+ <Fact label="Paid models">fal.ai, Replicate and Higgsfield with your key: their terms and prices apply</Fact>+ </dl>++ {list.notices.length > 0 && (+ <section aria-labelledby="notices" className="mt-8">+ <h2 id="notices" className="text-[15px] font-semibold">+ Notices+ </h2>+ <p className="mt-1 text-[13px] text-muted-foreground">Some licences ask the app that runs their model to say so.</p>+ <ul className="mt-3 grid gap-2 sm:grid-cols-2">+ {list.notices.map((n) => (+ <li key={n.text} className="rounded-xl bg-muted/60 px-4 py-3">+ <p className="text-[15px] font-semibold">{n.text}</p>+ <p className="mt-0.5 text-[12px] text-muted-foreground [overflow-wrap:anywhere]">For {n.models.join(", ")}</p>+ </li>+ ))}+ </ul>+ </section>+ )}++ <section aria-labelledby="licences" className="mt-10">+ <h2 id="licences" className="font-heading text-[24px] leading-tight">+ Open model licences+ </h2>+ <p className="mt-1 mb-5 max-w-2xl text-[13px] text-muted-foreground">+ {list.counts.all} models and workflows: {list.counts.clear} allow commercial use, {list.counts.conditions} with conditions (revenue limits or use rules), {list.counts["non-commercial"]}{" "}+ non-commercial and {list.counts.territory} not available everywhere. Read the licence itself before you sell what you make; this list is a guide, not legal advice.+ </p>+ <LicencesView list={list} />+ </section>++ <section aria-labelledby="elsewhere" className="mt-10 border-t pt-6">+ <h2 id="elsewhere" className="text-[15px] font-semibold">+ Elsewhere+ </h2>+ <ul className="mt-2 list-disc space-y-1 pl-5 text-[13px] text-muted-foreground">+ <li>+ Models you pull into Ollama for Assist and prompt enhancement carry their own licences: <code className="font-mono text-[12px]">ollama show <model> --license</code>.+ </li>+ <li>The optional TRIBE v2 worker for the Virality page isn't bundled; its weights are CC BY-NC 4.0 (non-commercial).</li>+ <li>+ Each workflow's models, sizes and download links are on the{" "}+ <Link href="/workflows" className="text-brand-text underline underline-offset-2">+ Workflows+ </Link>{" "}+ page.+ </li>+ </ul>+ </section>+ </PageShell>+ );+}diff --git a/src/components/licences-view.tsx b/src/components/licences-view.tsxnew file mode 100644index 00000000..fee76962--- /dev/null+++ b/src/components/licences-view.tsx@@ -0,0 +1,159 @@+"use client";++import { Ban, CheckCircle2, Globe, Info, Search } from "lucide-react";+import { useDeferredValue, useState } from "react";+import { FLAG_LABEL, kindLabel, type LicenceFlag, type LicenceList, type LicenceRow } from "@/lib/licences";+import { cn } from "@/lib/utils";++type Filter = "all" | "clear" | LicenceFlag;++const FILTERS: { value: Filter; label: string }[] = [+ { value: "all", label: "All" },+ { value: "clear", label: "Commercial use OK" },+ { value: "conditions", label: FLAG_LABEL.conditions },+ { value: "non-commercial", label: FLAG_LABEL["non-commercial"] },+ { value: "territory", label: FLAG_LABEL.territory },+];++const chip = (active: boolean) =>+ cn(+ "h-8 shrink-0 rounded-full px-3 text-[13px] font-medium whitespace-nowrap text-muted-foreground transition-colors hover:bg-accent",+ active && "bg-secondary text-foreground",+ );++const FLAG_STYLE: Record<LicenceFlag, { icon: typeof Ban; tone: string; fill: string }> = {+ "non-commercial": { icon: Ban, tone: "text-destructive", fill: "bg-destructive/10 dark:bg-destructive/20" },+ territory: { icon: Globe, tone: "text-warning", fill: "bg-warning/15" },+ conditions: { icon: Info, tone: "text-muted-foreground", fill: "bg-secondary" },+};++const badge = "inline-flex h-5 shrink-0 items-center gap-1 rounded-full px-2 text-[11px] font-medium whitespace-nowrap text-foreground [&>svg]:size-3";++function FlagBadge({ row }: { row: LicenceRow }) {+ if (!row.flags.length)+ return (+ <span className={cn(badge, "bg-success/12")}>+ <CheckCircle2 className="text-success" aria-hidden /> Commercial use OK+ </span>+ );+ return (+ <>+ {row.flags.map((f) => {+ const { icon: Icon, tone, fill } = FLAG_STYLE[f];+ return (+ <span key={f} className={cn(badge, fill)}>+ <Icon className={tone} aria-hidden /> {f === "territory" && row.excludes ? `Not in ${row.excludes}` : FLAG_LABEL[f]}+ </span>+ );+ })}+ </>+ );+}++function Row({ row }: { row: LicenceRow }) {+ return (+ <li className="flex flex-col gap-1.5 py-3.5 sm:flex-row sm:items-start sm:gap-4">+ <div className="min-w-0 flex-1">+ <p className="text-[14px] font-medium [overflow-wrap:anywhere]">{row.name}</p>+ <p className="text-[12px] text-muted-foreground">+ {row.inCatalog ? `${row.by} · ` : ""}+ {kindLabel(row.kind)}+ </p>+ {row.licences.map((l) => (+ <p key={l} className="mt-1 text-[12px] leading-relaxed text-muted-foreground [overflow-wrap:anywhere]">+ {l}+ </p>+ ))}+ </div>+ <div className="flex flex-wrap gap-1.5 sm:max-w-[45%] sm:justify-end">+ <FlagBadge row={row} />+ {row.notices.map((n) => (+ <span key={n} className="inline-flex h-5 items-center rounded-full border px-2 text-[11px] font-medium whitespace-nowrap">+ Shows “{n}”+ </span>+ ))}+ </div>+ </li>+ );+}++function matches(row: LicenceRow, filter: Filter, q: string): boolean {+ if (filter === "clear" ? row.flags.length > 0 : filter !== "all" && !row.flags.includes(filter)) return false;+ if (!q) return true;+ return [row.name, row.by, row.kind, ...row.licences].some((s) => s.toLowerCase().includes(q));+}++/** The licence list with its filters: what's free to use commercially, and what isn't. */+export function LicencesView({ list }: { list: LicenceList }) {+ const [filter, setFilter] = useState<Filter>("all");+ const [query, setQuery] = useState("");+ const q = useDeferredValue(query.trim().toLowerCase());+ const shown = list.rows.filter((r) => matches(r, filter, q));+ const catalog = shown.filter((r) => r.inCatalog);+ const library = shown.filter((r) => !r.inCatalog);+ const count = (f: Filter) => (f === "all" ? list.counts.all : list.counts[f]);++ return (+ <div className="space-y-4">+ <div className="flex flex-col gap-2 lg:flex-row lg:items-center">+ <div className="relative w-full lg:w-72">+ <Search className="pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground" />+ <input+ type="search"+ value={query}+ onChange={(e) => setQuery(e.target.value)}+ placeholder="Search models or licences"+ aria-label="Search models or licences"+ className="h-9 w-full rounded-full border bg-background pr-3 pl-9 text-[14px] outline-none placeholder:text-subtle-foreground focus:border-primary focus:ring-4 focus:ring-brand-faint"+ />+ </div>+ <div role="group" aria-label="Filter by licence" className="flex min-w-0 flex-wrap items-center gap-1">+ {FILTERS.map((f) => (+ <button key={f.value} type="button" aria-pressed={filter === f.value} className={chip(filter === f.value)} onClick={() => setFilter(f.value)}>+ {f.label} <span className="ml-0.5 tabular-nums opacity-70">{count(f.value)}</span>+ </button>+ ))}+ </div>+ </div>++ <p className="sr-only" aria-live="polite">+ {shown.length} models shown+ </p>+ {!shown.length && <p className="py-8 text-center text-[13px] text-muted-foreground">Nothing matches. Try another word or filter.</p>}++ {catalog.length > 0 && (+ <section aria-labelledby="lic-models">+ <h2 id="lic-models" className="text-[15px] font-semibold">+ Open models in Fuobe's studios <span className="font-normal text-muted-foreground tabular-nums">· {catalog.length}</span>+ </h2>+ <ul className="divide-y">+ {catalog.map((r) => (+ <Row key={r.id} row={r} />+ ))}+ </ul>+ </section>+ )}+ {library.length > 0 && (+ <section aria-labelledby="lic-library" className="pt-4">+ <h2 id="lic-library" className="text-[15px] font-semibold">+ Also in the workflow library <span className="font-normal text-muted-foreground tabular-nums">· {library.length}</span>+ </h2>+ <p className="mt-1 text-[12px] text-muted-foreground">Workflows ready on your ComfyUI that no studio runs yet, or alternatives to the ones above.</p>+ <ul className="divide-y">+ {library.map((r) => (+ <Row key={r.id} row={r} />+ ))}+ </ul>+ </section>+ )}++ {filter === "all" && !q && list.noWeights.length > 0 && (+ <p className="border-t pt-4 text-[12px] leading-relaxed text-muted-foreground">+ <span className="font-medium text-foreground">No model weights:</span> {list.noWeights.join(", ")}+ {list.noWeightsLibrary > 0 ? `, and ${list.noWeightsLibrary} more library workflows` : ""}. They run on ComfyUI's own nodes (GPL-3.0, like ComfyUI) and+ FFmpeg.+ </p>+ )}+ </div>+ );+}diff --git a/src/components/security-settings.tsx b/src/components/security-settings.tsxindex fc6bf938..5b9a4677 100644--- a/src/components/security-settings.tsx+++ b/src/components/security-settings.tsx@@ -97,7 +97,7 @@ function McpSnippet({ token, needsToken }: { token: string | null; needsToken: b<div className="space-y-1.5 sm:w-[36rem] sm:max-w-full"><p className="text-[12px] font-medium">Connect an agent over MCP</p><div className="flex items-center gap-2 rounded-lg bg-muted px-2.5 py-2">- <code className="min-w-0 flex-1 overflow-x-auto font-mono text-[11px] whitespace-nowrap">{cmd}</code>+ <code tabIndex={0} aria-label="MCP command" className="min-w-0 flex-1 overflow-x-auto rounded-sm font-mono text-[11px] whitespace-nowrap outline-none focus-visible:ring-2 focus-visible:ring-ring">{cmd}</code><buttontype="button"onClick={() => void copyWithToast(cmd)}diff --git a/src/lib/licences.ts b/src/lib/licences.tsnew file mode 100644index 00000000..82f2f84b--- /dev/null+++ b/src/lib/licences.ts@@ -0,0 +1,190 @@+/*+ * The About & licences page: the licence of every open model Fuobe can run, from the ComfyUI+ * manifest's `license` field and the catalog's open models, with the catches a person should+ * know before using the results commercially (non-commercial, countries excluded, conditions)+ * and the notices some licences ask the app to show ("Built with DINOv3").+ *+ * Licence texts follow the manifest's convention: NON-COMMERCIAL in capitals when the weights+ * (or a node pack's code) may not be used commercially, "territory EXCLUDES …" for countries a+ * licence leaves out, and `show "…"` for a notice the app must display. A lower-case mention+ * ("Base/Large are CC-BY-NC, keep the small one") describes a variant Fuobe does not use.+ */++export type LicenceFlag = "non-commercial" | "territory" | "conditions";++/** The parts of a catalog model the list needs (the page passes ModelDefs). */+export interface LicenceModelInput {+ id: string;+ name: string;+ vendor: string;+ kind: string;+ hidden?: boolean;+ routes: { provider: string; endpoint: string }[];+}++/** The parts of a manifest workflow the list needs. */+export interface LicenceWorkflowInput {+ id: string;+ title: string;+ capability: string;+ license?: string;+}++export interface LicenceRow {+ /** The model id, or the workflow id for a workflow no model uses yet. */+ id: string;+ name: string;+ /** The vendor, or "Workflow library" for a workflow no studio uses yet. */+ by: string;+ kind: string;+ workflows: string[];+ /** Distinct licence texts of its workflows. */+ licences: string[];+ flags: LicenceFlag[];+ /** Who a territory-restricted licence leaves out ("the EU, UK and South Korea"). */+ excludes?: string;+ notices: string[];+ /** True when a studio, app or helper step runs it; false for a workflow only in the library. */+ inCatalog: boolean;+}++export interface LicenceList {+ rows: LicenceRow[];+ /** Catalog tools that run on ComfyUI's own nodes, with no model weights. */+ noWeights: string[];+ /** Library workflows with no model weights that no studio uses yet. */+ noWeightsLibrary: number;+ /** Each notice and the models that need it. */+ notices: { text: string; models: string[] }[];+ counts: { all: number; clear: number } & Record<LicenceFlag, number>;+}++/**+ * Licences of the workflows whose manifest entries predate the `license` field (rounds 1–2),+ * from docs/research/comfyui-oss.md and the model cards. First match wins.+ */+export const EARLIER_LICENCES: [RegExp, string][] = [+ [/^flux1-schnell/, "Apache-2.0 (FLUX.1 [schnell])"],+ [+ /^flux1-(dev|krea|kontext|fill)/,+ "FLUX.1 [dev] Non-Commercial License: NON-COMMERCIAL (outputs may be used commercially per BFL's terms; running the model in production needs a BFL commercial licence)",+ ],+ [/^flux2-dev/, "FLUX [dev] Non-Commercial License (FLUX.2 [dev]): NON-COMMERCIAL"],+ [/^qwen-image/, "Apache-2.0 (Qwen-Image 2512 / Qwen-Image-Edit, Lightning LoRAs, Qwen2.5-VL text encoder)"],+ [/^z-image/, "Apache-2.0 (Z-Image Turbo)"],+ [/^hidream-i1/, 'MIT (HiDream-I1); its Llama 3.1 8B text encoder is under the Llama 3.1 Community License (show "Built with Llama")'],+ [/^sdxl/, "CreativeML OpenRAIL++-M (commercial use allowed, with use-based restrictions)"],+ [/esrgan/, "BSD-3-Clause (Real-ESRGAN x4plus)"],+ [/seedvr2/, "Apache-2.0 (SeedVR2)"],+ [/^bg-remove-birefnet/, "MIT (BiRefNet)"],+ [/^bg-remove-rmbg/, "BEN2 weights MIT (the pack's default); RMBG-2.0 in the same pack is CC-BY-NC-4.0 (non-commercial), keep BEN2; ComfyUI-RMBG code GPL-3.0"],+ [/^face-swap-reactor/, "inswapper_128 weights (InsightFace): NON-COMMERCIAL, research use only; ReActor node MIT; GFPGAN Apache-2.0"],+ [/^wan22-i2v-14b-lora/, "Apache-2.0 (Wan 2.2); a LoRA you add carries its own licence"],+ [/^wan-animate/, "Apache-2.0 (Wan Animate 2, lightx2v)"],+ [/^wan22-/, "Apache-2.0 (Wan 2.2, umT5, lightx2v)"],+ [/^hunyuan15/, "Tencent Hunyuan Community License (territory EXCLUDES the EU, UK and South Korea)"],+ [/^ltx2/, "LTX-2.x Community License (free, commercial use included, below US$10M annual revenue; a paid licence above); Gemma 3 text encoder under the Gemma Terms of Use"],+ [/^infinitetalk/, "Apache-2.0 (InfiniteTalk, Wan 2.1, lightx2v)"],+ [/^interpolate-film/, "Apache-2.0 (FILM)"],+ [/^interpolate-rife/, "MIT (RIFE)"],+ [/^music-ace-step/, "Apache-2.0 (ACE-Step 1.5)"],+ [/^v2a-mmaudio/, "CC-BY-NC-4.0 (MMAudio weights: NON-COMMERCIAL)"],+ [/^selftest-/, "n/a (no model; ComfyUI core nodes)"],+];++export const UNKNOWN_LICENCE = "Not recorded yet: check the model card before using it commercially";++/** A workflow's licence: the manifest's, else the earlier table's, else unknown. */+export function workflowLicence(wf: Pick<LicenceWorkflowInput, "id" | "license">): string {+ return wf.license?.trim() || EARLIER_LICENCES.find(([re]) => re.test(wf.id))?.[1] || UNKNOWN_LICENCE;+}++/** What a licence text means for using the results: its flags, the countries it leaves out, its notices. */+export function licenceTerms(text: string): { flags: LicenceFlag[]; excludes?: string; notices: string[]; noWeights: boolean } {+ const noWeights = /^(n\/a|no model)\b/i.test(text.trim());+ const nonCommercial = /NON-COMMERCIAL/.test(text) || /^CC-BY-NC/.test(text.trim());+ const excludes = /\bEXCLUDES\s+([^);]+)/.exec(text)?.[1].trim();+ const conditional = /Community License|OpenRAIL|Model Use License|CogVideoX License|SAM License|DINOv3 License|Terms of Use|free below|below US\$/i.test(text);+ const flags: LicenceFlag[] = [];+ if (nonCommercial) flags.push("non-commercial");+ if (excludes) flags.push("territory");+ if (conditional && !nonCommercial && !excludes) flags.push("conditions");+ const notices = [...text.matchAll(/show (?:a |the )?"([^"]+)"/g)].map((m) => m[1]);+ return { flags, excludes, notices, noWeights };+}++/** Workflow ids an endpoint names: one id, or a family (`video-concat-{n}`). */+function endpointIds(endpoint: string, workflows: LicenceWorkflowInput[]): string[] {+ if (!endpoint.includes("{")) return [endpoint];+ const re = new RegExp(`^${endpoint.replace(/[.*+?^$()|[\]\\]/g, "\\$&").replace(/\{[^}]+\}/g, "\\d+")}$`);+ return workflows.filter((w) => re.test(w.id)).map((w) => w.id);+}++function rowFor(base: Omit<LicenceRow, "licences" | "flags" | "excludes" | "notices">, licences: string[]): LicenceRow & { noWeights: boolean } {+ const terms = licences.map(licenceTerms);+ const flags = (["non-commercial", "territory", "conditions"] as const).filter((f) => terms.some((t) => t.flags.includes(f)));+ return {+ ...base,+ licences,+ // A row with a stricter catch doesn't also say "conditions".+ flags: flags.includes("conditions") && flags.length > 1 ? flags.filter((f) => f !== "conditions") : flags,+ excludes: terms.find((t) => t.excludes)?.excludes,+ notices: [...new Set(terms.flatMap((t) => t.notices))],+ noWeights: terms.every((t) => t.noWeights),+ };+}++/**+ * Every open model and its licence: one row per catalog model that runs on ComfyUI (in catalog+ * order), then the library's workflows no model uses yet. Tools with no weights are listed by+ * name only; ComfyUI's self-tests are left out.+ */+export function buildLicenceList(models: LicenceModelInput[], workflows: LicenceWorkflowInput[]): LicenceList {+ const byId = new Map(workflows.map((w) => [w.id, w]));+ const used = new Set<string>();+ const rows: LicenceRow[] = [];+ const noWeights: string[] = [];+ let noWeightsLibrary = 0;+ const add = (r: LicenceRow & { noWeights: boolean }) => {+ const { noWeights: none, ...row } = r;+ if (!none) rows.push(row);+ else if (row.inCatalog) noWeights.push(row.name);+ else noWeightsLibrary++;+ };++ for (const m of models) {+ const ids = [...new Set(m.routes.filter((r) => r.provider === "comfyui").flatMap((r) => endpointIds(r.endpoint, workflows)))];+ if (!ids.length || ids.every((id) => id.startsWith("selftest-"))) continue;+ ids.forEach((id) => used.add(id));+ const licences = [...new Set(ids.map((id) => workflowLicence(byId.get(id) ?? { id })))];+ add(rowFor({ id: m.id, name: m.name, by: m.vendor, kind: m.kind, workflows: ids, inCatalog: true }, licences));+ }+ for (const w of workflows) {+ if (used.has(w.id) || w.id.startsWith("selftest-")) continue;+ add(rowFor({ id: w.id, name: w.title, by: "Workflow library", kind: w.capability, workflows: [w.id], inCatalog: false }, [workflowLicence(w)]));+ }++ const notices = new Map<string, string[]>();+ for (const r of rows) for (const n of r.notices) notices.set(n, [...(notices.get(n) ?? []), r.name]);+ const count = (f: LicenceFlag) => rows.filter((r) => r.flags.includes(f)).length;+ return {+ rows,+ noWeights: [...new Set(noWeights)],+ noWeightsLibrary,+ notices: [...notices].map(([text, names]) => ({ text, models: names })),+ counts: { all: rows.length, clear: rows.filter((r) => !r.flags.length).length, "non-commercial": count("non-commercial"), territory: count("territory"), conditions: count("conditions") },+ };+}++const KIND_LABEL: Record<string, string> = { image: "Image", video: "Video", audio: "Audio", text: "Text", model3d: "3D" };++/** A model's media kind, or a library workflow's capability, in words. */+export function kindLabel(kind: string): string {+ return KIND_LABEL[kind] ?? kind.replace(/-/g, " ").replace(/^\w/, (c) => c.toUpperCase());+}++export const FLAG_LABEL: Record<LicenceFlag, string> = {+ "non-commercial": "Non-commercial",+ territory: "Not everywhere",+ conditions: "Conditions apply",+};diff --git a/tests/licences.test.ts b/tests/licences.test.tsnew file mode 100644index 00000000..b0541cb0--- /dev/null+++ b/tests/licences.test.ts@@ -0,0 +1,81 @@+import fs from "node:fs";+import path from "node:path";+import { describe, expect, it } from "vitest";+import { MODELS } from "@/lib/catalog";+import type { Manifest } from "@/lib/comfy";+import { buildLicenceList, licenceTerms, UNKNOWN_LICENCE, workflowLicence } from "@/lib/licences";++/** The About & licences page (R4-53): every open model's licence, its catches and notices. */++const manifest = JSON.parse(fs.readFileSync(path.join(process.cwd(), "workflows", "comfyui", "manifest.json"), "utf8")) as Manifest;+const wf = (id: string) => manifest.workflows.find((w) => w.id === id) ?? { id };+const terms = (id: string) => licenceTerms(workflowLicence(wf(id)));++describe("licences", () => {+ it("knows the licence of every workflow in the library", () => {+ const unknown = manifest.workflows.filter((w) => workflowLicence(w) === UNKNOWN_LICENCE).map((w) => w.id);+ expect(unknown).toEqual([]);+ });++ it("flags non-commercial weights and code, but not a variant Fuobe keeps away from", () => {+ for (const id of ["v2a-mmaudio", "style-ref-uso-flux1", "captions-whisper-burnin", "flux1-dev-t2i", "flux2-dev-t2i", "face-swap-reactor", "flux1-kontext-dev-edit"]) {+ expect(terms(id).flags, id).toContain("non-commercial");+ }+ // "DA3-LARGE / GIANT are CC-BY-NC, do not swap them in": the graph uses the Apache-2.0 one.+ for (const id of ["video-depth-da3", "video-depth-vda-small", "bg-remove-rmbg", "z-image-turbo-t2i", "wan22-t2v-14b"]) {+ expect(terms(id).flags, id).not.toContain("non-commercial");+ }+ });++ it("reads every capitalised or leading NC mention in the manifest as non-commercial", () => {+ // Any other lower-case mention must name a variant the graph doesn't use; list it here when one is added.+ const variants = new Set(["video-depth-da3", "video-depth-vda-small", "bg-remove-rmbg"]);+ for (const w of manifest.workflows) {+ const text = workflowLicence(w);+ if (!/non-commercial|CC-BY-NC/i.test(text) || variants.has(w.id)) continue;+ expect(licenceTerms(text).flags, w.id).toContain("non-commercial");+ }+ });++ it("names the countries a licence leaves out, and the conditions of community licences", () => {+ expect(terms("hunyuan15-t2v-720p")).toMatchObject({ flags: ["territory"], excludes: "the EU, UK and South Korea" });+ expect(terms("sfx-hunyuan-foley").flags).toEqual(["territory"]);+ for (const id of ["ltx25-t2v", "style-ref-krea2", "sfx-stable-audio-3-small", "tts-indextts2", "sdxl-t2i"]) expect(terms(id).flags, id).toEqual(["conditions"]);+ expect(terms("bg-remove-birefnet").flags).toEqual([]);+ expect(terms("video-trim")).toMatchObject({ flags: [], noWeights: true });+ });++ it("finds the notices a licence asks the app to show", () => {+ expect(terms("image-to-splat-triposplat").notices).toEqual(["Built with DINOv3"]);+ expect(terms("hidream-i1-dev-t2i").notices).toEqual(["Built with Llama"]);+ expect(licenceTerms('MIT; the app must show a "Built with X" notice').notices).toEqual(["Built with X"]);+ });++ it("lists every open catalog model once, in or out of the weights list", () => {+ const list = buildLicenceList(MODELS, manifest.workflows);+ const open = MODELS.filter((m) => m.routes.some((r) => r.provider === "comfyui") && !m.id.startsWith("oss-selftest"));+ const listed = new Set([...list.rows.filter((r) => r.inCatalog).map((r) => r.name), ...list.noWeights]);+ for (const m of open) expect(listed.has(m.name), m.id).toBe(true);+ expect(list.rows.find((r) => r.id === "oss-flux2-dev")).toMatchObject({ workflows: ["flux2-dev-t2i", "flux2-dev-multiref"], flags: ["non-commercial"] });+ // Join clips names a family of workflows (video-concat-{n}); none of them has weights.+ expect(list.noWeights).toContain("Join clips");+ // Library workflows without weights are only counted (their titles are long descriptions).+ expect(list.noWeights.every((n) => MODELS.some((m) => m.name === n))).toBe(true);+ expect(list.noWeightsLibrary).toBeGreaterThan(0);+ expect(list.rows.some((r) => r.id.startsWith("selftest"))).toBe(false);+ // Workflows no studio uses yet are listed after the catalog's models.+ const firstLibrary = list.rows.findIndex((r) => !r.inCatalog);+ expect(list.rows.slice(firstLibrary).every((r) => !r.inCatalog)).toBe(true);+ expect(list.counts.all).toBe(list.rows.length);+ expect(list.counts.clear + list.counts["non-commercial"] + list.counts.territory + list.counts.conditions).toBeGreaterThanOrEqual(list.rows.length);+ });++ it("collects notices with the models that need them", () => {+ const list = buildLicenceList(MODELS, manifest.workflows);+ expect(list.notices.find((n) => n.text === "Built with Llama")?.models).toEqual(["HiDream-I1 Dev"]);+ expect(list.notices.find((n) => n.text === "Built with DINOv3")?.models.length).toBeGreaterThan(0);+ // No TripoSplat, no DINOv3 notice.+ const without = buildLicenceList(MODELS, manifest.workflows.filter((w) => !/triposplat/.test(w.id)));+ expect(without.notices.some((n) => n.text === "Built with DINOv3")).toBe(false);+ });+});