Skip to content

zidane-ui/models/headless

import { … } from 'zidane-ui/models/headless'ui/src/models/headless/index.ts

Functions#

compactWindowFunction#

zidane-ui/models/headless: the model catalog, React-free. The rows a host lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick (ModelPickRef), what a host offers of its catalogs (ComposerModels), the rules a picker lists, searches and edits a chain by, and the names a model goes by (modelNamesOf). The composer's pickers and the model rows of Settings both read it.

TypeScript
function compactWindow(tokens: number): string
Parameters
NameTypeDescription
tokensnumber

A context window size in tokens.

string

ui/src/models/headless/catalog.ts:41

groupKeyOfFunction#

zidane-ui/models/headless: the model catalog, React-free. The rows a host lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick (ModelPickRef), what a host offers of its catalogs (ComposerModels), the rules a picker lists, searches and edits a chain by, and the names a model goes by (modelNamesOf). The composer's pickers and the model rows of Settings both read it.

TypeScript
function groupKeyOf(entry: Pick<ModelCatalogRow, 'providerKey' | 'account'>): string
Parameters
NameTypeDescription
entryPick<ModelCatalogRow, 'providerKey' | 'account'>

A row, or any object with its providerKey and account.

string

ui/src/models/headless/catalog.ts:90

lineupKeyOfFunction#

zidane-ui/models/headless: the model catalog, React-free. The rows a host lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick (ModelPickRef), what a host offers of its catalogs (ComposerModels), the rules a picker lists, searches and edits a chain by, and the names a model goes by (modelNamesOf). The composer's pickers and the model rows of Settings both read it.

TypeScript
function lineupKeyOf(entry: ModelCatalogRow): string
Parameters
NameTypeDescription
entryModelCatalogRow

The catalog row.

string

ui/src/models/headless/catalog.ts:81

modelLineupFunction#

zidane-ui/models/headless: the model catalog, React-free. The rows a host lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick (ModelPickRef), what a host offers of its catalogs (ComposerModels), the rules a picker lists, searches and edits a chain by, and the names a model goes by (modelNamesOf). The composer's pickers and the model rows of Settings both read it.

TypeScript
function modelLineup(catalog: readonly ModelCatalogRow[]): ReadonlySet<string>
Parameters
NameTypeDescription
catalogreadonly ModelCatalogRow[]

The catalog rows. The result is cached per array.

ReadonlySet<string>

ui/src/models/headless/catalog.ts:28

modelNameOfFunction#

zidane-ui/models/headless: the model catalog, React-free. The rows a host lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick (ModelPickRef), what a host offers of its catalogs (ComposerModels), the rules a picker lists, searches and edits a chain by, and the names a model goes by (modelNamesOf). The composer's pickers and the model rows of Settings both read it.

TypeScript
function modelNameOf(
  catalog: readonly ModelCatalogRow[] | null,
  modelId: string,
  providerKey?: string | null,
): string
Parameters
NameTypeDefaultDescription
catalogreadonly ModelCatalogRow[] | null

The catalog rows, or null while it loads.

modelIdstring

The model id to name.

providerKey?string | nullnull

Limits the lookup to one provider. Defaults to null, which matches any provider.

string

ui/src/models/headless/catalog.ts:111

modelNamesOfFunction#

The one ModelNamesStore over a host's models (this computer's catalog, and its providers when listed). Without models, every model keeps its readable id.

TypeScript
function modelNamesOf(models: ComposerModels | undefined): ModelNamesStore
Parameters
NameTypeDescription
modelsComposerModels | undefined

The host's member.

ui/src/models/headless/names.ts:145

modelSearchScoreFunction#

zidane-ui/models/headless: the model catalog, React-free. The rows a host lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick (ModelPickRef), what a host offers of its catalogs (ComposerModels), the rules a picker lists, searches and edits a chain by, and the names a model goes by (modelNamesOf). The composer's pickers and the model rows of Settings both read it.

TypeScript
function modelSearchScore(
  entry: ModelCatalogRow,
  terms: readonly string[],
): number | null
Parameters
NameTypeDescription
entryModelCatalogRow

The catalog row.

termsreadonly string[]

The lower-cased search terms. Every term must match.

number | null

ui/src/models/headless/catalog.ts:273

namerForFunction#

A namer reading catalog: the entry of that provider first, then any provider listing the id.

TypeScript
function namerFor(
  catalog: readonly Pick<ModelCatalogRow, 'providerKey' | 'modelId' | 'modelName'>[],
): ModelNamer
Parameters
NameTypeDescription
catalogreadonly Pick<ModelCatalogRow, 'providerKey' | 'modelId' | 'modelName'>[]

The catalog rows.

ModelNamer

ui/src/models/headless/names.ts:45

offCatalogRowsFunction#

zidane-ui/models/headless: the model catalog, React-free. The rows a host lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick (ModelPickRef), what a host offers of its catalogs (ComposerModels), the rules a picker lists, searches and edits a chain by, and the names a model goes by (modelNamesOf). The composer's pickers and the model rows of Settings both read it.

TypeScript
function offCatalogRows(
  catalog: readonly ModelCatalogRow[],
  query: string,
  currentProviderKey: string | null,
  catalogMatched: boolean,
): ModelCatalogRow[]
Parameters
NameTypeDescription
catalogreadonly ModelCatalogRow[]

The catalog rows.

querystring

What the user typed in the search field.

currentProviderKeystring | null

Key of the provider in use, listed after the one the query names. null for none.

catalogMatchedboolean

Whether the catalog already matched the query. If so, only an id-shaped query gets typed routes.

ui/src/models/headless/catalog.ts:221

pickerGroupsFunction#

zidane-ui/models/headless: the model catalog, React-free. The rows a host lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick (ModelPickRef), what a host offers of its catalogs (ComposerModels), the rules a picker lists, searches and edits a chain by, and the names a model goes by (modelNamesOf). The composer's pickers and the model rows of Settings both read it.

TypeScript
function pickerGroups<E extends ModelCatalogRow>(
  catalog: readonly E[],
  query: string,
  chain: readonly ModelPickRef[],
  showLegacy: boolean,
  current: ReadonlySet<string>,
): PickerGroup<E>[]
Type parameters
NameTypeDescription
Eextends ModelCatalogRow
Parameters
NameTypeDescription
catalogreadonly E[]

The catalog rows.

querystring

What the user typed in the search field. Blank lists by provider.

chainreadonly ModelPickRef[]

The chain in force. Its models lead the list as "In use".

showLegacyboolean

Lists every model instead of only the current ones.

currentReadonlySet<string>

The lineup keys of the current models, from modelLineup.

ui/src/models/headless/catalog.ts:322

pickRefOfFunction#

zidane-ui/models/headless: the model catalog, React-free. The rows a host lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick (ModelPickRef), what a host offers of its catalogs (ComposerModels), the rules a picker lists, searches and edits a chain by, and the names a model goes by (modelNamesOf). The composer's pickers and the model rows of Settings both read it.

TypeScript
function pickRefOf(entry: ModelCatalogRow): ModelPickRef
Parameters
NameTypeDescription
entryModelCatalogRow

The catalog row.

ui/src/models/headless/catalog.ts:59

providerAccountLabelFunction#

zidane-ui/models/headless: the model catalog, React-free. The rows a host lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick (ModelPickRef), what a host offers of its catalogs (ComposerModels), the rules a picker lists, searches and edits a chain by, and the names a model goes by (modelNamesOf). The composer's pickers and the model rows of Settings both read it.

TypeScript
function providerAccountLabel(
  entry: Pick<ModelCatalogRow, 'providerLabel' | 'account'>,
): string
Parameters
NameTypeDescription
entryPick<ModelCatalogRow, 'providerLabel' | 'account'>

A row, or any object with its providerLabel and account.

string

ui/src/models/headless/catalog.ts:100

refKeyFunction#

zidane-ui/models/headless: the model catalog, React-free. The rows a host lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick (ModelPickRef), what a host offers of its catalogs (ComposerModels), the rules a picker lists, searches and edits a chain by, and the names a model goes by (modelNamesOf). The composer's pickers and the model rows of Settings both read it.

TypeScript
function refKey(entry: ModelPickRef): string
Parameters
NameTypeDescription
entryModelPickRef

The pick.

string

ui/src/models/headless/catalog.ts:50

resolveChainFunction#

zidane-ui/models/headless: the model catalog, React-free. The rows a host lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick (ModelPickRef), what a host offers of its catalogs (ComposerModels), the rules a picker lists, searches and edits a chain by, and the names a model goes by (modelNamesOf). The composer's pickers and the model rows of Settings both read it.

TypeScript
function resolveChain(
  chain: readonly ModelPickRef[],
  catalog: readonly ModelCatalogRow[],
): readonly ModelPickRef[]
Parameters
NameTypeDescription
chainreadonly ModelPickRef[]

The chain: the primary, then its fallbacks.

catalogreadonly ModelCatalogRow[]

The catalog rows.

readonly ModelPickRef[]

ui/src/models/headless/catalog.ts:166

resolvePickFunction#

zidane-ui/models/headless: the model catalog, React-free. The rows a host lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick (ModelPickRef), what a host offers of its catalogs (ComposerModels), the rules a picker lists, searches and edits a chain by, and the names a model goes by (modelNamesOf). The composer's pickers and the model rows of Settings both read it.

TypeScript
function resolvePick(
  pick: ModelPickRef,
  catalog: readonly ModelCatalogRow[],
): ModelPickRef
Parameters
NameTypeDescription
pickModelPickRef

A pick of the chain.

catalogreadonly ModelCatalogRow[]

The catalog rows.

ui/src/models/headless/catalog.ts:144

rowKeyFunction#

zidane-ui/models/headless: the model catalog, React-free. The rows a host lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick (ModelPickRef), what a host offers of its catalogs (ComposerModels), the rules a picker lists, searches and edits a chain by, and the names a model goes by (modelNamesOf). The composer's pickers and the model rows of Settings both read it.

TypeScript
function rowKey(entry: ModelCatalogRow): string
Parameters
NameTypeDescription
entryModelCatalogRow

The catalog row.

string

ui/src/models/headless/catalog.ts:72

unresolveChainFunction#

zidane-ui/models/headless: the model catalog, React-free. The rows a host lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick (ModelPickRef), what a host offers of its catalogs (ComposerModels), the rules a picker lists, searches and edits a chain by, and the names a model goes by (modelNamesOf). The composer's pickers and the model rows of Settings both read it.

TypeScript
function unresolveChain(
  next: readonly ModelPickRef[],
  chain: readonly ModelPickRef[],
  shown: readonly ModelPickRef[],
): ModelPickRef[]
Parameters
NameTypeDescription
nextreadonly ModelPickRef[]

The edited resolved chain.

chainreadonly ModelPickRef[]

The chain before the edit.

shownreadonly ModelPickRef[]

chain resolved, as the edit saw it.

ui/src/models/headless/catalog.ts:190

withPrimaryFunction#

zidane-ui/models/headless: the model catalog, React-free. The rows a host lists (ModelCatalogRow, ComposerModelEntry, ImageModelRow) and a pick (ModelPickRef), what a host offers of its catalogs (ComposerModels), the rules a picker lists, searches and edits a chain by, and the names a model goes by (modelNamesOf). The composer's pickers and the model rows of Settings both read it.

TypeScript
function withPrimary(chain: readonly ModelPickRef[], pick: ModelPickRef): ModelPickRef[]
Parameters
NameTypeDescription
chainreadonly ModelPickRef[]

The current chain: the primary, then its fallbacks.

pickModelPickRef

The model to make the primary.

ui/src/models/headless/catalog.ts:131

Interfaces#

ComposerModelEntryInterface#

A catalog row with the options its model declares: what ComposerModels.catalog lists.

TypeScript
interface ComposerModelEntry extends ModelCatalogRow
ComposerModelEntry properties
NameTypeDescription
account?from ModelCatalogRow{ active?: boolean; id: string; label: string }

The provider's stored account this row runs on, when it has several. Absent: its only one.

contextWindowfrom ModelCatalogRownumber | null

Context window in tokens, or null when unknown.

details?from ModelCatalogRowreadonly string[]

Short facts shown beside the name, before the window (ChatModel.details).

isDefault?from ModelCatalogRowboolean

The provider's default model: what a new chat falls back to on this provider.

modelIdfrom ModelCatalogRowstring

Model id within the provider.

modelNamefrom ModelCatalogRowstring

The catalog's display name (Claude Opus 4.6); the row shows its natural form (Opus 4.6).

modelProvider?from ModelCatalogRowstring

Attribution for an aggregator's row (anthropic on OpenRouter).

offCatalog?from ModelCatalogRowboolean

A typed id the catalog does not know: used as typed, no metadata.

options?readonly ComposerModelOption[]

The feature toggles the model declares. Absent or empty: none.

providerKeyfrom ModelCatalogRowstring

Key of the provider that serves the model.

providerLabelfrom ModelCatalogRowstring

Provider name shown as the group heading.

references?from ModelCatalogRowboolean

An image model that takes reference images (to edit, or to match a style).

searchCorpus?from ModelCatalogRowstring

Pre-lowercased search text. Default: provider key and label, account, id, name, attribution.

supportsAdaptive?from ModelCatalogRowboolean

The model's provider has an adaptive thinking mode, so the effort pickers offer adaptive (zidane's thinkingLevelsFor). Absent: it has none.

supportsReasoningfrom ModelCatalogRowboolean

The model supports reasoning effort.

transparency?from ModelCatalogRowboolean

An image model that can make a transparent background.

unavailable?from ModelCatalogRowstring

Why the row cannot be picked with the current credentials. The row shows, greyed out, and picking it does nothing.

ui/src/models/headless/rows.ts:87

ComposerModelOptionInterface#

A feature toggle a model declares (fast mode, …).

TypeScript
interface ComposerModelOption
ComposerModelOption properties
NameTypeDescription
description?string

What it does.

idstring

The option's id, a key of the session's enabled options.

labelstring

Its name.

ui/src/models/headless/rows.ts:77

ComposerModelsInterface#

The model catalogs, kept current.

TypeScript
interface ComposerModels
ComposerModels properties
NameTypeDescription
catalog(cwd: string | undefined, hostId: string | null) => Readable<ResourceSnapshot<readonly ComposerModelEntry[]>>

The chat models a folder (cwd, undefined: the host's default) on a host (null: this one) can run.

images?(cwd: string | null) => Readable<ResourceSnapshot<readonly ImageModelRow[]>>

The image models for a folder. Absent: the picker has no Image tab.

providers?() => Readable<ResourceSnapshot<readonly { key: string; label: string }[]>>

Every provider this computer knows, signed in or not (labels for model names).

ui/src/models/headless/host.ts:11

ImageModelRowInterface#

One image model, as the host lists it.

TypeScript
interface ImageModelRow
ImageModelRow properties
NameTypeDescription
availableboolean

The provider's credentials can generate with it.

isDefault?boolean

The model generate_image uses while no default is picked.

modelIdstring

The model's id at the provider.

modelNamestring

The model's display name.

providerKeystring

The provider's key, for example openai.

providerLabelstring

The provider's display name.

reason?string

Why it is not available.

referencesboolean

The model takes reference images.

transparencyboolean

The model can return a transparent background.

ui/src/models/headless/rows.ts:55

ModelCatalogRowInterface#

One row of the catalog.

TypeScript
interface ModelCatalogRow
ModelCatalogRow properties
NameTypeDescription
account?{ active?: boolean; id: string; label: string }

The provider's stored account this row runs on, when it has several. Absent: its only one.

contextWindownumber | null

Context window in tokens, or null when unknown.

details?readonly string[]

Short facts shown beside the name, before the window (ChatModel.details).

isDefault?boolean

The provider's default model: what a new chat falls back to on this provider.

modelIdstring

Model id within the provider.

modelNamestring

The catalog's display name (Claude Opus 4.6); the row shows its natural form (Opus 4.6).

modelProvider?string

Attribution for an aggregator's row (anthropic on OpenRouter).

offCatalog?boolean

A typed id the catalog does not know: used as typed, no metadata.

providerKeystring

Key of the provider that serves the model.

providerLabelstring

Provider name shown as the group heading.

references?boolean

An image model that takes reference images (to edit, or to match a style).

searchCorpus?string

Pre-lowercased search text. Default: provider key and label, account, id, name, attribution.

supportsAdaptive?boolean

The model's provider has an adaptive thinking mode, so the effort pickers offer adaptive (zidane's thinkingLevelsFor). Absent: it has none.

supportsReasoningboolean

The model supports reasoning effort.

transparency?boolean

An image model that can make a transparent background.

unavailable?string

Why the row cannot be picked with the current credentials. The row shows, greyed out, and picking it does nothing.

ui/src/models/headless/rows.ts:19

ModelNamesInterface#

How models and providers are named.

TypeScript
interface ModelNames
ModelNames properties
NameTypeDescription
modelModelNamer

A model's name.

provider(providerKey: string) => string

A provider's label (Anthropic); its key when nothing names it.

ui/src/models/headless/names.ts:17

ModelNamesProviderInterface#

A provider as the sign-in report lists it.

TypeScript
interface ModelNamesProvider
ModelNamesProvider properties
NameTypeDescription
keystring

The provider's key.

labelstring

Its label.

ui/src/models/headless/names.ts:25

ModelNamesStoreInterface#

The live names.

TypeScript
interface ModelNamesStore
ModelNamesStore properties
NameTypeDescription
get() => ModelNames

The names now (a new object when the catalog changes).

subscribe(listener: () => void) => () => void

Registers a listener (the first one starts reading). Returns the unsubscribe.

ui/src/models/headless/names.ts:33

ModelPickRefInterface#

A model pick: provider, model and, when the provider has several, the stored account it runs on.

TypeScript
interface ModelPickRef
ModelPickRef properties
NameTypeDescription
account?string

Id of the stored account the pick runs on. Only set when the provider has several.

modelIdstring

Model id within the provider.

providerKeystring

Key of the provider, for example anthropic.

ui/src/models/headless/rows.ts:9

PickerGroupInterface#

One section of the model picker list.

TypeScript
interface PickerGroup<E extends ModelCatalogRow = ModelCatalogRow>
PickerGroup type parameters
NameTypeDefaultDescription
Eextends ModelCatalogRowModelCatalogRow
PickerGroup properties
NameTypeDescription
detail?string

Shown after the label as typed (not uppercased): the typed id of the routes group.

keystring

Provider key (provider@account for one of several accounts), in-use for the pinned chain, typed for a typed id's routes.

labelstring

Heading of the section.

providerKeystring | null

Provider key for coloring; null for the in-use and typed groups.

rowsE[]

The models listed in the section.

totalnumber

Models of this provider in the catalog, before the lineup filter.

ui/src/models/headless/catalog.ts:294