JSON Envelope Schemas
Palyra defines several top-level envelope structures inschemas/json/envelopes/ to wrap different types of data payloads. These envelopes ensure that versioning, identification, and metadata are consistently handled across the system.
| Envelope | Purpose | Key Fields |
|---|---|---|
a2ui-envelope.v1.json | Encapsulates A2UI documents and incremental patches. | v, id, surface, patch, experimental |
message-envelope.v1.json | Standard wrapper for chat messages and system notifications. | v, id, timestamp, payload |
webhook-envelope.v1.json | Format for egress notifications to external services. | v, event_type, resource_id, data |
config-export/import.v1.json | Portable format for migrating daemon configuration and profiles. | v, kind, metadata, encrypted_payload |
A2UI Envelope Structure
The A2UI envelope is specifically designed for high-frequency UI updates. It supports an incrementalpatch mechanism (RFC 6902-inspired) to avoid re-sending the entire UI state over the wire.
Sources: schemas/json/envelopes/a2ui-envelope.v1.json#1-201
A2UI Protocol Implementation
The A2UI protocol allows an agent to describe a structured interface (forms, tables, charts) that the client renders natively. This bypasses the security risks ofdangerouslySetInnerHTML and provides a consistent look and feel across different surfaces.
Data Flow: From Patch to Render
The following diagram illustrates how an A2UI payload is processed from the Rust-based daemon validation to the React-based renderer. A2UI Processing Pipeline Sources: crates/palyra-a2ui/src/lib.rs#84-99, apps/web/src/a2ui/normalize.ts#33-77, apps/web/src/a2ui/renderer.tsx#36-63Component Normalization and Sanitization
Before rendering, thenormalizeA2uiDocument function in the web client enforces strict limits and sanitizes inputs to prevent layout breaking or injection attacks.
- Identifier Sanitization: All component IDs are processed via
sanitizeIdentifierto ensure they are valid DOM attributes apps/web/src/a2ui/normalize.ts#174-175. - Resource Limits:
RenderInputLimits(defined intypes.ts) constrain the number of components, string lengths, and table rows to prevent browser OOM or DoS via massive payloads apps/web/src/a2ui/types.ts#162-174. - Tone Mapping: Text components use a restricted set of tones (
normal,muted,success,critical) mapped to CSS classes apps/web/src/a2ui/types.ts#43-46.
A2UI Renderer Components
TheA2uiRenderer maps JSON component types to React components:
| Type | React Implementation | Props Source |
|---|---|---|
text | p with .a2ui-text | A2uiTextProps |
markdown | SanitizedMarkdown | A2uiMarkdownProps |
list | ol / ul | A2uiListProps |
table | EntityTable | A2uiTableProps |
form | AppForm | A2uiFormProps |
chart | A2uiBarChart | A2uiChartProps |
Experimental Governance
A2UI includes a first-classexperimental block for features in rollout. This block enforces transparency and security reviews before an experimental UI surface can be rendered.
Security Gates
The protocol requires anexperimental document to provide:
- Track ID: A unique identifier for the experiment apps/web/src/a2ui/normalize.ts#149.
- Feature Flag: The specific daemon-side flag controlling the feature apps/web/src/a2ui/normalize.ts#150.
- Security Review: A checklist of completed security assessments apps/web/src/a2ui/normalize.ts#155.
- Consent Enforcement: If
ambient_modeis set topush_to_talk, the protocol strictly requiresconsent_required: true. Failure to provide this results in a validation error apps/web/src/a2ui/normalize.ts#123-128.
Patching and State Management
Thepalyra-a2ui Rust crate provides utilities for generating and validating incremental updates to the UI state.
- Patch Operations: Supports
Add,Replace, andRemoveoperations crates/palyra-a2ui/src/lib.rs#29-34. - Validation: The
parse_patch_documentfunction ensures that every operation has a valid JSON pointer path and thatadd/replaceoperations include avaluecrates/palyra-a2ui/src/lib.rs#101-160. - Root Replacement: A helper
build_replace_root_patchis provided to perform a full state reset using the patch protocol crates/palyra-a2ui/src/lib.rs#162-171.