import type { Metadata } from 'next';
import Link from 'next/link';
import { CompareButton } from '@/components/compare/compare-button';
import { CompareTrayBar } from '@/components/compare/compare-tray-bar';
import { BTN_GHOST, CTRL, Field, FitCell, LicenceLegend, LicencePerms, Methodology, RankChips, SortTh } from '@/components/intelligence/bits';
import { DataStrip, type StripItem, TerminalLayout } from '@/components/layout/terminal';
import { Chip, Estimated, OpennessBadge } from '@/components/ui/badges';
import { DataTable, EmptyRow, Td, Th } from '@/components/ui/data-table';
import { EntityLink } from '@/components/ui/entity';
import { Pagination, withParams } from '@/components/ui/pagination';
import { Note, PageHeader, Section } from '@/components/ui/section';
import { EmptyState, Unavailable } from '@/components/ui/unavailable';
import { WatchButton } from '@/components/watchlist/watch-button';
import { intel, safe } from '@/lib/api';
import { fmtDate, fmtInt, fmtParams, fmtTokens, fmtUsdPerM, num } from '@/lib/format';
import { OPENNESS_LABELS, routes, SITE_NAME, SITE_URL } from '@/lib/site';
import type { OpenItem } from '@/lib/types';
export const revalidate = 300;
type SP = Record;
const LIMIT = 50;
const SORTS = ['rank', 'release', 'params', 'context', 'downloads', 'name'] as const;
type Sort = (typeof SORTS)[number];
const SORT_LABELS: Record = { rank: 'Best benchmark rank', release: 'Release date', params: 'Parameters', context: 'Context window', downloads: 'Downloads', name: 'Name' };
const KEYS = ['sort', 'license', 'min_params', 'max_params', 'min_context', 'modality', 'days', 'openness', 'offset'] as const;
const CATS = ['open-source', 'open-weights', 'restricted-weights'] as const;
const CAT_COLOR: Record = { 'open-source': 'var(--positive)', 'open-weights': 'var(--series-1)', 'restricted-weights': 'var(--warning)', proprietary: 'var(--ink-3)' };
function parseScale(v: string | undefined): number | undefined {
if (!v) return undefined;
const m = /^\s*([\d.]+)\s*([kmbt])?\s*$/i.exec(v);
if (!m) return undefined;
const mult = { k: 1e3, m: 1e6, b: 1e9, t: 1e12 }[(m[2] ?? '').toLowerCase() as 'k' | 'm' | 'b' | 't'] ?? 1;
const n = Number(m[1]);
return Number.isFinite(n) ? Math.round(n * mult) : undefined;
}
function pick(sp: SP) {
const cur: Record = {};
for (const k of KEYS) if (sp[k]) cur[k] = sp[k];
const sort: Sort = (SORTS as readonly string[]).includes(cur.sort ?? '') ? (cur.sort as Sort) : 'rank';
return { cur, sort, offset: Math.max(0, Number(cur.offset) || 0) };
}
const TITLE = 'Open Model Frontier — downloadable AI models by licence, size, context and rank';
const DESC = 'Every canonical model whose weights can be downloaded — open source, open weights, restricted weights — with its licence permissions (commercial use, redistribution, derivatives, hosting), parameters, context, release date, best benchmark ranks, providers and an estimated fit on 64 GB / 128 GB machines. Measurable openness dimensions, no ideological score.';
export async function generateMetadata({ searchParams }: { searchParams: Promise }): Promise {
const { cur } = pick(await searchParams);
const filtered = Object.keys(cur).some((k) => k !== 'sort');
return { title: TITLE, description: DESC, alternates: { canonical: routes.open() }, openGraph: { title: `${TITLE} | ${SITE_NAME}`, description: DESC, url: `${SITE_URL}${routes.open()}`, type: 'website', siteName: SITE_NAME }, twitter: { card: 'summary_large_image', title: TITLE, description: DESC }, robots: filtered ? { index: false, follow: true } : undefined };
}
export default async function OpenPage({ searchParams }: { searchParams: Promise }) {
const sp = await searchParams;
const { cur, sort, offset } = pick(sp);
const [res, meth] = await Promise.all([safe(intel.open({ sort, license: cur.license, min_params: parseScale(cur.min_params), max_params: parseScale(cur.max_params), min_context: parseScale(cur.min_context), modality: cur.modality, days: cur.days, openness: cur.openness, limit: LIMIT, offset })), safe(intel.methodology())]);
const href = (patch: Record) => withParams('/open', cur, patch);
const defs = meth?.openness?.definitions ?? {};
const labels: Record = { ...OPENNESS_LABELS, 'restricted-weights': 'Restricted weights', ...(meth?.openness?.labels ?? {}) };
const byCat = res?.summary?.by_category ?? {};
const catTotal = Object.values(byCat).reduce((n, v) => n + (num(v) ?? 0), 0);
const items: OpenItem[] = res?.items ?? [];
const filterCount = Object.keys(cur).filter((k) => k !== 'sort' && k !== 'offset').length;
const licences = res?.summary?.by_license_top ?? [];
const strip: StripItem[] = [
...CATS.map((c) => ({ label: labels[c] ?? c, value: fmtInt(byCat[c] ?? 0), definition: defs[c], href: href({ openness: c, offset: undefined }) })),
{ label: 'Downloadable total', value: fmtInt(res?.total), definition: res?.note ?? 'Universe = canonical models whose weights can be downloaded.' },
{ label: 'New in 30 days', value: fmtInt(res?.summary?.new_30d), definition: 'Downloadable models with a release date inside the last 30 days (release_date claim; models without one are not counted).', href: href({ days: 30, offset: undefined }) },
];
// licence permission matrix over the rows on this page (measurable: each licence's stated permissions)
const PERMS: { key: 'commercial_use' | 'redistribution' | 'derivatives' | 'hosting'; label: string }[] = [
{ key: 'commercial_use', label: 'Commercial use' },
{ key: 'redistribution', label: 'Redistribution' },
{ key: 'derivatives', label: 'Derivatives' },
{ key: 'hosting', label: 'Hosting' },
];
const matrix = CATS.map((c) => {
const rows = items.filter((it) => it.dimensions?.openness === c);
return {
cat: c,
n: rows.length,
cells: PERMS.map((p) => {
let yes = 0;
let no = 0;
let unk = 0;
for (const it of rows) {
const l = it.licence;
if (!l || l.key === null) {
unk++;
continue;
}
const v = p.key === 'hosting' ? (l.hosting_restrictions === null || l.hosting_restrictions === undefined ? null : !l.hosting_restrictions) : l[p.key];
if (v === true) yes++;
else if (v === false) no++;
else unk++;
}
return { yes, no, unk };
}),
};
});
const filters = (
);
const inspector = (
Openness categories
{(meth?.openness?.categories ?? [...CATS, 'proprietary']).map((c) => (
{labels[c] ?? c}
{defs[c] ?? '—'}
))}
{meth?.openness?.note &&
{meth.openness.note}
}
Measured dimensions
{(meth?.openness?.dimensions ?? []).map((d) => (
{d}
))}
Each model page states these booleans with their source; the category is derived from them and the licence ontology.
Licence ontology · /methodology
);
return (
{fmtInt(res.total)} downloadable models
: undefined} />
{!res ? (
) : (
<>
{/* ------------------------------------------------------------------------------- openness explorer */}
{CATS.map((c) => {
const n = num(byCat[c]) ?? 0;
return n > 0 ? : null;
})}
{CATS.map((c) => (
{labels[c] ?? c}
{fmtInt(byCat[c] ?? 0)} {catTotal ? `${Math.round((100 * (num(byCat[c]) ?? 0)) / catTotal)}%` : ''}
))}
Top licences: {licences.slice(0, 6).map((l) => `${l.label ?? l.key} (${fmtInt(l.models)})`).join(' · ') || '—'}
Category · this page
{PERMS.map((p) => (
{p.label}
))}
{matrix.map((r) => (
n={r.n}
{r.cells.map((c, i) => (
{r.n === 0 ? (
—
) : (
{c.yes}
{c.no}
{c.unk}
)}
))}
))}
Counts read: allowed · restricted · unknown / unclassified — over the {fmtInt(items.length)} models on this page, from each licence's stated terms (ontology).
{/* --------------------------------------------------------------------------------------- table */}
}>
Model
Licence · permissions
Params
Context
Release
Best results
Providers
Fit 64 GB @4bit · 128 GB @8bit
{items.length === 0 && No downloadable model matches these filters. }
{items.map((it) => {
const d = it.dimensions ?? {};
const mods = Array.isArray(d.modalities) ? (d.modalities as string[]) : [];
return (
{typeof d.openness === 'string' && }
{it.model.organization?.name ?? '—'}
{mods.length ? ` · ${mods.join(', ')}` : ''}
{fmtParams(d.parameter_count)}
{num(d.active_parameter_count) !== null && num(d.active_parameter_count) !== num(d.parameter_count) && {fmtParams(d.active_parameter_count)} active }
{fmtTokens(d.context_length)}
{typeof d.release_date === 'string' ? fmtDate(d.release_date) : '—'}
{fmtInt(it.providers)}
{num(it.cheapest_output_per_mtok) !== null && from {fmtUsdPerM(it.cheapest_output_per_mtok)} out }
);
})}
href({ offset: o || undefined })} className="mt-4" />
Best results = rank inside each benchmark's primary comparability group; several dimensions are shown side by side and never combined. Fit columns are estimates (64 GB device at 4-bit, 128 GB at 8-bit, 8K context) — method on /methodology. unclassified = the raw licence label is not yet mapped in the ontology.
>
)}
);
}