Herramientas de UI
El adk-ui crate permite a los agentes de IA generar dinΓ‘micamente interfaces de usuario enriquecidas a travΓ©s de llamadas a herramientas. Los Agents pueden renderizar formularios, tarjetas, alertas, tablas, grΓ‘ficos y mΓ‘s, todo a travΓ©s de un Rust de tipo seguro API que se serializa a JSON para el consumo del frontend.
Lo que construirΓ‘s

Conceptos Clave:
- Formularios - Recopila la entrada del usuario con varios tipos de campo
- Tarjetas - Muestra informaciΓ³n con botones de acciΓ³n
- Tablas - Presentan datos estructurados en filas/columnas
- GrΓ‘ficos - Visualizan datos con grΓ‘ficos de barras, lΓneas, Γ‘reas, circulares
- Alerts - Muestra notificaciones y mensajes de estado
- Modals - DiΓ‘logos de confirmaciΓ³n e interacciones enfocadas
- Toasts - Notificaciones de estado breves
- Interoperabilidad de Protocolo - Emitir UI como A2UI, AG-UI, o cargas ΓΊtiles de aplicaciones MCP
Ejemplo: Panel de AnΓ‘lisis

Ejemplo: Formulario de Registro

CΓ³mo Funciona
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β STEP 1: User requests something β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β User: "I want to register for an account" β
β β
β β β
β β
β ββββββββββββββββββββββββββββββββββββββββ β
β β AI AGENT (LLM) β β
β β "I should show a registration form" β β
β ββββββββββββββββββββββββββββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β STEP 2: Agent calls render_form tool β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β π Tool Call: render_form({ β
β title: "Registration", β
β fields: [ β
β {name: "email", type: "email"}, β
β {name: "password", type: "password"} β
β ] β
β }) β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β STEP 3: Frontend renders the form β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β π Registration β β
β β ββββββββββββββββββββββββββββββββββββββββββββ β β
β β Email: [________________________] β β
β β Password: [________________________] β β
β β β β
β β [ Register ] β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β β
User sees an interactive form, fills it out, clicks Register β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β STEP 4: Form submission sent back to agent β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β π© Event: { β
β type: "form_submit", β
β data: { email: "user@example.com", password: "***" } β
β } β
β β
β Agent: "Great! I'll process your registration and show a success alert" β
β β
β π Tool Call: render_alert({ β
β title: "Registration Complete!", β
β variant: "success" β
β }) β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
VisiΓ³n General
Las herramientas de UI permiten a los agentes:
- Recopilar la entrada del usuario a travΓ©s de formularios dinΓ‘micos con soporte para textarea
- Mostrar informaciΓ³n con tarjetas, alertas y notificaciones
- Presentar datos en tablas y grΓ‘ficos interactivos (Recharts)
- Mostrar progreso y estados de carga (spinner, skeleton)
- Crear diseΓ±os de panel con mΓΊltiples componentes
- Solicitar confirmaciΓ³n al usuario mediante modales
- Mostrar notificaciones "toast" para actualizaciones de estado
Inicio RΓ‘pido
AΓ±ade a tu Cargo.toml:
[dependencies]
adk-ui = { git = "https://github.com/zavora-ai/adk-ui" }
adk-agent = "2.0.0"
adk-model = "2.0.0"
Uso BΓ‘sico
use adk_rust::prelude::*;
use adk_ui::UiToolset;
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let model = Arc::new(GeminiModel::from_env("gemini-2.5-flash")?);
// Get all 10 UI tools
let ui_tools = UiToolset::all_tools();
// Create AI agent with UI tools
let mut builder = LlmAgentBuilder::new("ui_agent")
.model(model)
.instruction(r#"
You are a helpful assistant that uses UI components to interact with users.
Use render_form for collecting information.
Use render_card for displaying results.
Use render_alert for notifications.
Use render_modal for confirmation dialogs.
Use render_toast for brief status messages.
"#);
for tool in ui_tools {
builder = builder.tool(tool);
}
let agent = builder.build()?;
Ok(())
}
A2UI JSONL (render_screen / render_page / render_kit)
Estas herramientas emiten A2UI v0.9 JSONL para compatibilidad con renderers A2UI.
render_screen (superficie ΓΊnica)
{
"surface_id": "main",
"components": [
{ "id": "root", "component": "Column", "children": ["title", "cta"] },
{ "id": "title", "component": "Text", "text": "Welcome", "variant": "h1" },
{ "id": "cta_label", "component": "Text", "text": "Continue", "variant": "body" },
{ "id": "cta", "component": "Button", "child": "cta_label", "action": { "event": { "name": "continue" } } }
]
}
render_page (pΓ‘gina de mΓΊltiples secciones)
{
"title": "Release Notes",
"description": "Highlights for the latest launch.",
"sections": [
{
"heading": "Whatβs new",
"body": "Three big improvements shipped this week.",
"bullets": ["Faster onboarding", "Better search", "New dashboards"],
"actions": [{ "label": "View details", "action": "view_details", "variant": "borderless" }]
}
]
}
render_kit (catΓ‘logo + tokens + plantillas)
{
"name": "Fintech Pro",
"version": "0.1.0",
"brand": { "vibe": "trustworthy", "industry": "fintech" },
"colors": { "primary": "#2F6BFF" },
"typography": { "family": "Source Sans 3" },
"templates": ["auth_login", "dashboard"]
}
Utilice el React renderer para consumir A2UI JSONL:
import {
A2uiStore,
A2uiSurfaceRenderer,
applyParsedMessages,
parseJsonl,
} from "@zavora-ai/adk-ui-react";
const store = new A2uiStore();
const parsed = parseJsonl(jsonl);
applyParsedMessages(store, parsed);
export function App() {
return <A2uiSurfaceRenderer store={store} surfaceId="main" />;
}
Herramientas Disponibles
render_form
Renderizar formularios interactivos para recopilar la entrada del usuario.
{
"title": "Registration Form",
"description": "Create your account",
"fields": [
{"name": "username", "label": "Username", "type": "text", "required": true},
{"name": "email", "label": "Email", "type": "email", "required": true},
{"name": "password", "label": "Password", "type": "password", "required": true},
{"name": "newsletter", "label": "Subscribe to newsletter", "type": "switch"}
],
"submit_label": "Register"
}
Se renderiza como:
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β π Registration Form β
β Create your account β
β βββββββββββββββββββββββββββββββββββββββββββββ β
β β
β Username * β
β βββββββββββββββββββββββββββββββββββββββββββ β
β β β β
β βββββββββββββββββββββββββββββββββββββββββββ β
β β
β Email * β
β βββββββββββββββββββββββββββββββββββββββββββ β
β β β β
β βββββββββββββββββββββββββββββββββββββββββββ β
β β
β Password * β
β βββββββββββββββββββββββββββββββββββββββββββ β
β β β’β’β’β’β’β’β’β’ β β
β βββββββββββββββββββββββββββββββββββββββββββ β
β β
β Subscribe to newsletter [β] β
β β
β βββββββββββββββββββββββββββββββββββββββββββ β
β β Register β β
β βββββββββββββββββββββββββββββββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
Tipos de campo: text, email, password, number, date, select, multiselect, switch, slider, textarea
render_card
Mostrar tarjetas de informaciΓ³n con botones de acciΓ³n opcionales.
{
"title": "Order Confirmed",
"description": "Order #12345",
"content": "Your order has been placed successfully. Expected delivery: Dec 15, 2025.",
"actions": [
{"label": "Track Order", "action_id": "track", "variant": "primary"},
{"label": "Cancel", "action_id": "cancel", "variant": "danger"}
]
}
Variantes de botΓ³n: primary, secondary, danger, ghost, outline
render_alert
Mostrar notificaciones y mensajes de estado.
{
"title": "Payment Successful",
"description": "Your payment of $99.00 has been processed.",
"variant": "success"
}
Variantes: info, success, warning, error
render_confirm
Solicitar confirmaciΓ³n al usuario antes de las acciones.
{
"title": "Delete Account",
"message": "Are you sure you want to delete your account? This action cannot be undone.",
"confirm_label": "Delete",
"cancel_label": "Keep Account",
"variant": "danger"
}
render_table
Mostrar datos tabulares.
{
"title": "Recent Orders",
"columns": [
{"header": "Order ID", "accessor_key": "id"},
{"header": "Date", "accessor_key": "date"},
{"header": "Amount", "accessor_key": "amount"},
{"header": "Status", "accessor_key": "status"}
],
"data": [
{"id": "#12345", "date": "2025-12-10", "amount": "$99.00", "status": "Delivered"},
{"id": "#12346", "date": "2025-12-11", "amount": "$149.00", "status": "Shipped"}
]
}
render_chart
Crear visualizaciones de datos.
{
"title": "Monthly Sales",
"chart_type": "bar",
"x_key": "month",
"y_keys": ["revenue", "profit"],
"data": [
{"month": "Jan", "revenue": 4000, "profit": 2400},
{"month": "Feb", "revenue": 3000, "profit": 1398},
{"month": "Mar", "revenue": 5000, "profit": 3800}
]
}
Tipos de grΓ‘ficos: bar, line, area, pie
render_progress
Muestra el progreso de la tarea con pasos opcionales.
{
"title": "Installing Dependencies",
"value": 65,
"description": "Installing package 13 of 20...",
"steps": [
{"label": "Download", "completed": true},
{"label": "Extract", "completed": true},
{"label": "Install", "current": true},
{"label": "Configure", "completed": false}
]
}
render_layout
Crear diseΓ±os de panel con mΓΊltiples secciones.
{
"title": "System Status",
"description": "Current system health overview",
"sections": [
{
"title": "Services",
"type": "stats",
"stats": [
{"label": "API Server", "value": "Healthy", "status": "operational"},
{"label": "Database", "value": "Degraded", "status": "warning"},
{"label": "Cache", "value": "Down", "status": "error"}
]
},
{
"title": "Recent Errors",
"type": "table",
"columns": [{"header": "Time", "key": "time"}, {"header": "Error", "key": "error"}],
"rows": [{"time": "10:30", "error": "Connection timeout"}]
}
]
}
Tipos de secciΓ³n: stats, table, chart, alert, text
render_modal
Muestra diΓ‘logos modales para confirmaciones o interacciones enfocadas.
{
"title": "Confirm Deletion",
"message": "Are you sure you want to delete this item? This action cannot be undone.",
"size": "medium",
"closable": true,
"confirm_label": "Delete",
"cancel_label": "Cancel",
"confirm_action": "delete_confirmed"
}
TamaΓ±os: small, medium, large, full
render_toast
Mostrar notificaciones toast breves para actualizaciones de estado.
{
"message": "Settings saved successfully",
"variant": "success",
"duration": 5000,
"dismissible": true
}
Variantes: info, success, warning, error
Herramientas Filtradas
Selecciona solo las herramientas que tu agente necesita:
let toolset = UiToolset::new()
.without_chart() // Disable charts
.without_table() // Disable tables
.without_progress() // Disable progress
.without_modal() // Disable modals
.without_toast(); // Disable toasts
// Or use forms only
let forms_only = UiToolset::forms_only();
Manejo de Eventos de UI
Cuando los usuarios interactΓΊan con la UI renderizada (envΓan formularios, hacen clic en botones), los eventos se envΓan de vuelta al agent:
use adk_ui::{UiEvent, UiEventType};
// UiEvent structure
pub struct UiEvent {
pub event_type: UiEventType, // FormSubmit, ButtonClick, InputChange
pub action_id: Option<String>,
pub data: Option<HashMap<String, Value>>,
}
// Convert to message for agent
let message = ui_event.to_message();
Actualizaciones de UI por streaming
Para actualizaciones de UI en tiempo real, usa UiUpdate para parchear componentes por ID:
use adk_ui::{UiUpdate, UiOperation};
let update = UiUpdate {
target_id: "progress-bar".to_string(),
operation: UiOperation::Patch,
payload: Some(Component::Progress(Progress {
id: Some("progress-bar".to_string()),
value: 75,
label: Some("75%".to_string()),
})),
};
Operaciones: Replace, Patch, Append, Remove
Esquema de Componentes
Todos los 28 tipos de componentes soportan campos id opcionales para actualizaciones de streaming:
Γtomos: Texto, BotΓ³n, Icono, Imagen, Insignia Entradas: TextInput, NumberInput, Selector, MultiSelect, Interruptor, DateInput, Deslizador, Γrea de texto DiseΓ±os: Stack, Grid, Card, Container, Divider, Tabs Datos: Table, List, KeyValue, CodeBlock VisualizaciΓ³n: GrΓ‘fico (barras, lΓneas, Γ‘reas, circular a travΓ©s de Recharts) RetroalimentaciΓ³n: Alert, Progress, Toast, Modal, Spinner, Skeleton
React Client
Se proporciona una implementaciΓ³n de referencia de React en el repositorio independiente adk-ui:
npm install @zavora-ai/adk-ui-react
El cliente de React incluye:
- TypeScript tipos que coinciden con el esquema de Rust
- Component renderer para los 28 tipos
- IntegraciΓ³n de Recharts para grΓ‘ficos interactivos
- Soporte para renderizado de Markdown
- Soporte para modo oscuro
- Manejo de envΓo de formularios
- Componentes modales y de notificaciΓ³n (toast)
Arquitectura
Agent ββ[render_* tool]ββ> UiResponse (JSON)
β
β SSE
βΌ
Client (React)
β
βββ> UiEvent (user action) ββ> Agent
Interoperabilidad de Protocolo
Todas las 13 herramientas de renderizado soportan salida consciente del protocolo a travΓ©s del protocol argumento:
| Protocolo | DescripciΓ³n |
|---|---|
a2ui | Superficies JSONL compatibles con A2UI v0.9 (predeterminadas para render_screen y render_page) |
ag_ui | Soporte AG-UI hΓbrido: envolturas de compatibilidad por defecto, mΓ‘s transporte en tiempo de ejecuciΓ³n aditivo nativo de protocolo para adk-server clientes |
mcp_apps | Cargas ΓΊtiles compatibles con MCP Apps mediante recursos ui://, ayudantes de puente adicionales, flujos de notificaciΓ³n, campos de solicitud en tiempo de ejecuciΓ³n y adaptadores de HTML y recursos |
Cuando protocol se omite, tools usan su formato de salida predeterminado (legado UiResponse JSON para la mayorΓa de los tools, A2UI para render_screen/render_page/render_kit).
Ejemplo con selecciΓ³n de protocolo:
{
"protocol": "mcp_apps",
"mcp_apps": {
"resource_uri": "ui://demo/surface"
}
}
Adaptadores de interoperabilidad
adk-ui incluye primitivas de adaptador para conversiΓ³n de protocolo:
A2uiAdapterβ Convierte superficies canΓ³nicas a A2UI JSONLAgUiAdapterβ Convierte a cargas ΓΊtiles de eventos AG-UIMcpAppsAdapterβ Convierte a MCP cargas ΓΊtiles de recursos de aplicaciones
Estos implementan un trait UiProtocolAdapter compartido para una conversiΓ³n consistente en todas las herramientas.
Cronograma de DesaprobaciΓ³n
El perfil de tiempo de ejecuciΓ³n heredado adk_ui contiene metadatos de desaprobaciΓ³n:
| Fecha | Hito |
|---|---|
| 2026-02-07 | DeprecaciΓ³n anunciada |
| 2026-12-31 | Objetivo de retirada |
Sustitutos: a2ui, ag_ui, mcp_apps
Estos metadatos se exponen mediante las constantes UI_PROTOCOL_CAPABILITIES, y adk-server los publica en /api/ui/capabilities.
La respuesta de capacidad tambiΓ©n informa implementationTier, specTrack, summary, y limitations para que los clientes puedan distinguir subconjuntos hΓbridos o de compatibilidad de soporte de protocolo totalmente nativo.
Cuando adk-server es el lΓmite orientado al host, tambiΓ©n expone ayudantes de puente aditivos de MCP Apps en /api/ui/initialize, /api/ui/message, /api/ui/update-model-context, /api/ui/notifications/poll, /api/ui/notifications/resources-list-changed, y /api/ui/notifications/tools-list-changed. Estos puntos finales preservan los contratos de tiempo de ejecuciΓ³n existentes de ADK y aceptan cuerpos de solicitud directos o Envoltorios tipo JSON-RPC con mΓ©todos ui/....
Para consumidores en tiempo de ejecuciΓ³n, adk-server tambiΓ©n soporta:
x-adk-ui-transport: protocol_nativeouiTransport: "protocol_native"para AG-UI-native SSE serialization- AG-UI dual-path request inputs a travΓ©s de
input/agUiInputjunto al existentenewMessage - MCP Las aplicaciones conectan envoltorios dentro de
/api/run_ssea travΓ©s demcpAppsInitialize,mcpAppsRequest, ymcpAppsInitialized
Estas adiciones son opcionales. Los consumidores existentes de /api/run y /api/run_sse continΓΊan recibiendo el wrapper genΓ©rico ADK a menos que soliciten explΓcitamente un modo de transporte nativo de AG-UI.
Para las respuestas de herramientas de Apps MCP propiedad del framework, adk-server::ui_types ahora expone:
McpUiBridgeSnapshotpara el estado de puente host/app tipadoMcpUiToolResultpara la envolvente de respuesta aditivaMcpUiToolResultBridgepara el puente metadata (protocolVersion,structuredContent,hostInfo,hostCapabilities,hostContext,appInfo,appCapabilities,initialized)
Prefiera McpUiBridgeSnapshot::build_tool_result(...) al promover el estado del puente/sesiΓ³n en una respuesta de herramienta. Esto estandariza la forma del resultado de la herramienta mientras se preserva resourceUri y en lΓnea html mecanismos de reserva para hosts orientados a la compatibilidad.
Para mapeos incrustados o de host de navegador, el puente aditivo HTTP corresponde a los flujos de host/aplicaciΓ³n de la siguiente manera:
ui/initialize->/api/ui/initializeui/message->/api/ui/messageui/update-model-context->/api/ui/update-model-contextnotifications/resources/list_changed->/api/ui/notifications/resources-list-changednotifications/tools/list_changed->/api/ui/notifications/tools-list-changed- notificaciones de host en cola ->
/api/ui/notifications/poll
Los puntos finales de puente directos /api/ui/* son la ruta de ciclo de vida preferida para los hosts de Apps MCP. Los campos de solicitud de Apps MCP del lado del tiempo de ejecuciΓ³n permanecen disponibles como una ruta de compatibilidad aditiva para clientes mixtos o heredados.
Ejemplos
El repositorio independiente adk-ui contiene los ejemplos de interfaz de usuario ejecutables:
| Ejemplo | DescripciΓ³n | Comando para ejecutar |
|---|---|---|
ui_agent | DemostraciΓ³n de consola | cargo run --bin ui_agent |
ui_server | HTTP servidor con SSE | cargo run --bin ui_server |
ui_react_client | React frontend | cd ui_react_client && npm run dev |
Ejecuta estos ejemplos desde el repositorio adk-ui para mantener los paquetes de Rust y React en la misma lΓnea de versiones.
Sample Prompts
Prueba las herramientas de UI con estas indicaciones:
# Forms
"I want to register for an account"
"Create a contact form"
"Create a feedback form with a comments textarea"
# Cards
"Show me my profile"
"Display a product card for a laptop"
# Alerts
"Show a success message"
"Display a warning about expiring session"
# Modals
"I want to delete my account" (shows confirmation modal)
"Show a confirmation dialog before submitting"
# Toasts
"Show a success toast notification"
"Display an error toast"
# Tables
"Show my recent orders"
"List all users"
# Charts
"Show monthly sales chart"
"Display traffic trends as a line chart"
"Show revenue breakdown as a pie chart"
# Progress & Loading
"Show upload progress at 75%"
"Display a loading spinner"
"Show skeleton loading state"
# Dashboards
"Show system status dashboard"
Anterior: β Herramientas de Navegador | Siguiente: MCP Herramientas β