Skip to content

API Reference parrot.registry.routing.route_labels

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

parrot.registry.routing.route_labels

View source

Composite route-label grammar and the A2UI component-hint channel (FEAT-755).

A phrase-bank key is either a plain :class:OutputMode value ("structured_chart") or a composite "a2ui:<ComponentName>" that resolves to :attr:OutputMode.A2UI plus a component hint carried on the request context.

This module is deliberately pure: the A2UI catalog is imported lazily, inside :func:is_inline_component only, so parrot.registry.routing stays light.

Attribute A2UI_LABEL_PREFIX

Type: Final[str]

Class OutputShape

Resolved output shape: mode plus an optional A2UI component hint.

Attributes:

Attribute Type Description
mode OutputMode
component Optional[str]

Function get_component_hint

Return a context's A2UI component hint, if present.

get_component_hint(ctx: Any) -> Optional[str]

Parameter Type Default Description
ctx Any A request-context-like object, or None.

Returns: Optional[str] — The component hint or None when it is unavailable.

Function is_inline_component

Return whether component is registered and does not require actions.

The catalog is imported only for the lookup to keep routing imports light.

is_inline_component(component: str) -> bool

Parameter Type Default Description
component str The A2UI catalog component name to check.

Returns: bool — True when the component is display-only; otherwise False.

Function make_route_label

Return "a2ui:<component>".

make_route_label(component: str) -> str

Parameter Type Default Description
component str The A2UI catalog component name.

Returns: str

Raises:

  • ValueError — If component is empty or whitespace-only.

Function parse_route_label

Parse a phrase-bank key into an :class:OutputShape.

"structured_chart" -> OutputShape(OutputMode.STRUCTURED_CHART); "a2ui:KPICard" -> OutputShape(OutputMode.A2UI, "KPICard").

Does NOT consult the catalog — see :func:is_inline_component.

parse_route_label(label: str) -> OutputShape

Parameter Type Default Description
label str A plain output-mode value or composite A2UI route label.

Returns: OutputShape

Raises:

  • ValueError — On an unknown OutputMode value or a malformed composite (empty component after the prefix).

Function set_output_shape

Write an A2UI component hint to a context and return its output mode.

set_output_shape(ctx: Any, shape: OutputShape) -> OutputMode

Parameter Type Default Description
ctx Any A request-context-like object, or None.
shape OutputShape The resolved output shape to apply.

Returns: OutputMode — The output mode stored in shape.

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