AFSHomeShowcase

Getting Started with AUP

Build agent-driven UIs in three steps: define a node tree, bind data, handle events — no framework, no build step, no CSS.

Overview

AUP (Agentic UI Protocol) lets AI agents build user interfaces by composing a tree of semantic nodes. The runtime renders the tree, handles user interactions, and manages live data updates — no framework, no build step, no CSS required.

This guide walks you through three steps to build your first AUP interface:

1. Define

Compose a node tree from 18 cross-platform primitives. Each node has an id, type, and optional props and children.

2. Bind

Connect nodes to live data via src (read-only), bind (read-write), or state (client-local). Data changes propagate to the UI automatically.

3. Interact

Wire up events so user actions trigger server-side execution, client-side patches, or page navigation — all declarative, no imperative code.

Step 1

Define a Node Tree

Every AUP interface starts as a tree of nodes. The root is typically a view container, with children that form the UI hierarchy. Each node has an id, a type, and optional props — that’s it.

Node Schema (7 core fields)

Only id and type are required. Everything else is optional:

FieldTypeDescription
idstringUnique node identifier. Must be unique across the entire tree.
typestringPrimitive name: view, text, media, input, action, overlay, table, chart, map, calendar, time, chat, etc.
propsobjectPrimitive-specific attributes. Each type has its own props schema.
childrenarrayChild nodes. Containable types: view, overlay, chat, deck, ticker, frame.
srcstringAFS path for read-only data binding. Client reads on mount and subscribes for live updates.
bindstringAFS path for read-write data binding. Value changes are written back to this path.
eventsobjectEvent bindings. Keys: click, change, send, sort, select, confirm, cancel, dismiss.

Layout with view

The view type is the layout engine. Its layout prop controls how children are arranged:

columnVertical stack (default). Children flow top to bottom.
rowHorizontal flow. Children sit side by side.
gridResponsive auto-fill grid. Adapts to available width.
stackLayered children. Each child occupies the same space.

Add "mode": "card" for a card appearance with surface background and border. Combine layout directions with modes to build dashboards, forms, or any layout.

Live Demo: Dashboard

This dashboard is built entirely from AUP nodes — view containers with row/column layouts, text headings, chart visualizations, and table data, all composed into a single tree:

Live AUP — Dashboard
Step 2

Bind Data

AUP nodes connect to data through three mechanisms. Both src and bind use AFS paths — the same path-based interface that agents use to access any data source (databases, APIs, files, IoT devices).

srcServer → Client

One-way data flow. The client reads the AFS path on mount and subscribes for live updates. Ideal for charts, tables, maps — any display that reflects backend data. When the data changes on the server, the UI updates in real-time.

bindServer ↔ Client

Two-way sync for input nodes. The input reads its initial value from the AFS path, and writes changes back when the user types. Other nodes reading the same path update in real time.

stateClient only

For transient state that doesn’t need persistence — whether an overlay is open, a toggle’s current value, or draft text. Maintained client-side with no server round-trip.

How Data Flows

AgentWrites node tree with src or bind paths
RuntimeReads AFS path, subscribes for changes
UIRenders data, auto-updates on change

Live Demo: Contact Form

This form demonstrates bound inputs. Each field uses AUP’s input primitive with validation and submit handling — inputs write back to AFS paths on change:

Live AUP — Contact Form
Step 3

Handle Events

When users interact with AUP nodes, events flow through the protocol. AUP supports three dispatch modes — each one is declarative, defined right in the node’s events field:

1

Server-Side Exec

Calls an AFS exec action on the server. The agent receives the event and can respond with aup_patch operations to update the UI — create, update, remove, or reorder nodes.

2

Client-Side Patch

Directly patches another node without a server round-trip. Use $args.* placeholders to pass event data into the target’s new properties. Perfect for filtering, toggling, or updating sibling nodes.

3

Page Navigation

Navigate to a named page by targeting _root with a page value. The session resolves the page tree and applies the new style from the app’s page resolver.

Event Lifecycle

1User interacts (click, type, select)
2Client emits aup_event with nodeId, event, data
3Handler resolves: exec → server processes & patches, target+set → client patches directly, page → navigate
4UI updates via aup_patch operations (create, update, remove, reorder)

Supported Events (8)

EventDescription
clickFired by action buttons
changeFired by input fields; carries the new value
sendFired by chat input
sortFired by table header click
selectFired by table row click or overlay choice
confirmFired by overlay confirm button
cancelFired by overlay cancel button
dismissFired by overlay toast dismiss

Live Demo: Interactive Portal

This portal combines all three dispatch modes — buttons trigger exec actions, selections update sibling nodes via target+set, and navigation links switch pages:

Live AUP — Portal

Core Primitives

AUP provides 18 cross-platform primitives that cover every UI pattern — from simple text to real-time video. Each primitive has a typed props schema and renders natively on every supported platform:

view
Layout container. Directions: column, row, grid, stack. Supports card/panel/pane modes.
text
Text display. Levels 1–6 for headings, badge mode, markdown and code format.
media
Images, video, audio. Supports fit modes (cover, contain, fill) and alt text.
input
Form inputs: text, number, select, checkbox, slider, date, file, color, textarea.
action
Buttons with intent: primary, secondary, danger, success, warning, ghost.
overlay
Modal, sheet, toast, confirm, prompt. Controlled via state.open.
table
Data tables with sortable columns, row selection, pagination, and field definitions.
chart
Visualizations: line, bar, area, pie, donut, scatter, radar, heatmap.
map
Geographic maps with markers, clusters, heatmaps, and route lines.
calendar
Date views: month, week, day. Events with color-coded categories.
time
Clocks, timers, countdowns. Analog and digital modes.
chat
Conversational UI. Message bubbles, typing indicators, agent responses.
surface
Embeds external content. Supports URL sources and sandboxed rendering.
explorer
File browser with list/grid views, breadcrumbs, and folder navigation.
editor
Rich text editor with toolbar, markdown support, and content formatting.
canvas
Free-form drawing surface for sketching and annotation.
rtc
Real-time communication: video, audio, screen sharing.
afs-list
AFS-native list with layout × itemStyle dimensions, filter, sort, and live subscription.

See the Primitives Reference for complete documentation with props schemas and rendered demos.

Next Steps

You now know the three building blocks of AUP: node trees, data binding, and event handling. Explore further: