
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
dynamic-ui-agent
Advanced tools
A flexible AI agent library for generating structured UI components from natural language prompts
A flexible, schema-agnostic AI agent library for generating structured data from natural language prompts. The agent uses Zod schemas to return strongly-typed, predictable structures that can be rendered in React or consumed by any app. Great for dynamic UI, data pipelines, and more.
Dynamic UI Agent generates structured UI (and arbitrary typed data) from natural language prompts. It validates outputs against Zod, auto-assigns IDs for UI trees, and supports multi-turn conversations via history.
✨ Schema-agnostic (bring your own Zod schema) 🎛️ Flexible LLM config (OpenAI, Anthropic, Google, etc.) ⚛️ Optional React renderer for UI schemas 📦 Type-safe with full TS support 🔧 Configurable prompts, temperature, models 🎯 Function-based API (no classes)
npm install dynamic-ui-agent ai zod
Optionally install a provider:
npm install @ai-sdk/openai # OpenAI
npm install @ai-sdk/anthropic # Anthropic
npm install @ai-sdk/google # Google
For React components (optional):
npm install react react-dom
Set your provider API key via environment variables (e.g., OPENAI_API_KEY) according to your chosen provider.
import { respond } from 'dynamic-ui-agent';
import { openai } from '@ai-sdk/openai';
const response = await respond('Create a login form with email and password', {
llm: { provider: openai, model: 'gpt-4o-mini', temperature: 1 }
});
console.log(response.ui); // Array of UI elements
import { respond } from 'dynamic-ui-agent';
import { z } from 'zod';
import { anthropic } from '@ai-sdk/anthropic';
const RecipeSchema = z.object({
name: z.string(),
ingredients: z.array(z.object({ item: z.string(), amount: z.string() })),
steps: z.array(z.string()),
cookTime: z.number(),
});
const recipe = await respond('Create a lasagna recipe', {
schema: RecipeSchema,
llm: { provider: anthropic, model: 'claude-3-5-sonnet-20241022', temperature: 0.7 }
});
import { createAgent } from 'dynamic-ui-agent';
import { openai } from '@ai-sdk/openai';
const agent = createAgent({
systemPrompt: 'You are a helpful UI designer',
llm: { provider: openai, model: 'gpt-4o' },
history: [],
});
const response1 = await agent.respond('Create a contact form');
const response2 = await agent.respond('Make it more colorful');
Core modules (see lib/src):
agent/ — public API (respond, createAgent), helpers (assignIdsToTree), types/schemasreact/ — DynamicUIRenderer for rendering UI schema in ReactData flow:
respond() with schemaRelationship:
Schema → AI generates structured data → Renderer interprets → UI Components
Approaches:
Example (Input element):
const UIInput = z.object({
type: z.literal('input'),
props: z.object({ name: z.string(), label: z.string().optional(), inputType: z.enum(['text','email','password']) })
});
Renderer switch (simplified):
switch (element.type) {
case 'input': return <Input name={...} type={...} label={...} />
}
import { DynamicUIRenderer } from 'dynamic-ui-agent/react';
DynamicUIRenderer renders the built-in UI schema and exposes onAction for callbacks.
Types supported:
See the schema at lib/src/agent/schema.ts.
Maintain multi-turn context via history:
const agent = createAgent({ history: [] });
const res = await agent.respond('Build a contact form');
UIElementSchemarespond<TSchema>(prompt: string, config?: AgentConfig<TSchema>)schema?: ZodSchema (defaults to built-in UI schema)systemPrompt?: stringhistory?: ChatMessage[]llm?: LLMConfig — provider, model, temperature, maxTokens, topPautoAssignIds?: boolean (default true)Returns: Promise<z.infer<TSchema>>
createAgent<TSchema>(config?: AgentConfig<TSchema>)Returns an object with:
respond(prompt: string)getConfig()import { openai } from '@ai-sdk/openai';
await respond('Create a signup form', { llm: { provider: openai, model: 'gpt-4o-mini' } });
import { anthropic } from '@ai-sdk/anthropic';
await respond('Design a pricing table', { llm: { provider: anthropic, model: 'claude-3-5-sonnet-20241022' } });
import { google } from '@ai-sdk/google';
await respond('Build a user profile form', { llm: { provider: google, model: 'gemini-1.5-pro' } });
package.json fieldsnpm run build then npm publishApache 2.0 - See LICENSE file
Contributions welcome! Please open an issue or PR.
FAQs
A flexible AI agent library for generating structured UI components from natural language prompts
We found that dynamic-ui-agent demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.