Registry

The Smarter Extension registry: discovery, trust badges and updates.

The registry is a public GitHub repository, smarter-sh/extensions-registry, whose CI publishes a signed index of every released extension: index.json, and its Ed25519 signature, index.json.sig, at extension_registry_url. Publishers submit releases by pull request; the Smarter team assigns publishers’ trust badges in a file that only it may change.

This module:

  • fetches the index, caching the HTTP request for an hour, and verifies its signature with extension_registry_public_key on every read;

  • finds each extension’s newest version that is compatible with this platform;

  • downloads an archive, and checks it against the sha256 in the signed index;

  • installs or updates an extension from the registry, with its publisher’s trust badge;

  • records the newest compatible version of each installed extension, so that the admin console can say an update is available.

The index’s models allow fields that they do not know, so that the registry can add fields without breaking older platforms.

class smarter.apps.llmtool.extension.registry.RegistryExtension(**data)[source]

Bases: RegistryModel

An extension in the registry, with every released version.

description: str
display_name: str
docs_rst: str
find_version(version)[source]

Return one of the extension’s versions, or None.

Return type:

RegistryVersion | None

homepage: str | None
latest_compatible(platform_version=None)[source]

Return the newest version that works with a Smarter version, this platform’s if None, or None.

Return type:

RegistryVersion | None

license: str | None
model_config = {'extra': 'ignore'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

publisher: str
slug: str
versions: list[RegistryVersion]
class smarter.apps.llmtool.extension.registry.RegistryIndex(**data)[source]

Bases: RegistryModel

The registry’s index: every publisher, and every extension.

badge_of(extension)[source]

Return the trust badge of an extension’s publisher; community if the publisher is unknown.

Return type:

str

extension(slug)[source]

Return an extension by slug, or None.

Return type:

RegistryExtension | None

extensions: list[RegistryExtension]
generated_at: datetime | None
model_config = {'extra': 'ignore'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

publisher(publisher_id)[source]

Return a publisher by id, or None.

Return type:

RegistryPublisher | None

publishers: list[RegistryPublisher]
schema_version: int
class smarter.apps.llmtool.extension.registry.RegistryPublisher(**data)[source]

Bases: RegistryModel

A publisher of extensions, and how far the Smarter team trusts them.

badge: Literal['official', 'verified', 'community']
id: str
model_config = {'extra': 'ignore'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str
url: str | None
class smarter.apps.llmtool.extension.registry.RegistryVersion(**data)[source]

Bases: RegistryModel

One released version of an extension.

archive_url: str
is_compatible(platform_version=None)[source]

Return whether this version works with a Smarter version; this platform’s if None.

Return type:

bool

model_config = {'extra': 'ignore'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

released_at: datetime | None
requires_smarter: str | None
sha256: str
sort_key()[source]

The version, for sorting; an invalid version sorts first.

Return type:

Version

version: str
smarter.apps.llmtool.extension.registry.check_for_updates(refresh=False)[source]

Record the newest compatible version of every extension installed from the registry.

Extensions installed from uploaded archives are not checked, so that an upload is never offered a registry package that happens to have the same slug.

Parameters:

refresh (bool) – Whether to download the index again, rather than reading the cached copy.

Return type:

list[Extension]

Returns:

The extensions for which an update is available.

Raises:

SmarterExtensionRegistryError – If the registry cannot be read.

smarter.apps.llmtool.extension.registry.download(version)[source]

Download an extension archive, and check it against the signed index’s sha256.

Parameters:

version (RegistryVersion) – The version to download.

Return type:

bytes

Returns:

The archive’s bytes.

Raises:

SmarterExtensionRegistryError – If it cannot be downloaded, or does not match its sha256.

smarter.apps.llmtool.extension.registry.get_index()[source]

Return the registry’s verified index.

Return type:

RegistryIndex

Returns:

The index.

Raises:

SmarterExtensionRegistryError – If the registry is disabled, cannot be reached, or its index is not authentic or not valid.

smarter.apps.llmtool.extension.registry.index_json_schema()[source]

Return the JSON Schema of the registry’s index.

Return type:

dict

smarter.apps.llmtool.extension.registry.install_from_registry(slug, version=None, user=None)[source]

Install an extension from the registry, or update an installed one.

Parameters:
  • slug (str) – The extension’s slug.

  • version (str | None) – The version to install; the newest compatible version if None.

  • user (User | None) – The superuser who installs it.

Return type:

Extension

Returns:

The extension, installed but disabled if it is new.

Raises:

SmarterExtensionRegistryError – If the registry, the extension or the version cannot be found or downloaded.

smarter.apps.llmtool.extension.registry.is_enabled()[source]

Return whether the registry is configured: it is disabled until its public key is set.

Return type:

bool

smarter.apps.llmtool.extension.registry.refresh_index()[source]

Download the index again, rather than reading the cached copy, and return it.

Return type:

RegistryIndex

smarter.apps.llmtool.extension.registry.verify(index, signature, public_key)[source]

Verify the index’s Ed25519 signature.

Parameters:
  • index (bytes) – The index’s bytes.

  • signature (bytes) – The signature, base64.

  • public_key (str) – The registry’s public key, base64.

Raises:

SmarterExtensionRegistryError – If the key or signature is malformed, or the signature does not match.

Return type:

None