Creating GenUI Components
FERAL’s GenUI layer generates server-driven UI (SDUI) from tool results and provider contracts. Instead of hardcoding frontend components for every tool, the backend decides what to render and sends a declarative payload to the client.How It Works
- A tool returns structured data (JSON).
- The GenUI engine matches the data shape to a UI template.
- An SDUI payload is sent to the client.
- The client’s
SduiRendererdisplays it — cards, charts, maps, forms, lists.
SDUI Payload Structure
Built-in Components
| Component | Use Case |
|---|---|
MetricCard | Single value with label, icon, trend indicator |
DataTable | Tabular data with sortable columns |
BarChart / LineChart | Quantitative data over categories or time |
MapView | Geographic data with markers |
FormCard | User input that posts back to a skill endpoint |
ListCard | Ordered or unordered list of items |
MarkdownCard | Rendered markdown content |
ImageCard | Image with optional caption |
Provider Surfaces
For richer experiences, a provider can register a full JSON contract that defines branded, multi-screen surfaces. Think of it as a mini-app inside FERAL.Registering a Provider
Provider Contract
Surface Lifecycle
- Register — provider posts its contract via the API.
- Compile — FERAL compiles each named surface into SDUI JSON and caches it locally in
~/.feral/genui_surfaces/. - Serve — subsequent opens reuse the cached layout shell; only runtime data (prefixed with
$) is hydrated. - Update — if the provider pushes a new contract version, the cache is invalidated and recompiled.
Contract Fields
| Field | Required | Description |
|---|---|---|
provider_id | yes | Unique ID |
name | yes | Display name |
brand | no | Colors, logo, theme |
ui_rules | no | Layout mode (fixed or adaptive), brand strictness, navigation style |
cache_policy | no | static (compile once) or dynamic (regenerate per session) |
endpoints[] | yes | Backend endpoints the surface can call |
surfaces[] | yes | Named UI screens with declarative templates |
Template Primitives
| Type | Description |
|---|---|
VStack | Vertical layout container |
HStack | Horizontal layout container |
Text | Text label with style variants (headline, body, caption) |
Button | Tappable action with an action_id |
MapView | Map with center, markers, routes |
MetricCard | Single metric display |
Image | Image with URL and optional alt text |
Input | Text input field |
Select | Dropdown or picker |
Client-Side Rendering
The web UI’sSduiRenderer component (feral-client/src/components/SduiRenderer.jsx) recursively renders SDUI payloads. When adding a new component type:
- Define the component in the renderer’s component map.
- Handle the
propspassed from the SDUI payload. - Wire up any
action_idhandlers to post back to the Brain.
API Reference
| Endpoint | Method | Description |
|---|---|---|
/api/genui/providers/register | POST | Register a provider contract |
/api/genui/providers | GET | List registered providers |
/api/genui/providers/{id}/surfaces | GET | List surfaces + cache status |
/api/genui/providers/{id}/surfaces/{sid} | GET | Get one surface contract |
/api/genui/providers/{id}/surfaces/compile | POST | Compile and cache surfaces |
/api/genui/providers/{id}/surfaces/render | POST | Render runtime data into cached surface |
