Skip to content

API Reference parrot.models.interactive

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

parrot.models.interactive

View source

Models for Interactive HTML Artifacts ("vibe-coding" canvas).

This is the free-form counterpart to the structured Infographic system. Where an infographic constrains the LLM to a fixed set of typed JSON blocks rendered deterministically, an interactive artifact lets the LLM author the HTML/JS directly — guided by a catalog of vetted JavaScript libraries and HTML scaffold templates that is injected into the agent prompt.

Two pure-data models live here:

  • :class:LibraryEntry — a single vetted JS library (Mermaid, ECharts, Grid.js, …) the LLM may use. It carries the :class:~parrot.models.infographic.JSBundle used by the SRI allow-list / CSP machinery, plus a usage snippet and optional TypeScript reference types that guide the LLM (the snippets are reference material — nothing is compiled; the LLM emits plain JavaScript).
  • :class:ScaffoldTemplate — a deterministic HTML skeleton (dashboard, wizard, diagram, grid, report) with named <!-- SLOT:* --> placeholders the LLM fills during the enhance pass.

The render envelope :class:InteractiveRenderResult mirrors InfographicRenderResult so the agent post-loop can treat both uniformly.

The catalog itself (loading entries from disk) lives in parrot.tools.interactive.catalog_registry to keep this module dependency-light.

Class InteractiveRenderResult

Envelope returned by InteractiveToolkit.render (return_direct=True).

Mirrors InfographicRenderResult so the agent post-loop can handle both artifact families through a single isinstance branch.

Fields:

Field Type Default Description
artifact_id str
html_url str
html_inline Optional[str] None
template_name str
theme Optional[str] None
libraries_used List[str]
enhanced bool False
a2ui_envelope Optional[Dict[str, Any]] None

Alias JSBundle

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

Attribute LibraryCategory

Class LibraryEntry

A single vetted JavaScript library the LLM may use in an artifact.

The library's delivery is described by bundle (a CDN <script> with SRI, or an inline source block). Some libraries also ship a stylesheet — captured by the optional css_bundle (a JSBundle whose url points at a .css file). Both bundles flow into the enhance allow-list and the CSP script-src / style-src directives.

usage_snippet and ts_types are reference material for the LLM: the snippet shows idiomatic usage and ts_types documents the API shape. They are never executed or compiled — the LLM emits plain JavaScript.

Fields:

Field Type Default Description
name str Stable library identifier (e.g. 'mermaid').
description str One-line summary shown in the prompt index.
category LibraryCategory Coarse capability bucket.
bundle JSBundle The script bundle (cdn or inline).
css_bundle Optional[JSBundle] None Optional companion stylesheet bundle (a JSBundle with a .css url).
usage_snippet str '' Idiomatic HTML/JS usage example shown to the LLM (not executed).
ts_types Optional[str] None Optional TypeScript reference types documenting the API (not compiled).

Method LibraryEntry.bundles

Return all bundles (script + optional stylesheet) for allow-listing.

bundles() -> List[JSBundle]

Returns: List[JSBundle]

Method LibraryEntry.to_prompt_entry

Render this library as a compact prompt block for the catalog index.

to_prompt_entry() -> str

Returns: str

Class ScaffoldTemplate

A deterministic HTML skeleton with named slots for the enhance pass.

The skeleton is a complete, self-contained HTML document. <!-- SLOT:name --> markers indicate where the LLM should inject content during the enhance pass; in deterministic mode they are replaced with an empty placeholder so the skeleton still renders standalone.

allowed_bundles lists the library names (matching :attr:LibraryEntry.name) a render against this template may pull. The render tool rejects any requested library not in this list, keeping each template's attack surface explicit.

Fields:

Field Type Default Description
name str Template identifier (e.g. 'wizard').
description str Human-readable description for the LLM.
html_skeleton str Self-contained HTML with markers.
allowed_bundles List[str] Library names this template may use (must exist in the catalog).
slots List[str] Ordered list of slot names present in the skeleton.
default_theme Optional[str] None Optional default theme hint for this template.

Method ScaffoldTemplate.to_prompt_instruction

Generate LLM prompt instructions describing this scaffold.

to_prompt_instruction() -> str

Returns: str

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