Components designed for humans, agents, and automation.
PromptUI is an AI-native UI component system for modern web apps. It treats UI definitions as both human interfaces and machine-operable contracts, so the same component tree can render for people, serialize for agents, validate structured payloads, and dispatch semantic actions.
Most UI systems stop at presentation. Most form libraries stop at validation. Most automation layers operate on brittle selectors or ad hoc JSON. PromptUI sits between those concerns.
It gives developers a single definition layer for:
- human-facing rendering
- machine-readable metadata
- structured actions and intents
- normalized validation rules
- UI serialization and introspection
The result is a practical UI contract that can be inspected and operated by software without abandoning usability for humans.
packages/promptui: framework-agnostic TypeScript core libraryapps/demo: Vite + React demo that renders the same definitions and shows their serialized agent view- unit tests for serialization, dispatch, validation, lookup, and schema generation
- Framework-neutral component model
- Declarative builders for
section,form,field,card,table,panel, andaction - Stable JSON serialization with semantic metadata
- First-class structured actions with ids, intents, labels, schemas, and confirmation metadata
- JSON Schema generation for forms and action payloads
- Structured validation results for humans and software
- Introspection APIs for components, actions, and schemas
- Lightweight rendering helpers plus a polished demo implementation
- Accessibility-conscious HTML structure in the rendering layer
- Optional state adapters for local binding
npm install
npm run build
npm run test
npm run devIf you prefer pnpm, the workspace is also configured with pnpm-workspace.yaml.
npm install promptui-workspaceimport { action, createPromptUI, field, form } from "promptui";
const ui = createPromptUI({
id: "lead-qualification",
title: "Lead Qualification",
description: "Capture inquiry details and next-step eligibility",
});
ui.add(
form({
id: "contact-form",
title: "Get in touch",
description: "Collect lead details for qualification",
fields: [
field.text({
id: "fullName",
label: "Full name",
required: true,
}),
field.email({
id: "email",
label: "Email",
required: true,
}),
field.select({
id: "inquiryType",
label: "Inquiry type",
required: true,
options: [
{ value: "sales", label: "Sales" },
{ value: "partnership", label: "Partnership" },
{ value: "support", label: "Support" },
],
}),
field.textarea({
id: "message",
label: "Message",
}),
],
actions: [
action.submit({
id: "submit-lead",
label: "Submit",
intent: "create_lead",
}),
],
}),
);ui.onAction("submit-lead", async (payload, ctx) => {
console.log("intent", ctx.action.intent);
console.log("values", payload.values);
return {
accepted: true,
queue: "sales-intake",
};
});
const result = await ui.dispatch("submit-lead", {
values: {
fullName: "Mario Moreno",
email: "mario@example.com",
inquiryType: "sales",
message: "I want more information",
},
});const snapshot = ui.serialize();
const tree = ui.inspect();
console.log(snapshot.components);
console.log(tree.actions);
console.log(tree.schemas);Conceptually, the serialized output looks like:
{
"kind": "promptui",
"id": "lead-qualification",
"title": "Lead Qualification",
"components": [
{
"id": "contact-form",
"type": "form",
"title": "Get in touch",
"fields": [
{
"id": "fullName",
"type": "text",
"label": "Full name",
"required": true
}
],
"actions": [
{
"id": "submit-lead",
"kind": "submit",
"intent": "create_lead",
"label": "Submit"
}
]
}
]
}ui.serialize(): stable machine-readable documentui.inspect(): serialized root plus flat component and action indexesui.getActions(): normalized action registryui.getComponentById(id): retrieve a component definitionui.getSchema(): form schemas and action payload schemasui.dispatch(actionId, payload): validate and execute an actionui.onAction(actionId, handler): register a structured handler
The demo app shows both the rendered UI and the machine-facing view for three scenarios:
- Lead Qualification Form
- Invoice Approval Review Card
- Support Operations Action Panel
Run it locally:
npm install
npm run devPromptUI is built in four practical layers:
- Definition layer Components are declared with small builder functions and explicit semantic metadata.
- Serialization layer Definitions normalize into stable JSON with actions, validation rules, and component metadata.
- Execution layer Actions are registered and dispatched through a typed runtime that validates payloads and returns structured results.
- Rendering layer Lightweight helpers and the demo prove that the same contract can drive a usable interface for humans.
Component libraries solve presentation and interaction primitives. PromptUI adds:
- structured semantics
- machine-readable actions
- introspection
- normalized validation metadata
- a bridge between UI and automation
Raw JSON is not enough on its own. PromptUI adds:
- typed developer ergonomics
- usable human rendering
- reusable component contracts
- an action dispatch model
- consistent semantics and validation behavior
- PromptUI does not include LLM execution.
- PromptUI does not replace a full frontend framework.
- PromptUI does not solve autonomous agent planning by itself.
- Rendering is intentionally lightweight in v1.
- Serialization quality depends on the developer’s component definitions.
- richer list and table affordances
- deeper accessibility metadata and keyboard policies
- richer framework adapters beyond the demo
- schema export helpers for external automation pipelines
- workflow composition primitives above the current action model