Skip to content

API Reference parrot.tools.interactive_toolkit

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

parrot.tools.interactive_toolkit

View source

InteractiveToolkit — free-form, self-contained interactive HTML artifacts.

The "vibe-coding" counterpart to :class:~parrot.tools.infographic_toolkit.InfographicToolkit. Where infographics constrain the LLM to typed JSON blocks rendered deterministically, this toolkit hands the LLM a scaffold (a self-contained HTML skeleton with named slots) plus a catalog of vetted JS libraries, and lets it author the HTML/JS directly during an enhance pass. The result is the same artifact plumbing infographics use: persisted via :class:ArtifactStore, served by the public signed-URL HTML route, and locked down by the JSBundle SRI allow-list + CSP.

Tools exposed (prefixed with interactive_)::

interactive_render            — Build skeleton + enhance + validate + persist.
interactive_list_templates    — Discover scaffold templates.
interactive_list_libraries    — Discover available JS libraries.
interactive_get_scaffold      — Inspect one template's skeleton + libraries.

With return_direct=True the interactive_render result is the final agent output (consumed by the agent post-loop), exactly like infographic_render.

Alias AbstractToolkit

Re-exported from parrot.tools.toolkit.AbstractToolkit.

Alias Artifact

Re-exported from parrot.storage.models.Artifact.

Alias ArtifactCreator

Re-exported from parrot.storage.models.ArtifactCreator.

Alias ArtifactStore

Re-exported from parrot.storage.artifacts.ArtifactStore.

Alias ArtifactType

Re-exported from parrot.storage.models.ArtifactType.

Alias HEAD_MARKER

Re-exported from parrot.tools.interactive.catalog_registry.HEAD_MARKER.

Alias InteractiveCatalogRegistry

Re-exported from parrot.tools.interactive.catalog_registry.InteractiveCatalogRegistry.

Alias InteractiveRenderResult

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

Class InteractiveToolkit

Toolkit producing self-contained interactive HTML artifacts.

Usage::

toolkit = InteractiveToolkit(artifact_store=store)
tools = toolkit.get_tools()
toolkit.set_bot(agent)   # enables enhance mode + prompt guidance
Parameter Type Default Description
artifact_store ArtifactStore Initialised ArtifactStore instance.
catalog Optional[InteractiveCatalogRegistry] None Optional catalog override; defaults to the bundled singleton.
emit_a2ui bool False When True, the render tool additionally produces a validated A2UI CreateSurface envelope (FEAT-273 Module 11, D1a lane).
**kwargs {} Forwarded to AbstractToolkit.__init__.

Attributes:

Attribute Type Description
tool_prefix Optional[str]
prefix_separator str
exclude_tools Tuple[str, ...]
return_direct bool

Method InteractiveToolkit.get_tools

Return generated tools; only interactive_render is terminal.

get_tools(**kwargs)

Parameter Type Default Description
**kwargs {}

Method InteractiveToolkit.set_bot

Bind a bot for enhance-mode support and inject prompt guidance.

Appends both the usage guide and the static catalog index to the bot's system_prompt_template so any agent that registers this toolkit knows which scaffolds and libraries exist (the two-tier skills pattern). Call during the agent's configure() before _define_prompt() runs.

set_bot(bot: Any) -> None

Parameter Type Default Description
bot Any

Method InteractiveToolkit.list_templates

Return available scaffold templates with their slots and libraries.

list_templates() -> List[Dict[str, Any]]

Returns: List[Dict[str, Any]] — List of dicts with name, description, default_theme, allowed_bundles and slots.

Method InteractiveToolkit.list_libraries

Return available JS libraries the LLM may use in artifacts.

list_libraries() -> List[Dict[str, Any]]

Returns: List[Dict[str, Any]] — List of dicts with name, description, category and scope ("cdn" or "inline").

Method InteractiveToolkit.get_scaffold

Return one template's raw skeleton plus its allowed library details.

Use this before interactive_render to see the slot markers you must fill and the usage snippets for the libraries you may reference.

get_scaffold(template_name: str) -> Dict[str, Any]

Parameter Type Default Description
template_name str Template identifier from interactive_list_templates.

Returns: Dict[str, Any] — Dict with name, description, slots, html_skeleton (raw, with <!--HEAD--> and <!-- SLOT:* --> markers), and allowed_libraries (each with usage and types).

Raises:

  • InteractiveValidationError — TEMPLATE_UNKNOWN if not found.

Method InteractiveToolkit.render

Build, (optionally) enhance, validate, and persist an interactive artifact.

This is the primary tool. Call it as the last tool in the turn. The result is returned verbatim — do NOT summarise it.

render(template_name: str, brief: str, libraries: Optional[List[str]] = None, mode: Literal['deterministic', 'enhance'] = 'enhance', theme: Optional[str] = None, title: Optional[str] = None, data_context: Optional[Dict[str, Any]] = None) -> InteractiveRenderResult

Parameter Type Default Description
template_name str Scaffold identifier from interactive_list_templates.
brief str Natural-language description of the page to build (what each slot should contain, the data to visualise, desired interactivity).
libraries Optional[List[str]] None Library names to use; each MUST be in the template's allowed_bundles. Defaults to all of the template's libraries.
mode Literal['deterministic', 'enhance'] 'enhance' "enhance" (LLM authors the content) or "deterministic" (return the empty skeleton — used as the safe fallback).
theme Optional[str] None Theme name ("light"/"dark"); defaults to the template's.
title Optional[str] None Optional document title (used for the artifact title).
data_context Optional[Dict[str, Any]] None Optional JSON-serialisable data passed to the LLM as the source of truth for any figures it renders.

Returns: InteractiveRenderResult — InteractiveRenderResult with artifact_id, html_url, optional html_inline and provenance fields.

Raises:

  • InteractiveValidationError — On unknown/disallowed template or library, or a missing enhance brief.

Class InteractiveValidationError

Structured error raised by the interactive render pipeline.

Carries a stable code (for client routing) and a detail dict.

Valid codes::

TEMPLATE_UNKNOWN
LIBRARY_UNKNOWN
LIBRARY_NOT_ALLOWED
ENHANCE_BRIEF_MISSING
ENHANCE_OUTPUT_INVALID
Parameter Type Default Description
code str
detail Dict[str, Any]

Alias JSBundle

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

Alias LibraryEntry

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

Alias ScaffoldTemplate

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

Alias build_head

Re-exported from parrot.tools.interactive.catalog_registry.build_head.

Alias build_public_html_url

Re-exported from parrot.storage.artifact_signing.build_public_html_url.

Alias get_interactive_catalog

Re-exported from parrot.tools.interactive.catalog_registry.get_interactive_catalog.

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