Skip to content

API Reference parrot.tools.interactive.catalog_registry

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.tools.interactive.catalog_registry

View source

On-disk loader for the interactive HTML artifact catalog.

The catalog ships two kinds of entries under parrot/tools/interactive/catalog/:

  • libraries/*.md — YAML frontmatter describing a vetted JS library plus fenced ## Usage / ## Types / ## Inline code blocks. Parsed into :class:~parrot.models.interactive.LibraryEntry.
  • templates/<name>.html + templates/<name>.meta.yaml — a self-contained HTML skeleton with <!-- SLOT:name --> markers and a <!--HEAD--> marker, plus metadata (description, default theme, allowed libraries). Parsed into :class:~parrot.models.interactive.ScaffoldTemplate (slots auto-derived from the skeleton).

The registry follows the eager-load + index pattern of :class:~parrot.skills.file_registry.SkillFileRegistry. A module-level singleton is exposed via :func:get_interactive_catalog.

This module also owns the deterministic presentation layer reused by the toolkit: :data:BASE_CSS, the theme variable map, and :func:build_head, which assembles the <head> injection (base CSS + theme variables + allow-listed bundle <script>/<link> tags) that replaces a skeleton's <!--HEAD--> marker.

Attribute BASE_CSS

Attribute CATALOG_DIR

Attribute HEAD_MARKER

Class InteractiveCatalogRegistry

Eager-loading registry of catalog libraries and scaffold templates.

Parameter Type Default Description
catalog_dir Optional[Path] None Root directory containing libraries/ and templates/. Defaults to the bundled :data:CATALOG_DIR.

Method InteractiveCatalogRegistry.load

Load (or reload) all libraries and templates from disk.

load() -> 'InteractiveCatalogRegistry'

Returns: 'InteractiveCatalogRegistry' — self for chaining. Individual malformed entries are logged and skipped rather than aborting the whole load.

Method InteractiveCatalogRegistry.ensure_loaded_async

Load the catalog in a thread pool executor to avoid blocking the event loop.

Call this from async contexts (aiohttp handlers, async tool methods) before the first synchronous catalog access. Subsequent calls are no-ops.

ensure_loaded_async() -> None

Method InteractiveCatalogRegistry.get_library

Return the library entry name or raise KeyError.

get_library(name: str) -> LibraryEntry

Parameter Type Default Description
name str

Returns: LibraryEntry

Method InteractiveCatalogRegistry.get_template

Return the scaffold template name or raise KeyError.

get_template(name: str) -> ScaffoldTemplate

Parameter Type Default Description
name str

Returns: ScaffoldTemplate

Method InteractiveCatalogRegistry.list_libraries

Return all loaded libraries, sorted by name.

list_libraries() -> List[LibraryEntry]

Returns: List[LibraryEntry]

Method InteractiveCatalogRegistry.list_templates

Return all loaded templates, sorted by name.

list_templates() -> List[ScaffoldTemplate]

Returns: List[ScaffoldTemplate]

Method InteractiveCatalogRegistry.render_prompt_index

Render the static <interactive_catalog> prompt index.

This block is injected once into the agent system prompt (configure-time) so the LLM knows which scaffolds and libraries exist — the two-tier pattern borrowed from the skills system. Zero per-turn cost.

render_prompt_index() -> str

Returns: str

Alias JSBundle

Re-exported from parrot.models.infographic.JSBundle.

Alias LibraryEntry

Re-exported from parrot.models.interactive.LibraryEntry.

Attribute PLACEHOLDER_SRI_PREFIX

Alias ScaffoldTemplate

Re-exported from parrot.models.interactive.ScaffoldTemplate.

Attribute THEMES

Type: Dict[str, Dict[str, str]]

Function build_head

Assemble the <head> injection for a skeleton's <!--HEAD--> marker.

Emits the base stylesheet, optional theme overrides, then the allow-listed bundle tags (stylesheets first, then scripts) so the libraries are available before any inline content runs.

build_head(bundles: Iterable[JSBundle], theme: Optional[str] = None) -> str

Parameter Type Default Description
bundles Iterable[JSBundle] The resolved bundles to inject (script + stylesheet).
theme Optional[str] None Optional theme name applied as CSS-variable overrides.

Returns: str — An HTML fragment safe to splice into a document <head>.

Function get_interactive_catalog

Return the process-wide catalog singleton (not yet loaded).

The catalog is loaded on first access via _ensure_loaded() (sync) or ensure_loaded_async() (async, thread-safe). Async callers should call await catalog.ensure_loaded_async() before touching catalog data to avoid blocking the event loop with disk I/O.

get_interactive_catalog() -> InteractiveCatalogRegistry

Returns: InteractiveCatalogRegistry

Attribute logger

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally