--- ## A2UIView Renders a trusted-catalog A2UI (Agent-to-UI, v0.9.1 `basic` subset) payload into live, interactive Urbicon components. Fail-loud and whitelist-only: only the 12 mapped components and their declared props ever reach the DOM — unknown components/props, prototype-pollution keys and function-call bindings are rejected, never rendered, and surfaced through `onValidationError` (spec-compatible issues a consumer can relay to the agent as a `VALIDATION_FAILED` error). Inputs are two-way (typing writes into the local data model; bound text updates live); actions dispatch a spec-exact `A2uiActionEvent`. Images and links are gated by the same strict-by-default `urlPolicy` as StreamingMarkdown. It is deliberately NOT a default ChatMessage renderer — wire it in per surface via `partRenderers.a2ui` to keep it out of the base bundle. Generate the agent-side prompt with the shipped `a2uiSystemPrompt()`; validate a payload without a DOM with `createA2uiProcessor()` — never hand-roll either. **Import:** `import { A2UIView } from '@urbicon-ui/blocks';` ### Examples ```svelte {#snippet a2uiPart(part)} sendUserTurn(`[ui-action] ${JSON.stringify(event)}`)} onValidationError={(issues) => reportToAgent(issues)} /> {/snippet} ``` ```svelte console.log(e)} /> ``` ### Api | Prop | Type | Required | Default | Description | | --- | --- | :---: | --- | --- | | payload | `unknown` | yes | | The A2UI payload. Accepts an array of envelopes (the accumulated JSONL sequence — stream by extending it immutably: `[...prev, envelope]`), a single envelope object, or the golden-file `{ messages: [...] }` wrapper. | | ...HTMLAttributes | `HTMLAttributes` | no | | HTML attributes (excluding: 'class') | | blockedImageLabel | `string` | no | 'Image blocked' | Chip label shown in place of a policy-blocked image. | | class | `string` | no | | Extra classes merged onto the root element. | | errorTitle | `string` | no | 'Invalid UI payload' | Title of the top-level error Alert for envelope-level faults. | | onAction | `(event: A2uiActionEvent) => void` | no | | Fired when a Button is activated, with the spec-exact resolved action event. | | onValidationError | `(issues: A2uiValidationIssue[]) => void` | no | | Fired whenever the validation-issue list changes (errors AND warnings, each with a `severity`). Relay error-severity issues to the agent as an A2UI `error` message. | | pendingLabel | `string` | no | 'Loading UI' | Screen-reader label of the streaming placeholder. | | preset | `string` | no | | Apply a named preset registered via ``. Prefer this over `class` overrides for reusable custom looks. | | slotClasses | `Partial>` | no | | Per-slot class overrides. Slots: `root`, `surface`, `errorList`, `errorChip`, `errorIcon`, `pending`, `column`, `row`, `list`, `listItem`, `heading`, `caption`, `inlineText`, `image`, `blockedChip`, `icon`, `svgIcon`, `choiceGroup`, `choiceLabel`. | | streaming | `boolean` | no | false | While true, a reference to a not-yet-defined component renders a placeholder instead of a fault chip (mid-stream tolerance). Flip to false when the stream settles so dangling references become errors. | | unstyled | `boolean` | no | | Strip the component's default tv() classes. | | unsupportedLabel | `string` | no | 'Unsupported component' | Fault-chip label for an unknown/unsupported/incomplete component. | | urlPolicy | `MarkdownUrlPolicy` | no | | URL policy for `Image` sources (and Text markdown links). Strict by default: every external image is blocked unless its prefix is allowlisted. Keep the object referentially stable. | Inherited from: - Omit, 'class'> (omit-pattern) ### Types ```ts interface MarkdownUrlPolicy { /** * Allowed link protocols (with trailing colon). Relative URLs are always * allowed for links. @default ['http:', 'https:', 'mailto:', 'tel:'] */ allowedLinkProtocols?: string[]; /** * Prefix allowlist for image sources, matched against the normalized * absolute URL. Empty (the default) blocks every external image; relative * sources are allowed. Prefer deep, specific prefixes — broad ones are * open-redirect bait. `data:` images are blocked unless a `data:` prefix * is listed explicitly. * @default [] */ allowedImagePrefixes?: string[]; /** Observability hook — fires once per blocked URL occurrence. */ onBlocked?: (kind: 'link' | 'image', url: string) => void; } ``` ```ts interface A2uiActionEvent { name: string; surfaceId: string; sourceComponentId: string; /** ISO 8601 timestamp (`new Date().toISOString()`). */ timestamp: string; context: Record; } ``` ```ts interface A2uiValidationIssue { severity: A2uiIssueSeverity; code: string; surfaceId?: string; path?: string; message: string; } ``` ```ts type A2uiIssueSeverity = 'error' | 'warning' ``` ```ts type SlotNames = keyof ReturnType & string ```