UIResponse that serializes to the envelope below. The renderer parses it, resolves templates, interpolates state, and renders the component tree.
Envelope
Every response is a JSON object with clean top-level keys:| Key | Type | Description |
|---|---|---|
version | string | Protocol version (currently "0.2") |
view | Component | The root component tree to render |
defs | object | Optional map of template name to component subtree (see Define/Use below) |
state | object | Optional client-side state, accessible via {{ key }} interpolation |
$ (reserved for interpolation builtins like $event and $error).
Components
Every component is a JSON object with atype discriminator:
| Field | Type | Description |
|---|---|---|
cssClass | string | Additional Tailwind CSS classes |
children array of nested components.
For conditional rendering, use the Condition component with cases and an optional else branch.
Actions
Actions define what happens on user interaction. They appear in event handler fields likeonClick, onChange, and onSubmit. An action uses an action discriminator instead of type:
null:
| Action | Discriminator | Description |
|---|---|---|
| SetState | setState | Set a client-side state variable |
| ToggleState | toggleState | Flip a boolean state variable |
| ToolCall | toolCall | Call a server-side tool |
| SendMessage | sendMessage | Send a message to the chat |
| UpdateContext | updateContext | Silently update model context |
| OpenLink | openLink | Open a URL |
| ShowToast | showToast | Display a toast notification |
Interpolation
All string properties support{{ key }} placeholders that resolve against client-side state at render time. The special value {{ $event }} captures the triggering interaction’s value (slider position, input text, checkbox state, etc.).
Define / Use (Templates)
Templates let you define a component subtree once and reference it multiple times with different data. Defining a template — entries indefs map a name to a component subtree:
$ref node references a definition by name:
$ref in a State node to provide interpolation values:
$ref nodes by looking up the definition and rendering it with the current interpolation context. Circular references are detected and short-circuited.