The Open Standard for Generative UI
Add openUiChat library and update Renderer updateMessage prop (#276)
Aditya-thesys1c913f27fd06
diff --git a/docs/app/(home)/components/Footer.tsx b/docs/app/(home)/components/Footer.tsxindex 8dff47c6b..0b10bb40a 100644--- a/docs/app/(home)/components/Footer.tsx+++ b/docs/app/(home)/components/Footer.tsx@@ -20,21 +20,22 @@ interface SocialLink {const SOCIAL_LINKS: SocialLink[] = [{- label: "Discord",- href: "#",+ label: "Twitter",+ href: "https://x.com/thesysdev",viewBox: "0 0 24 24",path: svgPaths.pa1e7100,+ wrapperClass: "inset-[10.82%_4.33%_18.35%_4.17%]",},{- label: "Twitter",- href: "#",+ label: "Discord",+ href: "https://discord.com/invite/Pbv5PsqUSv",viewBox: "0 0 21.9611 17",path: svgPaths.p3885cd00,- wrapperClass: "inset-[10.82%_4.33%_18.35%_4.17%]",+},{label: "YouTube",- href: "#",+ href: "https://www.youtube.com/@thesysdev",viewBox: "0 0 22 15.4688",path: svgPaths.p23dbbd00,wrapperClass: "-translate-x-1/2 -translate-y-1/2 left-1/2 top-1/2 h-[15.469px] w-[22px]",@@ -43,7 +44,7 @@ const SOCIAL_LINKS: SocialLink[] = [},{label: "LinkedIn",- href: "#",+ href: "https://www.linkedin.com/company/thesysdev/",viewBox: "0 0 19 19",path: svgPaths.p26fc3100,wrapperClass: "-translate-x-1/2 -translate-y-1/2 left-1/2 top-1/2 size-[19px]",@@ -75,7 +76,7 @@ function SocialIcon({ link }: { link: SocialLink }) {);return (- <a href={link.href} className="size-6 relative" aria-label={link.label}>+ <a href={link.href} target="_blank" rel="noopener noreferrer" className="size-6 relative" aria-label={link.label}>{link.wrapperClass ? (<div className={`absolute ${link.wrapperClass}`}>{svgContent}</div>) : (diff --git a/docs/app/playground/components/CatalogPanel/CatalogPanel.tsx b/docs/app/playground/components/CatalogPanel/CatalogPanel.tsxindex 95245e754..333837335 100644--- a/docs/app/playground/components/CatalogPanel/CatalogPanel.tsx+++ b/docs/app/playground/components/CatalogPanel/CatalogPanel.tsx@@ -1,12 +1,12 @@"use client";import type { ComponentGroup } from "@openuidev/lang-react";-import { defaultLibrary } from "@openuidev/react-ui";+import { openuiLibrary } from "@openuidev/react-ui";import { ChevronLeft, ChevronRight, LayoutList } from "lucide-react";import { useState } from "react";import "./CatalogPanel.css";-const jsonSchemas = defaultLibrary.toJSONSchema() as Record<string, any>;+const jsonSchemas = openuiLibrary.toJSONSchema() as Record<string, any>;function getPropType(schemaProp: any): string {if (!schemaProp) return "any";@@ -82,7 +82,7 @@ export function CatalogPanel() {</button></div><div className={`catalog-panel-body${isCollapsed ? " catalog-panel-body--hidden" : ""}`}>- {defaultLibrary.componentGroups!.map((group: ComponentGroup) => {+ {openuiLibrary.componentGroups!.map((group: ComponentGroup) => {const groupExpanded = expandedComp !== null && group.components.includes(expandedComp);const props = groupExpanded ? getPropsForComponent(expandedComp!) : [];@@ -91,7 +91,7 @@ export function CatalogPanel() {<div className="catalog-group-name">{group.name}</div><div className="catalog-chips">{group.components.map((comp: string) => {- const desc = defaultLibrary.components[comp]?.description;+ const desc = openuiLibrary.components[comp]?.description;const isActive = expandedComp === comp;return (<span@@ -110,9 +110,9 @@ export function CatalogPanel() {<div className="catalog-prop-panel"><div className="catalog-prop-panel-header"><span className="catalog-prop-comp-name">{expandedComp}</span>- {defaultLibrary.components[expandedComp!]?.description && (+ {openuiLibrary.components[expandedComp!]?.description && (<p className="catalog-prop-desc">- {defaultLibrary.components[expandedComp!].description}+ {openuiLibrary.components[expandedComp!].description}</p>)}</div>diff --git a/docs/app/playground/components/PreviewPanel/PreviewPanel.tsx b/docs/app/playground/components/PreviewPanel/PreviewPanel.tsxindex 43f51059c..6dd60dbe9 100644--- a/docs/app/playground/components/PreviewPanel/PreviewPanel.tsx+++ b/docs/app/playground/components/PreviewPanel/PreviewPanel.tsx@@ -1,6 +1,6 @@import type { ParseResult } from "@openuidev/lang-react";import { Renderer } from "@openuidev/lang-react";-import { defaultLibrary, ThemeProvider } from "@openuidev/react-ui";+import { openuiLibrary, ThemeProvider } from "@openuidev/react-ui";import { Loader2, Maximize2, Monitor } from "lucide-react";import { useCallback, useEffect, useMemo, useState } from "react";import type { Theme } from "../../constants";@@ -39,7 +39,7 @@ export function PreviewPanel({ code, isStreaming, onParseResult, theme }: Previe<ThemeProvider mode={resolvedMode}><Rendererresponse={code}- library={defaultLibrary}+ library={openuiLibrary}isStreaming={isStreaming}onParseResult={onParseResult}/>diff --git a/docs/app/playground/page.tsx b/docs/app/playground/page.tsxindex f251ab783..43c68bb73 100644--- a/docs/app/playground/page.tsx+++ b/docs/app/playground/page.tsx@@ -1,6 +1,6 @@"use client";-import { defaultExamples, defaultLibrary } from "@openuidev/react-ui";+import { openuiExamples, openuiLibrary } from "@openuidev/react-ui";import { Send, Square } from "lucide-react";import { useCallback, useEffect, useRef, useState } from "react";import { CatalogPanel } from "./components/CatalogPanel/CatalogPanel";@@ -9,7 +9,7 @@ import { Header } from "./components/Header/Header";import { PreviewPanel } from "./components/PreviewPanel/PreviewPanel";import { MODELS, STARTER_PROMPTS, type Model, type Status, type Theme } from "./constants";-const SYSTEM_PROMPT = defaultLibrary.prompt({ examples: defaultExamples });+const SYSTEM_PROMPT = openuiLibrary.prompt({ examples: openuiExamples });export default function PlaygroundPage() {const [theme, setTheme] = useState<Theme>("system");diff --git a/docs/components/overview-components/overview-page.tsx b/docs/components/overview-components/overview-page.tsxindex 285612254..7b088c301 100644--- a/docs/components/overview-components/overview-page.tsx+++ b/docs/components/overview-components/overview-page.tsx@@ -222,11 +222,11 @@ export function AssistantMessage({ content, isStreaming }) {title="Quick example"code={`import "@openuidev/react-ui/components.css";import "@openuidev/react-ui/styles/index.css";-import { FullScreen, defaultLibrary } from "@openuidev/react-ui";+import { FullScreen, openuiLibrary } from "@openuidev/react-ui";<FullScreenapiUrl="/api/chat"- componentLibrary={defaultLibrary}+ componentLibrary={openuiLibrary}/>`}/>@@ -291,10 +291,10 @@ import { FullScreen, defaultLibrary } from "@openuidev/react-ui";<CodeBlocktitle="Quick example"code={`import { createLibrary, defineComponent } from '@openuidev/lang-react';-import { defaultLibrary, defaultPromptOptions } from '@openuidev/react-ui';+import { openuiLibrary, openuiPromptOptions } from '@openuidev/react-ui';import { z } from 'zod';-const prompt = defaultLibrary.prompt(defaultPromptOptions);+const prompt = openuiLibrary.prompt(openuiPromptOptions);const CustomWidget = defineComponent({name: 'CustomWidget',@@ -306,9 +306,9 @@ const CustomWidget = defineComponent({});const customLibrary = createLibrary({- root: defaultLibrary.root ?? 'Stack',- componentGroups: defaultLibrary.componentGroups,- components: [...Object.values(defaultLibrary.components), CustomWidget],+ root: openuiLibrary.root ?? 'Stack',+ componentGroups: openuiLibrary.componentGroups,+ components: [...Object.values(openuiLibrary.components), CustomWidget],});`}/></TabsContent>@@ -316,13 +316,13 @@ const customLibrary = createLibrary({<TabsContent value="usage-with-chat" className="mt-4"><CodeBlocktitle="Using with Chat UI"- code={`import { Copilot, defaultLibrary } from '@openuidev/react-ui';+ code={`import { Copilot, openuiLibrary } from '@openuidev/react-ui';function App() {return (<CopilotapiUrl="/api/chat"- componentLibrary={defaultLibrary}+ componentLibrary={openuiLibrary}/>);}`}diff --git a/docs/content/docs/api-reference/lang-react.mdx b/docs/content/docs/api-reference/lang-react.mdxindex 90ba51248..09bba5588 100644--- a/docs/content/docs/api-reference/lang-react.mdx+++ b/docs/content/docs/api-reference/lang-react.mdx@@ -91,7 +91,8 @@ interface RendererProps {library: Library;isStreaming?: boolean;onAction?: (event: ActionEvent) => void;- updateMessage?: (message: string) => void;+ onStateUpdate?: (state: Record<string, any>) => void;+ initialState?: Record<string, any>;onParseResult?: (result: ParseResult | null) => void;}```@@ -108,7 +109,8 @@ interface ActionEvent {type: string;params: Record<string, any>;humanFriendlyMessage: string;- llmFriendlyMessage: string;+ formState?: Record<string, any>;+ formName?: string;}```@@ -173,7 +175,6 @@ interface ParseResult {function useRenderNode(): (value: unknown) => React.ReactNode;function useTriggerAction(): (userMessage: string,- actionContext: string,formName?: string,action?: { type?: string; params?: Record<string, any> },) => void;@@ -219,13 +220,3 @@ function parseRules(rules: unknown): ParsedRule[];const builtInValidators: Record<string, ValidatorFn>;```-## Message/context utilities--```ts-function wrapContent(text: string): string;-function wrapContext(json: string): string;-function separateContentAndContext(raw: string): {- content: string;- contextString: string | null;-};-```diff --git a/docs/content/docs/api-reference/react-ui.mdx b/docs/content/docs/api-reference/react-ui.mdxindex 4888b6f7a..2a7ec6632 100644--- a/docs/content/docs/api-reference/react-ui.mdx+++ b/docs/content/docs/api-reference/react-ui.mdx@@ -95,28 +95,33 @@ interface ConversationStartersConfig {}```-## Default component library exports+## Component library exports-The default library and prompt helpers for OpenUI Lang:+Two ready-to-use libraries ship with `@openuidev/react-ui`. Import from the `genui-lib` subpath:```tsimport {- defaultLibrary,- defaultPromptOptions,- defaultExamples,- defaultAdditionalRules,- defaultComponentGroups,-} from "@openuidev/react-ui";+ // Chat-optimised (root = Card, includes FollowUpBlock, ListBlock, SectionBlock)+ openuiChatLibrary,+ openuiChatPromptOptions,++ // General-purpose (root = Stack, full component suite)+ openuiLibrary,+ openuiPromptOptions,+ openuiExamples,+ openuiAdditionalRules,+ openuiComponentGroups,+} from "@openuidev/react-ui/genui-lib";```-These exports are built with `createLibrary(...)` from `@openuidev/lang-react` and are ready to use:+Use `openuiChatLibrary` with `FullScreen` / `BottomTray` chat interfaces. Use `openuiLibrary` with the standalone `Renderer` or any non-chat layout.```tsx-<Renderer response={message} library={defaultLibrary} />-```--Generate the system prompt with:+// Chat interface+const systemPrompt = openuiChatLibrary.prompt(openuiChatPromptOptions);+<FullScreen componentLibrary={openuiChatLibrary} ... />-```ts-const systemPrompt = defaultLibrary.prompt(defaultPromptOptions);+// Standalone renderer+const systemPrompt = openuiLibrary.prompt(openuiPromptOptions);+<Renderer response={message} library={openuiLibrary} />```diff --git a/docs/content/docs/chat/connecting.mdx b/docs/content/docs/chat/connecting.mdxindex d6e9e8418..a33b064eb 100644--- a/docs/content/docs/chat/connecting.mdx+++ b/docs/content/docs/chat/connecting.mdx@@ -35,9 +35,9 @@ With `apiUrl`, OpenUI sends the message history to your endpoint for you. If you```tsximport { openAIMessageFormat, openAIReadableStreamAdapter } from "@openuidev/react-headless";import { FullScreen } from "@openuidev/react-ui";-import { defaultLibrary, defaultPromptOptions } from "@openuidev/react-ui/genui-lib";+import { openuiLibrary, openuiPromptOptions } from "@openuidev/react-ui/genui-lib";-const systemPrompt = defaultLibrary.prompt(defaultPromptOptions);+const systemPrompt = openuiLibrary.prompt(openuiPromptOptions);<FullScreenprocessMessage={async ({ messages, abortController }) => {@@ -55,7 +55,7 @@ const systemPrompt = defaultLibrary.prompt(defaultPromptOptions);});}}streamProtocol={openAIReadableStreamAdapter()}- componentLibrary={defaultLibrary}+ componentLibrary={openuiLibrary}agentName="Assistant"/>;```diff --git a/docs/content/docs/chat/from-scratch.mdx b/docs/content/docs/chat/from-scratch.mdxindex 6f5c80a35..68c2b9e64 100644--- a/docs/content/docs/chat/from-scratch.mdx+++ b/docs/content/docs/chat/from-scratch.mdx@@ -27,9 +27,9 @@ If you want Generative UI, generate a system prompt from the component library aIf you only want plain text chat, you can skip this step and omit `componentLibrary` and `systemPrompt` in the next examples.```tsx-import { defaultLibrary, defaultPromptOptions } from "@openuidev/react-ui/genui-lib";+import { openuiLibrary, openuiPromptOptions } from "@openuidev/react-ui/genui-lib";-const systemPrompt = defaultLibrary.prompt(defaultPromptOptions);+const systemPrompt = openuiLibrary.prompt(openuiPromptOptions);```This prompt tells the model which UI components it is allowed to emit.@@ -88,9 +88,9 @@ This guide uses `processMessage` instead of `apiUrl` so the request body stays e```tsximport { openAIMessageFormat, openAIReadableStreamAdapter } from "@openuidev/react-headless";import { FullScreen } from "@openuidev/react-ui";-import { defaultLibrary, defaultPromptOptions } from "@openuidev/react-ui/genui-lib";+import { openuiLibrary, openuiPromptOptions } from "@openuidev/react-ui/genui-lib";-const systemPrompt = defaultLibrary.prompt(defaultPromptOptions);+const systemPrompt = openuiLibrary.prompt(openuiPromptOptions);export default function Page() {return (@@ -109,7 +109,7 @@ export default function Page() {}}messageFormat={openAIMessageFormat}streamProtocol={openAIReadableStreamAdapter()}- componentLibrary={defaultLibrary}+ componentLibrary={openuiLibrary}agentName="Assistant"/></div>@@ -122,7 +122,7 @@ Why this setup matters:- `processMessage` gives you control over the request body- `messageFormat={openAIMessageFormat}` converts the messages before they reach your route- `openAIReadableStreamAdapter()` matches `response.toReadableStream()`-- `componentLibrary={defaultLibrary}` lets the UI render structured responses+- `componentLibrary={openuiLibrary}` lets the UI render structured responses### Checkpoint@@ -154,7 +154,7 @@ If you want the UI to load saved threads and previous messages, add `threadApiUrthreadApiUrl="/api/threads"streamProtocol={openAIReadableStreamAdapter()}messageFormat={openAIMessageFormat}- componentLibrary={defaultLibrary}+ componentLibrary={openuiLibrary}agentName="Assistant"/>```diff --git a/docs/content/docs/chat/genui.mdx b/docs/content/docs/chat/genui.mdxindex e4b072b39..0e4c8289f 100644--- a/docs/content/docs/chat/genui.mdx+++ b/docs/content/docs/chat/genui.mdx@@ -17,16 +17,16 @@ The frontend and backend have different jobs here:If either side is missing, the model falls back to plain text or emits components the UI cannot render.-## Use the default library+## Use the chat library-`defaultLibrary` is the fastest way to enable GenUI because it ships with ready-to-use components and example prompt rules.+`openuiChatLibrary` is optimised for conversational chat: every response is wrapped in a `Card`, and it includes chat-specific components like `FollowUpBlock`, `ListBlock`, and `SectionBlock`.```tsx-import { openAIMessageFormat, openAIReadableStreamAdapter } from "@openuidev/react-headless";+import { openAIAdapter, openAIMessageFormat } from "@openuidev/react-headless";import { FullScreen } from "@openuidev/react-ui";-import { defaultLibrary, defaultPromptOptions } from "@openuidev/react-ui/genui-lib";+import { openuiChatLibrary, openuiChatPromptOptions } from "@openuidev/react-ui/genui-lib";-const systemPrompt = defaultLibrary.prompt(defaultPromptOptions);+const systemPrompt = openuiChatLibrary.prompt(openuiChatPromptOptions);export default function Page() {return (@@ -36,15 +36,14 @@ export default function Page() {method: "POST",headers: { "Content-Type": "application/json" },body: JSON.stringify({- messages,+ messages: openAIMessageFormat.toApi(messages),systemPrompt,}),signal: abortController.signal,});}}- messageFormat={openAIMessageFormat}- streamProtocol={openAIReadableStreamAdapter()}- componentLibrary={defaultLibrary}+ streamProtocol={openAIAdapter()}+ componentLibrary={openuiChatLibrary}agentName="Assistant"/>);@@ -53,12 +52,13 @@ export default function Page() {In this setup:-- `defaultLibrary.prompt(defaultPromptOptions)` creates the system prompt+- `openuiChatLibrary.prompt(openuiChatPromptOptions)` creates the system prompt- `systemPrompt` is sent with every request-- `messageFormat={openAIMessageFormat}` converts messages to the backend format-- `componentLibrary={defaultLibrary}` tells the UI how to render the model output+- `openAIMessageFormat.toApi(messages)` converts messages before sending+- `componentLibrary={openuiChatLibrary}` tells the UI how to render the model output+- `openAIAdapter()` parses raw SSE chunks from the backend-This is the minimal complete pattern for GenUI with the built-in library.+This is the minimal complete pattern for GenUI in a chat interface. For a non-chat renderer or custom layout, use `openuiLibrary` and `openuiPromptOptions` from the same import path.{/* add visual: image showing the difference between a plain text assistant response and a GenUI-rendered component response */}diff --git a/docs/content/docs/chat/nextjs.mdx b/docs/content/docs/chat/nextjs.mdxindex 23b35d1ac..f3f2bfe31 100644--- a/docs/content/docs/chat/nextjs.mdx+++ b/docs/content/docs/chat/nextjs.mdx@@ -67,9 +67,9 @@ Use `processMessage` here because the client needs to send both `messages` and ````tsximport { openAIMessageFormat, openAIReadableStreamAdapter } from "@openuidev/react-headless";import { FullScreen } from "@openuidev/react-ui";-import { defaultLibrary, defaultPromptOptions } from "@openuidev/react-ui/genui-lib";+import { openuiLibrary, openuiPromptOptions } from "@openuidev/react-ui/genui-lib";-const systemPrompt = defaultLibrary.prompt(defaultPromptOptions);+const systemPrompt = openuiLibrary.prompt(openuiPromptOptions);<FullScreenprocessMessage={async ({ messages, abortController }) => {@@ -85,7 +85,7 @@ const systemPrompt = defaultLibrary.prompt(defaultPromptOptions);}}messageFormat={openAIMessageFormat}streamProtocol={openAIReadableStreamAdapter()}- componentLibrary={defaultLibrary}+ componentLibrary={openuiLibrary}agentName="Assistant"/>;```diff --git a/docs/content/docs/chat/quick-start.mdx b/docs/content/docs/chat/quick-start.mdxindex 60bf0f3f2..b7310765a 100644--- a/docs/content/docs/chat/quick-start.mdx+++ b/docs/content/docs/chat/quick-start.mdx@@ -90,9 +90,9 @@ The frontend renders `FullScreen`, sends requests with `processMessage`, relies```tsximport { openAIMessageFormat, openAIReadableStreamAdapter } from "@openuidev/react-headless";import { FullScreen } from "@openuidev/react-ui";-import { defaultLibrary, defaultPromptOptions } from "@openuidev/react-ui/genui-lib";+import { openuiLibrary, openuiPromptOptions } from "@openuidev/react-ui/genui-lib";-const systemPrompt = defaultLibrary.prompt(defaultPromptOptions);+const systemPrompt = openuiLibrary.prompt(openuiPromptOptions);export default function Page() {return (@@ -110,7 +110,7 @@ export default function Page() {}}messageFormat={openAIMessageFormat}streamProtocol={openAIReadableStreamAdapter()}- componentLibrary={defaultLibrary}+ componentLibrary={openuiLibrary}agentName="OpenUI Chat"/>);@@ -133,7 +133,7 @@ That is why the frontend uses:- `processMessage` instead of a plain `apiUrl`- `messageFormat={openAIMessageFormat}` for request conversion- `openAIReadableStreamAdapter()` for stream parsing-- `defaultLibrary` plus `systemPrompt` for GenUI rendering+- `openuiLibrary` plus `systemPrompt` for GenUI rendering## Next stepsdiff --git a/docs/content/docs/openui-lang/index.mdx b/docs/content/docs/openui-lang/index.mdxindex ecd57f7bc..26bee8281 100644--- a/docs/content/docs/openui-lang/index.mdx+++ b/docs/content/docs/openui-lang/index.mdx@@ -34,11 +34,11 @@ It is designed for:```tsximport "@openuidev/react-ui/components.css";import { Renderer } from "@openuidev/lang-react";-import { defaultLibrary, defaultPromptOptions } from "@openuidev/react-ui";+import { openuiLibrary, openuiPromptOptions } from "@openuidev/react-ui";-const systemPrompt = defaultLibrary.prompt(defaultPromptOptions);+const systemPrompt = openuiLibrary.prompt(openuiPromptOptions);-<Renderer library={defaultLibrary} response={openuiLangText} isStreaming={isStreaming} />;+<Renderer library={openuiLibrary} response={openuiLangText} isStreaming={isStreaming} />;```Example OpenUI Lang output:diff --git a/docs/content/docs/openui-lang/prompts.mdx b/docs/content/docs/openui-lang/prompts.mdxindex 7c8d483c2..33716f183 100644--- a/docs/content/docs/openui-lang/prompts.mdx+++ b/docs/content/docs/openui-lang/prompts.mdx@@ -12,9 +12,9 @@ The canonical prompt documentation is:Quick example:```ts-import { defaultLibrary, defaultPromptOptions } from "@openuidev/react-ui";+import { openuiLibrary, openuiPromptOptions } from "@openuidev/react-ui";-const systemPrompt = defaultLibrary.prompt(defaultPromptOptions);+const systemPrompt = openuiLibrary.prompt(openuiPromptOptions);```<Callout type="info">diff --git a/docs/content/docs/openui-lang/quickstart.mdx b/docs/content/docs/openui-lang/quickstart.mdxindex 809d8c758..2cc45f13f 100644--- a/docs/content/docs/openui-lang/quickstart.mdx+++ b/docs/content/docs/openui-lang/quickstart.mdx@@ -3,7 +3,7 @@ title: Quick Startdescription: Use the default library to render OpenUI Lang immediately.----This is the fastest path: use `defaultLibrary` from `@openuidev/react-ui` and render LLM output with `@openuidev/lang-react`.+This is the fastest path: use `openuiLibrary` from `@openuidev/react-ui` and render LLM output with `@openuidev/lang-react`.## Installation@@ -16,17 +16,17 @@ npm install @openuidev/lang-react @openuidev/react-ui```tsximport "@openuidev/react-ui/components.css";import { Renderer } from "@openuidev/lang-react";-import { defaultLibrary } from "@openuidev/react-ui";+import { openuiLibrary } from "@openuidev/react-ui";-<Renderer library={defaultLibrary} response={streamedText} isStreaming={isStreaming} />;+<Renderer library={openuiLibrary} response={streamedText} isStreaming={isStreaming} />;```## Generate prompt```ts-import { defaultLibrary, defaultPromptOptions } from "@openuidev/react-ui";+import { openuiLibrary, openuiPromptOptions } from "@openuidev/react-ui";-const systemPrompt = defaultLibrary.prompt(defaultPromptOptions);+const systemPrompt = openuiLibrary.prompt(openuiPromptOptions);```Use `systemPrompt` as your model system message.@@ -35,7 +35,7 @@ Use `systemPrompt` as your model system message.```tsimport OpenAI from "openai";-import { defaultLibrary, defaultPromptOptions } from "@openuidev/react-ui";+import { openuiLibrary, openuiPromptOptions } from "@openuidev/react-ui";const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });@@ -46,7 +46,7 @@ export async function POST(req: Request) {model: "gpt-5.2",stream: true,messages: [- { role: "system", content: defaultLibrary.prompt(defaultPromptOptions) },+ { role: "system", content: openuiLibrary.prompt(openuiPromptOptions) },...messages,],});diff --git a/docs/content/docs/openui-lang/renderer.mdx b/docs/content/docs/openui-lang/renderer.mdxindex fa794a539..c22039676 100644--- a/docs/content/docs/openui-lang/renderer.mdx+++ b/docs/content/docs/openui-lang/renderer.mdx@@ -9,7 +9,7 @@ description: Parse and render OpenUI Lang streams in React.```tsximport { Renderer } from "@openuidev/lang-react";-import { defaultLibrary } from "@openuidev/react-ui";+import { openuiLibrary } from "@openuidev/react-ui";export function AssistantMessage({content,@@ -18,20 +18,21 @@ export function AssistantMessage({content: string | null;isStreaming: boolean;}) {- return <Renderer library={defaultLibrary} response={content} isStreaming={isStreaming} />;+ return <Renderer library={openuiLibrary} response={content} isStreaming={isStreaming} />;}```## Props-| Prop | Type | Description |-| :-------------- | :-------------------------------------- | :------------------------------------------------------------- |-| `response` | `string \| null` | Raw OpenUI Lang response text. |-| `library` | `Library` | Library created by `createLibrary(...)`. |-| `isStreaming` | `boolean` | Indicates stream is in progress. |-| `onAction` | `(event: ActionEvent) => void` | Receives structured action events from interactive components. |-| `updateMessage` | `(message: string) => void` | Persists message + context updates from form interactions. |-| `onParseResult` | `(result: ParseResult \| null) => void` | Debug/inspect latest parse result. |+| Prop | Type | Description |+| :--------------- | :-------------------------------------- | :------------------------------------------------------------- |+| `response` | `string \| null` | Raw OpenUI Lang response text. |+| `library` | `Library` | Library created by `createLibrary(...)`. |+| `isStreaming` | `boolean` | Indicates stream is in progress. |+| `onAction` | `(event: ActionEvent) => void` | Receives structured action events from interactive components. |+| `onStateUpdate` | `(state: Record<string, any>) => void` | Called on form field changes with the raw field state map. |+| `initialState` | `Record<string, any>` | Hydrates form state on load (e.g. from persisted message). |+| `onParseResult` | `(result: ParseResult \| null) => void` | Debug/inspect latest parse result. |## Streaming behavior@@ -44,11 +45,12 @@ export function AssistantMessage({```tsx<Renderer- library={defaultLibrary}+ library={openuiLibrary}response={content}onAction={(event) => {if (event.type === "continue_conversation") {- // event.params has llm/human-friendly messages+ // event.humanFriendlyMessage — display label+ // event.formState — raw field values at time of action}}}/>diff --git a/docs/content/docs/openui-lang/standard-library.mdx b/docs/content/docs/openui-lang/standard-library.mdxindex 9b44bbb39..f1b264197 100644--- a/docs/content/docs/openui-lang/standard-library.mdx+++ b/docs/content/docs/openui-lang/standard-library.mdx@@ -3,7 +3,7 @@ title: Using the Standard Librarydescription: Use the built-in default library from @openuidev/react-ui.----OpenUI ships with a prebuilt `defaultLibrary` for common layouts, forms, content, and charts.+OpenUI ships with a prebuilt `openuiLibrary` for common layouts, forms, content, and charts.## Install@@ -16,24 +16,24 @@ npm install @openuidev/lang-react @openuidev/react-ui```tsximport "@openuidev/react-ui/components.css";import { Renderer } from "@openuidev/lang-react";-import { defaultLibrary } from "@openuidev/react-ui";+import { openuiLibrary } from "@openuidev/react-ui";-<Renderer library={defaultLibrary} response={streamedText} isStreaming={isStreaming} />;+<Renderer library={openuiLibrary} response={streamedText} isStreaming={isStreaming} />;```## Generate prompt```ts-import { defaultLibrary, defaultPromptOptions } from "@openuidev/react-ui";+import { openuiLibrary, openuiPromptOptions } from "@openuidev/react-ui";-const systemPrompt = defaultLibrary.prompt(defaultPromptOptions);+const systemPrompt = openuiLibrary.prompt(openuiPromptOptions);```## Extend it```tsimport { createLibrary, defineComponent } from "@openuidev/lang-react";-import { defaultLibrary } from "@openuidev/react-ui";+import { openuiLibrary } from "@openuidev/react-ui";import { z } from "zod";const ProductCard = defineComponent({@@ -47,9 +47,9 @@ const ProductCard = defineComponent({});const myLibrary = createLibrary({- root: defaultLibrary.root ?? "Stack",- componentGroups: defaultLibrary.componentGroups,- components: [...Object.values(defaultLibrary.components), ProductCard],+ root: openuiLibrary.root ?? "Stack",+ componentGroups: openuiLibrary.componentGroups,+ components: [...Object.values(openuiLibrary.components), ProductCard],});```@@ -57,4 +57,4 @@ const myLibrary = createLibrary({- Default root component is `Stack`.- `Form` requires explicit `buttons`.-- Signature truth source is `defaultLibrary.prompt(defaultPromptOptions)`.+- Signature truth source is `openuiLibrary.prompt(openuiPromptOptions)`.diff --git a/docs/content/docs/openui-lang/syntax.mdx b/docs/content/docs/openui-lang/syntax.mdxindex 8f85c3e48..949b50e1b 100644--- a/docs/content/docs/openui-lang/syntax.mdx+++ b/docs/content/docs/openui-lang/syntax.mdx@@ -64,5 +64,5 @@ cancelBtn = Button("Cancel", "action:cancel", "secondary")For full generated signatures, inspect:```ts-defaultLibrary.prompt(defaultPromptOptions);+openuiLibrary.prompt(openuiPromptOptions);```diff --git a/docs/content/docs/openui-lang/system-prompts.mdx b/docs/content/docs/openui-lang/system-prompts.mdxindex 64b7e73d5..4c6ec510d 100644--- a/docs/content/docs/openui-lang/system-prompts.mdx+++ b/docs/content/docs/openui-lang/system-prompts.mdx@@ -8,9 +8,9 @@ description: Generate and customize prompt instructions from your OpenUI library## Generate prompt```ts-import { defaultLibrary, defaultPromptOptions } from "@openuidev/react-ui";+import { openuiLibrary, openuiPromptOptions } from "@openuidev/react-ui";-const systemPrompt = defaultLibrary.prompt(defaultPromptOptions);+const systemPrompt = openuiLibrary.prompt(openuiPromptOptions);```## Prompt options@@ -24,7 +24,7 @@ const options: PromptOptions = {examples: [`root = Stack([title])\ntitle = TextContent("Hello")`],};-const prompt = defaultLibrary.prompt(options);+const prompt = openuiLibrary.prompt(options);```## What gets generated@@ -46,7 +46,7 @@ The generated prompt includes:```tsimport OpenAI from "openai";-import { defaultLibrary, defaultPromptOptions } from "@openuidev/react-ui";+import { openuiLibrary, openuiPromptOptions } from "@openuidev/react-ui";const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });@@ -57,7 +57,7 @@ export async function POST(req: Request) {model: "gpt-5.2",stream: true,messages: [- { role: "system", content: defaultLibrary.prompt(defaultPromptOptions) },+ { role: "system", content: openuiLibrary.prompt(openuiPromptOptions) },...messages,],});diff --git a/examples/openui-chat/src/app/agent/page.tsx b/examples/openui-chat/src/app/agent/page.tsxdeleted file mode 100644index 4f29fbdeb..000000000--- a/examples/openui-chat/src/app/agent/page.tsx+++ /dev/null@@ -1,97 +0,0 @@-"use client";-import "@openuidev/react-ui/components.css";-import "@openuidev/react-ui/styles/index.css";--import { openAIAdapter, openAIMessageFormat } from "@openuidev/react-headless";-import { FullScreen } from "@openuidev/react-ui";-import { defaultExamples, defaultLibrary } from "@openuidev/react-ui/genui-lib";-import Link from "next/link";-import { useState } from "react";--const systemPrompt = `You are a helpful AI agent with access to tools. Use them when appropriate.--Available tools:-- get_weather: Get current weather for any city-- get_stock_price: Get stock prices by ticker symbol (e.g. AAPL, GOOGL)-- calculate: Evaluate math expressions-- search_web: Search the web for information--Always use the appropriate tool when the user asks about weather, stocks, math, or needs web information. Present results clearly using markdown and GenUI components.--${defaultLibrary.prompt({ examples: defaultExamples })}`;--export default function AgentPage() {- const [mode, setMode] = useState<"light" | "dark">("light");-- return (- <div className="h-screen w-screen overflow-hidden relative">- <nav- style={{- position: "absolute",- top: 16,- right: 16,- zIndex: 50,- display: "flex",- gap: 8,- alignItems: "center",- }}- >- <button- onClick={() => setMode((m) => (m === "light" ? "dark" : "light"))}- style={{- fontSize: 13,- padding: "6px 12px",- borderRadius: 6,- border: "1px solid rgba(128,128,128,0.3)",- background: mode === "dark" ? "rgba(255,255,255,0.1)" : "rgba(0,0,0,0.05)",- color: mode === "dark" ? "#fff" : "#333",- cursor: "pointer",- backdropFilter: "blur(8px)",- }}- >- {mode === "light" ? "Switch to Dark" : "Switch to Light"}- </button>- <Link- href="/"- style={{- fontSize: 13,- padding: "6px 12px",- borderRadius: 6,- border: "1px solid rgba(128,128,128,0.3)",- background: mode === "dark" ? "rgba(255,255,255,0.1)" : "rgba(0,0,0,0.05)",- color: mode === "dark" ? "#fff" : "#333",- textDecoration: "none",- backdropFilter: "blur(8px)",- }}- >- ← Home- </Link>- </nav>- <FullScreen- processMessage={async ({ messages, abortController }) => {- return fetch("/api/agent", {- method: "POST",- headers: { "Content-Type": "application/json" },- body: JSON.stringify({- messages: openAIMessageFormat.toApi(messages),- systemPrompt,- }),- signal: abortController.signal,- });- }}- streamProtocol={openAIAdapter()}- componentLibrary={defaultLibrary}- theme={{ mode }}- agentName="GenUI Agent"- conversationStarters={{- variant: "short",- options: [- { displayText: "Weather in Tokyo", prompt: "What's the weather like in Tokyo right now?" },- { displayText: "AAPL stock price", prompt: "What's the current stock price for AAPL?" },- { displayText: "Calculate something", prompt: "What is (42 * 17) + sqrt(144)?" },- ],- }}- />- </div>- );-}diff --git a/examples/openui-chat/src/app/api/agent/route.ts b/examples/openui-chat/src/app/api/agent/route.tsdeleted file mode 100644index 2d37e7930..000000000--- a/examples/openui-chat/src/app/api/agent/route.ts+++ /dev/null@@ -1,341 +0,0 @@-import { NextRequest } from "next/server";-import OpenAI from "openai";-import type { ChatCompletionMessageParam } from "openai/resources/chat/completions.mjs";--// ── Tool implementations ──--function getWeather({ location }: { location: string }): Promise<string> {- return new Promise((resolve) => {- setTimeout(() => {- const knownTemps: Record<string, number> = {- tokyo: 22,- "san francisco": 18,- london: 14,- "new york": 25,- paris: 19,- sydney: 27,- mumbai: 33,- berlin: 16,- };- const conditions = ["Sunny", "Partly Cloudy", "Cloudy", "Light Rain", "Clear Skies"];- const temp = knownTemps[location.toLowerCase()] ?? Math.floor(Math.random() * 30 + 5);- const condition = conditions[Math.floor(Math.random() * conditions.length)];- resolve(- JSON.stringify({- location,- temperature_celsius: temp,- temperature_fahrenheit: Math.round(temp * 1.8 + 32),- condition,- humidity_percent: Math.floor(Math.random() * 40 + 40),- wind_speed_kmh: Math.floor(Math.random() * 25 + 5),- forecast: [- { day: "Tomorrow", high: temp + 2, low: temp - 4, condition: "Partly Cloudy" },- { day: "Day After", high: temp + 1, low: temp - 3, condition: "Sunny" },- ],- }),- );- }, 800);- });-}--function getStockPrice({ symbol }: { symbol: string }): Promise<string> {- return new Promise((resolve) => {- setTimeout(() => {- const s = symbol.toUpperCase();- const knownPrices: Record<string, number> = {- AAPL: 189.84,- GOOGL: 141.8,- TSLA: 248.42,- MSFT: 378.91,- AMZN: 178.25,- NVDA: 875.28,- META: 485.58,- };- const price = knownPrices[s] ?? Math.floor(Math.random() * 500 + 20);- const change = parseFloat((Math.random() * 8 - 4).toFixed(2));- resolve(- JSON.stringify({- symbol: s,- price: parseFloat((price + change).toFixed(2)),- change,- change_percent: parseFloat(((change / price) * 100).toFixed(2)),- volume: `${(Math.random() * 50 + 10).toFixed(1)}M`,- day_high: parseFloat((price + Math.abs(change) + 1.5).toFixed(2)),- day_low: parseFloat((price - Math.abs(change) - 1.2).toFixed(2)),- }),- );- }, 600);- });-}--function calculate({ expression }: { expression: string }): Promise<string> {- return new Promise((resolve) => {- setTimeout(() => {- try {- const sanitized = expression.replace(- /[^0-9+\-*/().%\s,Math.sqrtpowabsceilfloorround]/g,- "",- );- const result = new Function(`return (${sanitized})`)();- resolve(JSON.stringify({ expression, result: Number(result) }));- } catch {- resolve(JSON.stringify({ expression, error: "Invalid expression" }));- }- }, 300);- });-}--function searchWeb({ query }: { query: string }): Promise<string> {- return new Promise((resolve) => {- setTimeout(() => {- resolve(- JSON.stringify({- query,- results: [- {- title: `Top result for "${query}"`,- snippet: `Comprehensive overview of ${query} with the latest information.`,- },- {- title: `${query} - Latest News`,- snippet: `Recent developments and updates related to ${query}.`,- },- {- title: `Understanding ${query}`,- snippet: `An in-depth guide explaining everything about ${query}.`,- },- ],- }),- );- }, 1000);- });-}--// ── Runnable tools — schema + implementation co-located ──--// eslint-disable-next-line @typescript-eslint/no-explicit-any-const tools: any[] = [- {- type: "function",- function: {- name: "get_weather",- description: "Get current weather for a location.",- parameters: {- type: "object",- properties: { location: { type: "string", description: "City name" } },- required: ["location"],- },- function: getWeather,- parse: JSON.parse,- },- },- {- type: "function",- function: {- name: "get_stock_price",- description: "Get stock price for a ticker symbol.",- parameters: {- type: "object",- properties: { symbol: { type: "string", description: "Ticker symbol, e.g. AAPL" } },- required: ["symbol"],- },- function: getStockPrice,- parse: JSON.parse,- },- },- {- type: "function",- function: {- name: "calculate",- description: "Evaluate a math expression.",- parameters: {- type: "object",- properties: { expression: { type: "string", description: "Math expression" } },- required: ["expression"],- },- function: calculate,- parse: JSON.parse,- },- },- {- type: "function",- function: {- name: "search_web",- description: "Search the web for information.",- parameters: {- type: "object",- properties: { query: { type: "string", description: "Search query" } },- required: ["query"],- },- function: searchWeb,- parse: JSON.parse,- },- },-];--// ── SSE helpers ──--function sseToolCallStart(- encoder: TextEncoder,- tc: { id: string; function: { name: string } },- index: number,-) {- return encoder.encode(- `data: ${JSON.stringify({- id: `chatcmpl-tc-${tc.id}`,- object: "chat.completion.chunk",- choices: [- {- index: 0,- delta: {- tool_calls: [- {- index,- id: tc.id,- type: "function",- function: { name: tc.function.name, arguments: "" },- },- ],- },- finish_reason: null,- },- ],- })}\n\n`,- );-}--function sseToolCallArgs(- encoder: TextEncoder,- tc: { id: string; function: { arguments: string } },- result: string,- index: number,-) {- let enrichedArgs: string;- try {- enrichedArgs = JSON.stringify({- _request: JSON.parse(tc.function.arguments),- _response: JSON.parse(result),- });- } catch {- enrichedArgs = tc.function.arguments;- }- return encoder.encode(- `data: ${JSON.stringify({- id: `chatcmpl-tc-${tc.id}-args`,- object: "chat.completion.chunk",- choices: [- {- index: 0,- delta: {- tool_calls: [{ index, function: { arguments: enrichedArgs } }],- },- finish_reason: null,- },- ],- })}\n\n`,- );-}--// ── Route handler ──--export async function POST(req: NextRequest) {- const { messages, systemPrompt } = await req.json();-- const client = new OpenAI({- apiKey: process.env.OPENROUTER_API_KEY,- baseURL: "https://openrouter.ai/api/v1",- });- const MODEL = "anthropic/claude-sonnet-4.6";-- const chatMessages: ChatCompletionMessageParam[] = [- ...(systemPrompt ? [{ role: "system" as const, content: systemPrompt }] : []),- ...messages,- ];-- const encoder = new TextEncoder();-- const readable = new ReadableStream({- start(controller) {- const pendingCalls: Array<{ id: string; name: string; arguments: string }> = [];- let callIdx = 0;- let resultIdx = 0;-- // eslint-disable-next-line @typescript-eslint/no-explicit-any- const runner = (client.chat.completions as any).runTools({- model: MODEL,- messages: chatMessages,- tools,- stream: true,- provider: { order: ["anthropic"] },- });-- // Tool dispatch → send TOOL_CALL_START- // eslint-disable-next-line @typescript-eslint/no-explicit-any- runner.on("functionToolCall", (fc: any) => {- const id = `tc-${callIdx}`;- console.log(`[TOOL CALL] ${fc.name}(${fc.arguments})`);- pendingCalls.push({ id, name: fc.name, arguments: fc.arguments });- controller.enqueue(sseToolCallStart(encoder, { id, function: { name: fc.name } }, callIdx));- callIdx++;- });-- // Tool result → send TOOL_CALL_ARGS with enriched request+response- runner.on("functionToolCallResult", (result: string) => {- const tc = pendingCalls[resultIdx];- if (tc) {- console.log(`[TOOL RESULT] ${result.slice(0, 200)}${result.length > 200 ? "..." : ""}`);- controller.enqueue(- sseToolCallArgs(- encoder,- { id: tc.id, function: { arguments: tc.arguments } },- result,- resultIdx,- ),- );- }- resultIdx++;- });-- // Text content chunks → forward to client in real time- // eslint-disable-next-line @typescript-eslint/no-explicit-any- runner.on("chunk", (chunk: any) => {- const choice = chunk.choices?.[0];- const delta = choice?.delta;- if (!delta) return;-- if (delta.content) {- controller.enqueue(encoder.encode(`data: ${JSON.stringify(chunk)}\n\n`));- }- if (choice?.finish_reason === "stop") {- controller.enqueue(encoder.encode(`data: ${JSON.stringify(chunk)}\n\n`));- }- });-- // Runner fully done (all rounds complete) → close the stream- runner.on("end", () => {- controller.enqueue(encoder.encode("data: [DONE]\n\n"));- controller.close();- });-- // eslint-disable-next-line @typescript-eslint/no-explicit-any- runner.on("error", (err: any) => {- const msg = err instanceof Error ? err.message : "Stream error";- console.error("Agent route error:", msg);- try {- controller.enqueue(encoder.encode(`data: ${JSON.stringify({ error: msg })}\n\n`));- controller.close();- } catch {- // controller may already be closed- }- });- },- });-- return new Response(readable, {- headers: {- "Content-Type": "text/event-stream",- "Cache-Control": "no-cache, no-transform",- Connection: "keep-alive",- },- });-}diff --git a/examples/openui-chat/src/app/api/chat/route.ts b/examples/openui-chat/src/app/api/chat/route.tsindex aa63a8db8..ec81a0adb 100644--- a/examples/openui-chat/src/app/api/chat/route.ts+++ b/examples/openui-chat/src/app/api/chat/route.ts@@ -1,36 +1,300 @@import { NextRequest } from "next/server";import OpenAI from "openai";+import type { ChatCompletionMessageParam } from "openai/resources/chat/completions.mjs";+// ── Tool implementations ──-export async function POST(req: NextRequest) {- const client = new OpenAI();- try {- const { messages, systemPrompt } = await req.json();+function getWeather({ location }: { location: string }): Promise<string> {+ return new Promise((resolve) => {+ setTimeout(() => {+ const knownTemps: Record<string, number> = {+ tokyo: 22, "san francisco": 18, london: 14, "new york": 25,+ paris: 19, sydney: 27, mumbai: 33, berlin: 16,+ };+ const conditions = ["Sunny", "Partly Cloudy", "Cloudy", "Light Rain", "Clear Skies"];+ const temp = knownTemps[location.toLowerCase()] ?? Math.floor(Math.random() * 30 + 5);+ const condition = conditions[Math.floor(Math.random() * conditions.length)];+ resolve(JSON.stringify({+ location, temperature_celsius: temp,+ temperature_fahrenheit: Math.round(temp * 1.8 + 32),+ condition,+ humidity_percent: Math.floor(Math.random() * 40 + 40),+ wind_speed_kmh: Math.floor(Math.random() * 25 + 5),+ forecast: [+ { day: "Tomorrow", high: temp + 2, low: temp - 4, condition: "Partly Cloudy" },+ { day: "Day After", high: temp + 1, low: temp - 3, condition: "Sunny" },+ ],+ }));+ }, 800);+ });+}- const chatMessages: OpenAI.ChatCompletionMessageParam[] = [- ...(systemPrompt ? [{ role: "system" as const, content: systemPrompt }] : []),- ...messages,- ];+function getStockPrice({ symbol }: { symbol: string }): Promise<string> {+ return new Promise((resolve) => {+ setTimeout(() => {+ const s = symbol.toUpperCase();+ const knownPrices: Record<string, number> = {+ AAPL: 189.84, GOOGL: 141.8, TSLA: 248.42, MSFT: 378.91,+ AMZN: 178.25, NVDA: 875.28, META: 485.58,+ };+ const price = knownPrices[s] ?? Math.floor(Math.random() * 500 + 20);+ const change = parseFloat((Math.random() * 8 - 4).toFixed(2));+ resolve(JSON.stringify({+ symbol: s,+ price: parseFloat((price + change).toFixed(2)),+ change, change_percent: parseFloat(((change / price) * 100).toFixed(2)),+ volume: `${(Math.random() * 50 + 10).toFixed(1)}M`,+ day_high: parseFloat((price + Math.abs(change) + 1.5).toFixed(2)),+ day_low: parseFloat((price - Math.abs(change) - 1.2).toFixed(2)),+ }));+ }, 600);+ });+}- const response = await client.chat.completions.create({- model: "gpt-5.2",- messages: chatMessages,- stream: true,- });+function calculate({ expression }: { expression: string }): Promise<string> {+ return new Promise((resolve) => {+ setTimeout(() => {+ try {+ const sanitized = expression.replace(/[^0-9+\-*/().%\s,Math.sqrtpowabsceilfloorround]/g, "");++ const result = new Function(`return (${sanitized})`)();+ resolve(JSON.stringify({ expression, result: Number(result) }));+ } catch {+ resolve(JSON.stringify({ expression, error: "Invalid expression" }));+ }+ }, 300);+ });+}++function searchWeb({ query }: { query: string }): Promise<string> {+ return new Promise((resolve) => {+ setTimeout(() => {+ resolve(JSON.stringify({+ query,+ results: [+ { title: `Top result for "${query}"`, snippet: `Comprehensive overview of ${query} with the latest information.` },+ { title: `${query} - Latest News`, snippet: `Recent developments and updates related to ${query}.` },+ { title: `Understanding ${query}`, snippet: `An in-depth guide explaining everything about ${query}.` },+ ],+ }));+ }, 1000);+ });+}- return new Response(response.toReadableStream(), {- headers: {- "Content-Type": "text/event-stream",- "Cache-Control": "no-cache, no-transform",- Connection: "keep-alive",+// ── Tool definitions ──++// eslint-disable-next-line @typescript-eslint/no-explicit-any+const tools: any[] = [+ {+ type: "function",+ function: {+ name: "get_weather",+ description: "Get current weather for a location.",+ parameters: {+ type: "object",+ properties: { location: { type: "string", description: "City name" } },+ required: ["location"],},- });- } catch (err) {- console.error(err);- const message = err instanceof Error ? err.message : "Unknown error";- return new Response(JSON.stringify({ error: message }), {- status: 500,- headers: { "Content-Type": "application/json" },- });+ function: getWeather,+ parse: JSON.parse,+ },+ },+ {+ type: "function",+ function: {+ name: "get_stock_price",+ description: "Get stock price for a ticker symbol.",+ parameters: {+ type: "object",+ properties: { symbol: { type: "string", description: "Ticker symbol, e.g. AAPL" } },+ required: ["symbol"],+ },+ function: getStockPrice,+ parse: JSON.parse,+ },+ },+ {+ type: "function",+ function: {+ name: "calculate",+ description: "Evaluate a math expression.",+ parameters: {+ type: "object",+ properties: { expression: { type: "string", description: "Math expression to evaluate" } },+ required: ["expression"],+ },+ function: calculate,+ parse: JSON.parse,+ },+ },+ {+ type: "function",+ function: {+ name: "search_web",+ description: "Search the web for information.",+ parameters: {+ type: "object",+ properties: { query: { type: "string", description: "Search query" } },+ required: ["query"],+ },+ function: searchWeb,+ parse: JSON.parse,+ },+ },+];++// ── SSE helpers ──++function sseToolCallStart(+ encoder: TextEncoder,+ tc: { id: string; function: { name: string } },+ index: number,+) {+ return encoder.encode(+ `data: ${JSON.stringify({+ id: `chatcmpl-tc-${tc.id}`,+ object: "chat.completion.chunk",+ choices: [{+ index: 0,+ delta: {+ tool_calls: [{ index, id: tc.id, type: "function", function: { name: tc.function.name, arguments: "" } }],+ },+ finish_reason: null,+ }],+ })}\n\n`,+ );+}++function sseToolCallArgs(+ encoder: TextEncoder,+ tc: { id: string; function: { arguments: string } },+ result: string,+ index: number,+) {+ let enrichedArgs: string;+ try {+ enrichedArgs = JSON.stringify({ _request: JSON.parse(tc.function.arguments), _response: JSON.parse(result) });+ } catch {+ enrichedArgs = tc.function.arguments;}+ return encoder.encode(+ `data: ${JSON.stringify({+ id: `chatcmpl-tc-${tc.id}-args`,+ object: "chat.completion.chunk",+ choices: [{+ index: 0,+ delta: { tool_calls: [{ index, function: { arguments: enrichedArgs } }] },+ finish_reason: null,+ }],+ })}\n\n`,+ );+}++// ── Route handler ──++export async function POST(req: NextRequest) {+ const { messages, systemPrompt } = await req.json();++ const client = new OpenAI({+ apiKey: process.env.OPENROUTER_API_KEY,+ baseURL: "https://openrouter.ai/api/v1",+ });+ const MODEL = "openai/gpt-5.4";++ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ const cleanMessages = (messages as any[])+ .filter((m) => m.role !== "tool")+ .map((m) => {+ if (m.role === "assistant" && m.tool_calls?.length) {+ // Strip tool_calls (runTools re-runs the agentic loop server-side)+ // but preserve content so prior replies remain in context.+ const { tool_calls: _tc, ...rest } = m; // eslint-disable-line @typescript-eslint/no-unused-vars+ return rest;+ }+ return m;+ });++ const chatMessages: ChatCompletionMessageParam[] = [+ ...(systemPrompt ? [{ role: "system" as const, content: systemPrompt }] : []),+ ...cleanMessages,+ ];++ const encoder = new TextEncoder();+ let controllerClosed = false;++ const readable = new ReadableStream({+ start(controller) {+ const enqueue = (data: Uint8Array) => {+ if (controllerClosed) return;+ try { controller.enqueue(data); } catch { /* already closed */ }+ };+ const close = () => {+ if (controllerClosed) return;+ controllerClosed = true;+ try { controller.close(); } catch { /* already closed */ }+ };++ const pendingCalls: Array<{ id: string; name: string; arguments: string }> = [];+ let callIdx = 0;+ let resultIdx = 0;++ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ const runner = (client.chat.completions as any).runTools({+ model: MODEL,+ messages: chatMessages,+ tools,+ stream: true+ });++ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ runner.on("functionToolCall", (fc: any) => {+ const id = `tc-${callIdx}`;+ pendingCalls.push({ id, name: fc.name, arguments: fc.arguments });+ enqueue(sseToolCallStart(encoder, { id, function: { name: fc.name } }, callIdx));+ callIdx++;+ });++ runner.on("functionToolCallResult", (result: string) => {+ const tc = pendingCalls[resultIdx];+ if (tc) {+ enqueue(sseToolCallArgs(encoder, { id: tc.id, function: { arguments: tc.arguments } }, result, resultIdx));+ }+ resultIdx++;+ });++ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ runner.on("chunk", (chunk: any) => {+ const choice = chunk.choices?.[0];+ const delta = choice?.delta;+ if (!delta) return;+ if (delta.content) {+ enqueue(encoder.encode(`data: ${JSON.stringify(chunk)}\n\n`));+ }+ if (choice?.finish_reason === "stop") {+ enqueue(encoder.encode(`data: ${JSON.stringify(chunk)}\n\n`));+ }+ });++ runner.on("end", () => {+ enqueue(encoder.encode("data: [DONE]\n\n"));+ close();+ });++ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ runner.on("error", (err: any) => {+ const msg = err instanceof Error ? err.message : "Stream error";+ console.error("Chat route error:", msg);+ enqueue(encoder.encode(`data: ${JSON.stringify({ error: msg })}\n\n`));+ close();+ });+ },+ });++ return new Response(readable, {+ headers: {+ "Content-Type": "text/event-stream",+ "Cache-Control": "no-cache, no-transform",+ Connection: "keep-alive",+ },+ });}diff --git a/examples/openui-chat/src/app/chat/page.tsx b/examples/openui-chat/src/app/chat/page.tsxdeleted file mode 100644index 2bfc30af6..000000000--- a/examples/openui-chat/src/app/chat/page.tsx+++ /dev/null@@ -1,80 +0,0 @@-"use client";--import "@openuidev/react-ui/components.css";-import "@openuidev/react-ui/styles/index.css";--import { openAIMessageFormat, openAIReadableStreamAdapter } from "@openuidev/react-headless";-import { FullScreen } from "@openuidev/react-ui";-import { defaultLibrary, defaultPromptOptions } from "@openuidev/react-ui/genui-lib";-import Link from "next/link";-import { useState } from "react";--const systemPrompt = defaultLibrary.prompt(defaultPromptOptions);--export default function ChatPage() {- const [mode, setMode] = useState<"light" | "dark">("light");-- return (- <div className="h-screen w-screen overflow-hidden relative">- <nav- style={{- position: "absolute",- top: 16,- right: 16,- zIndex: 50,- display: "flex",- gap: 8,- alignItems: "center",- }}- >- <button- onClick={() => setMode((m) => (m === "light" ? "dark" : "light"))}- style={{- fontSize: 13,- padding: "6px 12px",- borderRadius: 6,- border: "1px solid rgba(128,128,128,0.3)",- background: mode === "dark" ? "rgba(255,255,255,0.1)" : "rgba(0,0,0,0.05)",- color: mode === "dark" ? "#fff" : "#333",- cursor: "pointer",- backdropFilter: "blur(8px)",- }}- >- {mode === "light" ? "Switch to Dark" : "Switch to Light"}- </button>- <Link- href="/"- style={{- fontSize: 13,- padding: "6px 12px",- borderRadius: 6,- border: "1px solid rgba(128,128,128,0.3)",- background: mode === "dark" ? "rgba(255,255,255,0.1)" : "rgba(0,0,0,0.05)",- color: mode === "dark" ? "#fff" : "#333",- textDecoration: "none",- backdropFilter: "blur(8px)",- }}- >- ← Home- </Link>- </nav>- <FullScreen- processMessage={async ({ messages, abortController }) => {- return fetch("/api/chat", {- method: "POST",- headers: { "Content-Type": "application/json" },- body: JSON.stringify({- messages: openAIMessageFormat.toApi(messages),- systemPrompt,- }),- signal: abortController.signal,- });- }}- streamProtocol={openAIReadableStreamAdapter()}- componentLibrary={defaultLibrary}- agentName="OpenUI Chat"- theme={{ mode }}- />- </div>- );-}diff --git a/examples/openui-chat/src/app/page.tsx b/examples/openui-chat/src/app/page.tsxindex a9af23fe5..1814f45d6 100644--- a/examples/openui-chat/src/app/page.tsx+++ b/examples/openui-chat/src/app/page.tsx@@ -1,15 +1,15 @@"use client";import "@openuidev/react-ui/components.css";-import "@openuidev/react-ui/styles/index.css";-import { openAIMessageFormat, openAIReadableStreamAdapter } from "@openuidev/react-headless";+import { openAIAdapter, openAIMessageFormat } from "@openuidev/react-headless";import { FullScreen } from "@openuidev/react-ui";-import { defaultLibrary, defaultPromptOptions } from "@openuidev/react-ui/genui-lib";-import Link from "next/link";+import { openuiChatLibrary, openuiChatPromptOptions } from "@openuidev/react-ui/genui-lib";+import { useState } from "react";-const systemPrompt = defaultLibrary.prompt(defaultPromptOptions);+const systemPrompt = openuiChatLibrary.prompt(openuiChatPromptOptions);-export default function Home() {+export default function Page() {+ const [mode, setMode] = useState<"light" | "dark">("light");return (<div className="h-screen w-screen overflow-hidden relative"><nav@@ -20,53 +20,24 @@ export default function Home() {zIndex: 50,display: "flex",gap: 8,+ alignItems: "center",}}>- <Link- href="/theme-test"+ <button+ onClick={() => setMode((m) => (m === "light" ? "dark" : "light"))}style={{fontSize: 13,padding: "6px 12px",borderRadius: 6,border: "1px solid rgba(128,128,128,0.3)",- background: "rgba(0,0,0,0.05)",- color: "#333",- textDecoration: "none",+ background: mode === "dark" ? "rgba(255,255,255,0.1)" : "rgba(0,0,0,0.05)",+ color: mode === "dark" ? "#fff" : "#333",+ cursor: "pointer",backdropFilter: "blur(8px)",}}>- Theme Tests →- </Link>- <Link- href="/chat"- style={{- fontSize: 13,- padding: "6px 12px",- borderRadius: 6,- border: "1px solid rgba(128,128,128,0.3)",- background: "rgba(0,0,0,0.05)",- color: "#333",- textDecoration: "none",- backdropFilter: "blur(8px)",- }}- >- Chat (Themed) →- </Link>- <Link- href="/agent"- style={{- fontSize: 13,- padding: "6px 12px",- borderRadius: 6,- border: "1px solid rgba(128,128,128,0.3)",- background: "rgba(0,0,0,0.05)",- color: "#333",- textDecoration: "none",- backdropFilter: "blur(8px)",- }}- >- Agent →- </Link>+ {mode === "light" ? "Switch to Dark" : "Switch to Light"}+ </button></nav><FullScreenprocessMessage={async ({ messages, abortController }) => {@@ -80,10 +51,19 @@ export default function Home() {signal: abortController.signal,});}}- streamProtocol={openAIReadableStreamAdapter()}- componentLibrary={defaultLibrary}+ streamProtocol={openAIAdapter()}+ componentLibrary={openuiChatLibrary}agentName="OpenUI Chat"- disableThemeProvider+ theme={{ mode }}+ conversationStarters={{+ variant: "short",+ options: [+ { displayText: "Weather in Tokyo", prompt: "What's the weather like in Tokyo right now?" },+ { displayText: "AAPL stock price", prompt: "What's the current Apple stock price?" },+ { displayText: "Contact form", prompt: "Build me a contact form with name, email, topic, and message fields." },+ { displayText: "Data table", prompt: "Show me a table of the top 5 programming languages by popularity with year created." },+ ],+ }}/></div>);diff --git a/examples/openui-chat/src/app/theme-test/page.tsx b/examples/openui-chat/src/app/theme-test/page.tsxdeleted file mode 100644index d8838b13a..000000000--- a/examples/openui-chat/src/app/theme-test/page.tsx+++ /dev/null@@ -1,144 +0,0 @@-"use client";--import "@openuidev/react-ui/styles/index.css";--import {- Button,- Callout,- Card,- CardHeader,- Input,- Select,- SelectContent,- SelectItem,- SelectTrigger,- SelectValue,- Tag,- ThemeProvider,-} from "@openuidev/react-ui";--function ComponentShowcase({ label }: { label: string }) {- return (- <div style={{ display: "flex", flexDirection: "column", gap: 16, maxWidth: 480 }}>- <CardHeader title={label} />-- <Button variant="primary">Primary Action</Button>-- <Input placeholder="Type something here…" />-- <Select defaultValue="opt1">- <SelectTrigger>- <SelectValue placeholder="Pick an option" />- </SelectTrigger>- <SelectContent>- <SelectItem value="opt1">Option One</SelectItem>- <SelectItem value="opt2">Option Two</SelectItem>- <SelectItem value="opt3">Option Three</SelectItem>- </SelectContent>- </Select>-- <Card>- <CardHeader title="Card Title" subtitle="Subtitle text here" />- <div style={{ padding: "0 16px 16px" }}>Card body content goes here.</div>- </Card>-- <Callout- variant="info"- title="Information"- description="This is an informational callout to test semantic colors."- />-- <div style={{ display: "flex", gap: 8, flexWrap: "wrap" }}>- <Tag text="Neutral" />- <Tag text="Info" variant="info" />- <Tag text="Success" variant="success" />- <Tag text="Warning" variant="warning" />- <Tag text="Danger" variant="danger" />- </div>- </div>- );-}--function SectionDivider() {- return <hr style={{ border: "none", borderTop: "1px solid #e0e0e0", margin: "32px 0" }} />;-}--export default function ThemeTestPage() {- return (- <div style={{ padding: 32, fontFamily: "system-ui, sans-serif" }}>- <h1 style={{ fontSize: 28, fontWeight: 700, marginBottom: 8 }}>ThemeProvider Test Page</h1>- <p style={{ color: "#666", marginBottom: 32 }}>- Visual verification of ThemeProvider scoping, fallbacks, and nesting.- </p>-- {/* Section 1: No ThemeProvider */}- <section>- <h2 style={{ fontSize: 20, fontWeight: 600, marginBottom: 16 }}>- 1. No ThemeProvider (CSS fallback test)- </h2>- <p style={{ color: "#888", fontSize: 14, marginBottom: 12 }}>- Components render with zero wrapping. CSS var() fallbacks should apply.- </p>- <ComponentShowcase label="Unwrapped components" />- </section>-- <SectionDivider />-- {/* Section 2: Light ThemeProvider */}- <section>- <h2 style={{ fontSize: 20, fontWeight: 600, marginBottom: 16 }}>2. Light ThemeProvider</h2>- <ThemeProvider mode="light">- <ComponentShowcase label="mode=light" />- </ThemeProvider>- </section>-- <SectionDivider />-- {/* Section 3: Dark ThemeProvider */}- <section>- <h2 style={{ fontSize: 20, fontWeight: 600, marginBottom: 16 }}>3. Dark ThemeProvider</h2>- <ThemeProvider mode="dark" cssSelector=".openui-theme-dark">- <div- style={{ background: "#1a1a1a", padding: 24, borderRadius: 12 }}- className="openui-theme-dark"- >- <ComponentShowcase label="mode=dark" />- </div>- </ThemeProvider>- </section>-- <SectionDivider />-- {/* Section 4: Nested Scoping */}-- <section>- <h2 style={{ fontSize: 20, fontWeight: 600, marginBottom: 16 }}>- 4. Nested Scoping (light outer, dark inner)- </h2>- <p style={{ color: "#888", fontSize: 14, marginBottom: 12 }}>- Inner dark scope must not leak into the outer light scope.- </p>- <ThemeProvider mode="light">- <div style={{ display: "flex", gap: 24, flexWrap: "wrap" }}>- <div style={{ flex: 1, minWidth: 300 }}>- <ComponentShowcase label="Outer — light" />- </div>- <ThemeProvider mode="dark">- <div- style={{- flex: 1,- minWidth: 300,- background: "#1a1a1a",- padding: 24,- borderRadius: 12,- }}- >- <ComponentShowcase label="Inner — dark (nested)" />- </div>- </ThemeProvider>- </div>- </ThemeProvider>- </section>- </div>- );-}diff --git a/packages/lang-react/src/Renderer.tsx b/packages/lang-react/src/Renderer.tsxindex 921f42d9e..ef5997e48 100644--- a/packages/lang-react/src/Renderer.tsx+++ b/packages/lang-react/src/Renderer.tsx@@ -5,7 +5,7 @@ import type { ComponentRenderer, Library } from "./library";import type { ActionEvent, ElementNode, ParseResult } from "./parser/types";export interface RendererProps {- /** Raw response text (openui-lang code, possibly with <context> tag). */+ /** Raw response text (openui-lang code). */response: string | null;/** Component library from createLibrary(). */library: Library;@@ -13,8 +13,16 @@ export interface RendererProps {isStreaming?: boolean;/** Callback when a component triggers an action. */onAction?: (event: ActionEvent) => void;- /** Persist message content with form state on field change. */- updateMessage?: (message: string) => void;+ /**+ * Called whenever a form field value changes. Receives the raw form state map.+ * The consumer decides how to persist this (e.g. embed in message, store separately).+ */+ onStateUpdate?: (state: Record<string, any>) => void;+ /**+ * Initial form state to hydrate on load (e.g. from a previously persisted message).+ * Shape: { formName: { fieldName: { value, componentType } } }+ */+ initialState?: Record<string, any>;/** Called whenever the parse result changes. */onParseResult?: (result: ParseResult | null) => void;}@@ -115,7 +123,26 @@ function RenderNode({ node }: { node: ElementNode }) {*/function RenderNodeInner({ el, Comp }: { el: ElementNode; Comp: ComponentRenderer<any> }) {const renderNode = useRenderNode();- return <Comp props={el.props} renderNode={renderNode} />;+ const { library } = useOpenUI();++ // Handle elements that have positional `args` instead of named `props`+ let props = el.props;+ if (!props) {+ const args = (el as any).args as unknown[] | undefined;+ if (args) {+ const def = library.components[el.typeName];+ if (def) {+ const fieldNames = Object.keys(def.props.shape);+ props = {};+ for (let i = 0; i < fieldNames.length && i < args.length; i++) {+ props[fieldNames[i]] = args[i];+ }+ }+ }+ props = props ?? {};+ }++ return <Comp props={props} renderNode={renderNode} />;}// ─── Public component ───@@ -125,7 +152,8 @@ export function Renderer({library,isStreaming = false,onAction,- updateMessage,+ onStateUpdate,+ initialState,onParseResult,}: RendererProps) {const { result, contextValue } = useOpenUIState(@@ -134,7 +162,8 @@ export function Renderer({library,isStreaming,onAction,- updateMessage,+ onStateUpdate,+ initialState,},renderDeep,);diff --git a/packages/lang-react/src/context.ts b/packages/lang-react/src/context.tsindex bae728ac6..f521f9b73 100644--- a/packages/lang-react/src/context.ts+++ b/packages/lang-react/src/context.ts@@ -18,13 +18,11 @@ export interface OpenUIContextValue {* Trigger an action. Components call this to fire structured ActionEvents.** @param userMessage Human-readable label ("Submit Application")- * @param actionContext Description of the interaction ("User clicked on Button: submit-onboarding")* @param formName Optional form name — if provided, form state for this form is included* @param action Optional custom action config { type, params }*/triggerAction: (userMessage: string,- actionContext: string,formName?: string,action?: { type?: string; params?: Record<string, any> },) => void;@@ -81,7 +79,7 @@ export function useRenderNode() {* @example* ```tsx* const triggerAction = useTriggerAction();- * <button onClick={() => triggerAction("Submit", "User clicked Button: submit", "myForm")}>+ * <button onClick={() => triggerAction("Submit", "myForm")}>* ```*/export function useTriggerAction() {diff --git a/packages/lang-react/src/hooks/useOpenUIState.ts b/packages/lang-react/src/hooks/useOpenUIState.tsindex 9135a32d0..59099fa9a 100644--- a/packages/lang-react/src/hooks/useOpenUIState.ts+++ b/packages/lang-react/src/hooks/useOpenUIState.ts@@ -5,19 +5,14 @@ import type { Library } from "../library";import { createParser } from "../parser/parser";import type { ActionEvent, ParseResult } from "../parser/types";import { BuiltinActionType } from "../parser/types";-import {- parseContext,- separateContentAndContext,- wrapContent,- wrapContext,-} from "../utils/contentParser";export interface UseOpenUIStateOptions {response: string | null;library: Library;isStreaming: boolean;onAction?: (event: ActionEvent) => void;- updateMessage?: (message: string) => void;+ onStateUpdate?: (state: Record<string, any>) => void;+ initialState?: Record<string, any>;}export interface OpenUIState {@@ -34,63 +29,51 @@ export interface OpenUIState {* - setFieldValue accepts shouldTriggerSaveCallback (blur-based persistence for text inputs)*/export function useOpenUIState(- { response, library, isStreaming, onAction, updateMessage }: UseOpenUIStateOptions,+ { response, library, isStreaming, onAction, onStateUpdate, initialState }: UseOpenUIStateOptions,renderDeep: (value: unknown) => React.ReactNode,): OpenUIState {// ─── Parser (synchronous, created once from the library's JSON schema) ───const parser = useMemo(() => createParser(library.toJSONSchema()), []); // intentionally empty deps — parser is created once- // ─── Content/context separation ───- const { content: openuiCode, contextString } = useMemo(() => {- if (!response) return { content: null, contextString: null };- return separateContentAndContext(response);- }, [response]);-- // ─── Form state ───- const [formState, setFormState] = useState<Record<string, any>>(() =>- parseContext(contextString),- );-- const prevContextString = useRef(contextString);- useEffect(() => {- if (prevContextString.current !== contextString) {- prevContextString.current = contextString;- setFormState(parseContext(contextString));- }- }, [contextString]);-// ─── Parse result ───const result = useMemo<ParseResult | null>(() => {- if (!openuiCode) return null;+ if (!response) return null;try {- return parser.parse(openuiCode);+ return parser.parse(response);} catch (e) {console.error("[openui] Parse error:", e);return null;}- }, [parser, openuiCode]);+ }, [parser, response]);// Log the final parsed tree once streaming ends (dev debugging).const prevIsStreaming = useRef(isStreaming);useEffect(() => {- if (prevIsStreaming.current && !isStreaming && result) {- console.info("[openui] parsed output:", JSON.stringify(result, null, 2));- }prevIsStreaming.current = isStreaming;}, [isStreaming, result]);+ // ─── Form state ───+ const [formState, setFormState] = useState<Record<string, any>>(() => initialState ?? {});++ // Sync if initialState changes (e.g. loading a different message)+ const prevInitialFormState = useRef(initialState);+ useEffect(() => {+ if (prevInitialFormState.current !== initialState) {+ prevInitialFormState.current = initialState;+ setFormState(initialState ?? {});+ }+ }, [initialState]);+// ─── Ref for stable callbacks ───const propsRef = useRef({formState,- openuiCode: openuiCode ?? "",onAction,- updateMessage,+ onStateUpdate,});propsRef.current = {formState,- openuiCode: openuiCode ?? "",onAction,- updateMessage,+ onStateUpdate,};// ─── getFieldValue ───@@ -124,13 +107,7 @@ export function useOpenUIState(propsRef.current.formState = newState;if (shouldTriggerSaveCallback) {- const latestCode = propsRef.current.openuiCode;- const latestUpdate = propsRef.current.updateMessage;- if (latestUpdate) {- const contextJson = JSON.stringify([newState]);- const fullMessage = latestCode + "\n" + wrapContext(contextJson);- latestUpdate(fullMessage);- }+ propsRef.current.onStateUpdate?.(newState);}},[],@@ -140,7 +117,6 @@ export function useOpenUIState(const triggerAction = useCallback((userMessage: string,- actionContext: string,formName?: string,action?: { type?: string; params?: Record<string, any> },) => {@@ -148,37 +124,23 @@ export function useOpenUIState(const actionType = action?.type || BuiltinActionType.ContinueConversation;const actionParams = action?.params;- const messageCtx: (string | object)[] = [actionContext];+ // Collect relevant form state+ let relevantState: Record<string, any> | undefined;if (formName && currentState[formName]) {- messageCtx.push({ [formName]: currentState[formName] });+ relevantState = { [formName]: currentState[formName] };} else if (Object.keys(currentState).length > 0) {- messageCtx.push(currentState);+ relevantState = currentState;}- const contentPart = userMessage ? wrapContent(userMessage) : "";- const contextPart = wrapContext(JSON.stringify(messageCtx));- const llmFriendlyMessage = `${contentPart}${contextPart}`;-if (!handler) return;- if (actionType === BuiltinActionType.ContinueConversation) {- handler({- type: BuiltinActionType.ContinueConversation,- params: {- humanFriendlyMessage: userMessage,- llmFriendlyMessage,- },- humanFriendlyMessage: userMessage,- llmFriendlyMessage,- });- } else {- handler({- type: actionType,- params: actionParams || {},- humanFriendlyMessage: userMessage,- llmFriendlyMessage,- });- }+ handler({+ type: actionType,+ params: actionParams || {},+ humanFriendlyMessage: userMessage,+ formState: relevantState,+ formName,+ });},[],);diff --git a/packages/lang-react/src/index.ts b/packages/lang-react/src/index.tsindex 0306eee3b..662d02475 100644--- a/packages/lang-react/src/index.ts+++ b/packages/lang-react/src/index.ts@@ -42,8 +42,5 @@ export {} from "./hooks/useFormValidation";export type { FormValidationContextValue } from "./hooks/useFormValidation";-export { builtInValidators, parseRules, validate } from "./utils/validation";+export { builtInValidators, parseRules, parseStructuredRules, validate } from "./utils/validation";export type { ParsedRule, ValidatorFn } from "./utils/validation";--// openui-lang message context utilities (for building custom backends)-export { separateContentAndContext, wrapContent, wrapContext } from "./utils/contentParser";diff --git a/packages/lang-react/src/parser/parser.ts b/packages/lang-react/src/parser/parser.tsindex 77be8d403..3134d2d03 100644--- a/packages/lang-react/src/parser/parser.ts+++ b/packages/lang-react/src/parser/parser.ts@@ -19,6 +19,8 @@ export interface ParamDef {name: string;/** Whether the parameter is required by the component. */required: boolean;+ /** Default value from JSON Schema — used when the required field is missing/null. */+ defaultValue?: unknown;}/**@@ -544,21 +546,30 @@ function mapNode(for (let i = 0; i < def.params.length && i < args.length; i++)props[def.params[i].name] = toJson(args[i], partial, errors, cat);- // Validate required props- const invalidRequired = def.params.filter(+ // Validate required props — try defaultValue first before dropping+ const missingRequired = def.params.filter((p) => p.required && (!(p.name in props) || props[p.name] === null),);- if (invalidRequired.length) {- for (const p of invalidRequired)- errors.push({- component: name,- path: `/${p.name}`,- message:- p.name in props- ? `required field "${p.name}" cannot be null`- : `missing required field "${p.name}"`,- });- return null; // drop invalid nodes on validation failure+ if (missingRequired.length) {+ const stillInvalid = missingRequired.filter((p) => {+ if (p.defaultValue !== undefined) {+ props[p.name] = p.defaultValue as JsonVal;+ return false;+ }+ return true;+ });+ if (stillInvalid.length) {+ for (const p of stillInvalid)+ errors.push({+ component: name,+ path: `/${p.name}`,+ message:+ p.name in props+ ? `required field "${p.name}" cannot be null`+ : `missing required field "${p.name}"`,+ });+ return null;+ }}} else {// No library entry for this component — preserve all args under _args@@ -740,6 +751,7 @@ function compileSchema(schema: LibraryJSONSchema): ParamMap {const params = Object.keys(properties).map((k) => ({name: k,required: required.includes(k),+ defaultValue: (properties[k] as any)?.default,}));map.set(name, { params });}diff --git a/packages/lang-react/src/parser/prompt.ts b/packages/lang-react/src/parser/prompt.tsindex b2e3e8664..11119d678 100644--- a/packages/lang-react/src/parser/prompt.ts+++ b/packages/lang-react/src/parser/prompt.ts@@ -7,10 +7,10 @@ function syntaxRules(rootName: string): string {return `## Syntax Rules1. Each statement is on its own line: \`identifier = Expression\`-2. The first statement is the entry point and must be a ${rootName} component+2. \`root\` is the entry point — every program must define \`root = ${rootName}(...)\`3. Expressions are: strings ("..."), numbers, booleans (true/false), arrays ([...]), objects ({...}), or component calls TypeName(arg1, arg2, ...)4. Use references for readability: define \`name = ...\` on one line, then use \`name\` later-5. EVERY variable (except the root) MUST be referenced by at least one other variable. Unreferenced variables are silently dropped and will NOT render. Always include defined variables in their parent's children/items array.+5. EVERY variable (except root) MUST be referenced by at least one other variable. Unreferenced variables are silently dropped and will NOT render. Always include defined variables in their parent's children/items array.6. Arguments are POSITIONAL (order matters, not names)7. Optional arguments can be omitted from the end8. No operators, no logic, no variables — only declarations@@ -22,7 +22,14 @@ function streamingRules(rootName: string): string {openui-lang supports hoisting: a reference can be used BEFORE it is defined. The parser resolves all references after the full input is parsed.-During streaming, the output is re-parsed on every chunk. Undefined references are temporarily unresolved and appear once their definitions stream in. This creates a progressive top-down reveal — structure first, then data fills in. Always write the root = ${rootName}(...) statement first so the UI shell appears immediately, even before child data has streamed in.`;+During streaming, the output is re-parsed on every chunk. Undefined references are temporarily unresolved and appear once their definitions stream in. This creates a progressive top-down reveal — structure first, then data fills in.++**Recommended statement order for optimal streaming:**+1. \`root = ${rootName}(...)\` — UI shell appears immediately+2. Component definitions — fill in as they stream+3. Data values — leaf content last++Always write the root = ${rootName}(...) statement first so the UI shell appears immediately, even before child data has streamed in.`;}function importantRules(rootName: string): string {@@ -239,6 +246,7 @@ function generateComponentSignatures(library: Library): string {"## Component Signatures","","Arguments marked with ? are optional. Sub-components can be inline or referenced; prefer references for better streaming.",+ "The `action` prop type accepts: ContinueConversation (sends message to LLM), OpenUrl (navigates to URL), or Custom (app-defined).",];if (library.componentGroups?.length) {diff --git a/packages/lang-react/src/parser/types.ts b/packages/lang-react/src/parser/types.tsindex f2c168d35..b3754d0f6 100644--- a/packages/lang-react/src/parser/types.ts+++ b/packages/lang-react/src/parser/types.ts@@ -42,18 +42,18 @@ export enum BuiltinActionType {/*** Structured action event fired by interactive components.- *- * Follows C1's action event format for compatibility.*/export interface ActionEvent {/** Action type. See `BuiltinActionType` for built-in types. */type: string;- /** Action-specific params. For continue_conversation: { humanFriendlyMessage, llmFriendlyMessage }. */+ /** Action-specific params (e.g. { url } for OpenUrl, custom params for Custom). */params: Record<string, any>;/** Human-readable label for the action (displayed as user message in chat). */humanFriendlyMessage: string;- /** Full message with context tags, sent to the LLM. */- llmFriendlyMessage: string;+ /** Raw form state at the time of the action — all field values. */+ formState?: Record<string, any>;+ /** The form name that triggered this action, if any. */+ formName?: string;}/**diff --git a/packages/lang-react/src/utils/contentParser.ts b/packages/lang-react/src/utils/contentParser.tsdeleted file mode 100644index 8bad5bbf4..000000000--- a/packages/lang-react/src/utils/contentParser.ts+++ /dev/null@@ -1,76 +0,0 @@-// ─── Tag helpers ───--const openTag = (tag: string) => `<${tag}>`;-const closeTag = (tag: string) => `</${tag}>`;--/**- * Wrap text in <content> tags.- */-export function wrapContent(text: string): string {- return `${openTag("content")}${text}${closeTag("content")}`;-}--/**- * Wrap JSON string in <context> tags.- */-export function wrapContext(json: string): string {- return `${openTag("context")}${json}${closeTag("context")}`;-}--/**- * Separate openui-lang code from <context> tag in a message.- *- * Supports two formats:- * <content>message</content><context>state</context>- * message<context>state</context>- *- * Uses regex to find the last <context>...</context> block.- *- * @returns { content: the message/code, contextString: raw JSON or null }- */-export function separateContentAndContext(raw: string): {- content: string;- contextString: string | null;-} {- // Extract <context>...</context> from the end- const contextMatch = raw.match(/<context>([\s\S]*)<\/context>\s*$/);- let content = raw;- let contextString: string | null = null;-- if (contextMatch) {- contextString = contextMatch[1];- content = raw.slice(0, contextMatch.index!).trimEnd();- }-- // Unwrap <content>...</content> if present- const contentMatch = content.match(/^<content>([\s\S]*)<\/content>\s*$/);- if (contentMatch) {- content = contentMatch[1];- }-- return { content, contextString };-}--/**- * Parse the context string into a form state object.- *- * Context is stored as a JSON array: [{ formName: { fieldName: { value, componentType } } }]- * The array wrapper exists for backward compatibility.- *- * @returns The form state object, or empty object if parsing fails.- */-export function parseContext(contextString: string | null): Record<string, any> {- if (!contextString) return {};- try {- const parsed = JSON.parse(contextString);- if (Array.isArray(parsed) && typeof parsed[0] === "object") {- return parsed[0];- }- if (typeof parsed === "object" && !Array.isArray(parsed)) {- return parsed;- }- return {};- } catch {- return {};- }-}diff --git a/packages/lang-react/src/utils/index.ts b/packages/lang-react/src/utils/index.tsindex 76ddcdca1..6495f6152 100644--- a/packages/lang-react/src/utils/index.ts+++ b/packages/lang-react/src/utils/index.ts@@ -1,4 +1,2 @@-export { separateContentAndContext, wrapContent, wrapContext } from "./contentParser";--export { builtInValidators, parseRules, validate } from "./validation";+export { builtInValidators, parseRules, parseStructuredRules, validate } from "./validation";export type { ValidatorFn } from "./validation";diff --git a/packages/lang-react/src/utils/validation.ts b/packages/lang-react/src/utils/validation.tsindex a06adcf34..0902e9f79 100644--- a/packages/lang-react/src/utils/validation.ts+++ b/packages/lang-react/src/utils/validation.ts@@ -128,3 +128,23 @@ export function validate(}return undefined;}++/**+ * Parse a structured rules object into ParsedRule[].+ * Accepts: { required: true, minLength: 5, email: true, max: 100 }+ * Skips keys with false/undefined values.+ */+export function parseStructuredRules(rules: unknown): ParsedRule[] {+ if (!rules || typeof rules !== "object" || Array.isArray(rules)) return [];+ const obj = rules as Record<string, any>;+ const result: ParsedRule[] = [];+ for (const [key, val] of Object.entries(obj)) {+ if (val === false || val === undefined || val === null) continue;+ if (val === true) {+ result.push({ type: key });+ } else {+ result.push({ type: key, arg: val });+ }+ }+ return result;+}diff --git a/packages/lang-react/tsconfig.json b/packages/lang-react/tsconfig.jsonindex 79beb39cd..08e2cc8bd 100644--- a/packages/lang-react/tsconfig.json+++ b/packages/lang-react/tsconfig.json@@ -2,6 +2,7 @@"$schema": "https://json.schemastore.org/tsconfig","extends": "../../tsconfig.json","include": ["src/**/*"],+ "exclude": ["src/**/__tests__/**", "src/**/*.test.ts", "src/**/*.test.tsx"],"compilerOptions": {"moduleResolution": "bundler","module": "ESNext",diff --git a/packages/react-ui/src/components/Charts/ScatterChart/ScatterChart.tsx b/packages/react-ui/src/components/Charts/ScatterChart/ScatterChart.tsxindex 45906506b..eb4ad70ea 100644--- a/packages/react-ui/src/components/Charts/ScatterChart/ScatterChart.tsx+++ b/packages/react-ui/src/components/Charts/ScatterChart/ScatterChart.tsx@@ -112,9 +112,6 @@ export const ScatterChart = ({}, [containerWidth, yAxisWidth]);const chartHeight = useMemo(() => {- if (!chartWrapperRef.current) {- return 0;- }const legendHeight = legendContainerRef.current?.offsetHeight ?? 0;const xAxisHeight = xAxisContainerRef.current?.offsetHeight ?? 0;@@ -129,7 +126,7 @@ export const ScatterChart = ({}}- if (!height) {+ if (!height || !chartWrapperRef.current) {return DEFAULT_CHART_HEIGHT;}@@ -316,7 +313,7 @@ export const ScatterChart = ({data-openui-chart={exportData}style={{width: typeof width === "number" ? `${width}px` : width || "100%",- height: isFixedNumericHeight ? "auto" : height || "100%",+ height: isFixedNumericHeight ? "auto" : (height ?? "auto"),}}ref={chartWrapperRef}>diff --git a/packages/react-ui/src/components/FollowUpBlock/FollowUpBlock.tsx b/packages/react-ui/src/components/FollowUpBlock/FollowUpBlock.tsxindex a3e3d6620..06d6c17dc 100644--- a/packages/react-ui/src/components/FollowUpBlock/FollowUpBlock.tsx+++ b/packages/react-ui/src/components/FollowUpBlock/FollowUpBlock.tsx@@ -12,6 +12,7 @@ const FollowUpBlock = forwardRef<HTMLDivElement, FollowUpBlockProps>((props, refconst { children, className, style, ...rest } = props;return (<div ref={ref} className={clsx("openui-follow-up-block", className)} style={style} {...rest}>+ <div className="openui-follow-up-block__header">Related Queries</div>{children}</div>);diff --git a/packages/react-ui/src/components/FollowUpBlock/followUpBlock.scss b/packages/react-ui/src/components/FollowUpBlock/followUpBlock.scssindex 94653fae7..7c16c8cda 100644--- a/packages/react-ui/src/components/FollowUpBlock/followUpBlock.scss+++ b/packages/react-ui/src/components/FollowUpBlock/followUpBlock.scss@@ -4,4 +4,12 @@box-sizing: border-box;display: flex;flex-direction: column;++ &__header {+ color: cssUtils.$text-neutral-secondary;+ border-bottom: 1px solid cssUtils.$border-default;+ padding-top: cssUtils.$space-s;+ padding-bottom: cssUtils.$space-s;+ margin-bottom: cssUtils.$space-m;+ }}diff --git a/packages/react-ui/src/components/OpenUIChat/GenUIAssistantMessage.tsx b/packages/react-ui/src/components/OpenUIChat/GenUIAssistantMessage.tsxindex 0dbbdfd93..0a20a64d2 100644--- a/packages/react-ui/src/components/OpenUIChat/GenUIAssistantMessage.tsx+++ b/packages/react-ui/src/components/OpenUIChat/GenUIAssistantMessage.tsx@@ -1,8 +1,11 @@+"use client";+import type { ActionEvent, Library } from "@openuidev/lang-react";import { BuiltinActionType, Renderer } from "@openuidev/lang-react";import type { AssistantMessage, ToolMessage } from "@openuidev/react-headless";import { useThread } from "@openuidev/react-headless";import { useCallback, useMemo } from "react";+import { separateContentAndContext, wrapContent, wrapContext } from "../../utils/contentParser";import { AssistantMessageContainer } from "../Shell";import { BehindTheScenes, ToolCallComponent } from "../ToolCall";import { ToolResult } from "../ToolResult";@@ -29,6 +32,24 @@ export const GenUIAssistantMessage = ({return false;}, [isRunning, messages, message.id]);+ // Separate openui-lang code from persisted form state+ const { content: openuiCode, contextString } = useMemo(() => {+ if (!message.content) return { content: null, contextString: null };+ return separateContentAndContext(message.content);+ }, [message.content]);++ const initialState = useMemo(() => {+ if (!contextString) return undefined;+ try {+ const parsed = JSON.parse(contextString);+ if (Array.isArray(parsed) && typeof parsed[0] === "object") return parsed[0];+ if (typeof parsed === "object" && !Array.isArray(parsed)) return parsed;+ return undefined;+ } catch {+ return undefined;+ }+ }, [contextString]);+const toolMessages = useMemo(() => {const result: ToolMessage[] = [];const msgIndex = messages.findIndex((m) => m.id === message.id);@@ -50,25 +71,45 @@ export const GenUIAssistantMessage = ({return toolCall?.function.name;};+ // Persist form state into the message content (XML-wrapped)+ const handleStateUpdate = useCallback(+ (state: Record<string, any>) => {+ const code = openuiCode ?? "";+ const contextJson = JSON.stringify([state]);+ const fullMessage = code + "\n" + wrapContext(contextJson);+ updateMessage({ ...message, content: fullMessage });+ },+ [updateMessage, message, openuiCode],+ );++ // Build LLM-friendly message from action + form state, then dispatchconst handleAction = useCallback((event: ActionEvent) => {if (event.type === BuiltinActionType.ContinueConversation) {+ const contentPart = event.humanFriendlyMessage+ ? wrapContent(event.humanFriendlyMessage)+ : "";+ const messageCtx: (string | object)[] = [`User clicked: ${event.humanFriendlyMessage}`];+ if (event.formState) {+ messageCtx.push(event.formState);+ }+ const contextPart = wrapContext(JSON.stringify(messageCtx));+ const llmMessage = `${contentPart}${contextPart}`;+processMessage({role: "user",- content: event.humanFriendlyMessage,+ content: llmMessage,});+ } else if (event.type === BuiltinActionType.OpenUrl) {+ const url = event.params?.["url"] as string | undefined;+ if (typeof window !== "undefined" && url) {+ window.open(url, "_blank");+ }}},[processMessage],);- const handleUpdateMessage = useCallback(- (updatedContent: string) => {- updateMessage({ ...message, content: updatedContent });- },- [updateMessage, message],- );-const hasToolActivity =(message.toolCalls && message.toolCalls.length > 0) || toolMessages.length > 0;@@ -91,11 +132,12 @@ export const GenUIAssistantMessage = ({</BehindTheScenes>)}<Renderer- response={message.content ?? null}+ response={openuiCode}library={library}isStreaming={isStreaming}onAction={handleAction}- updateMessage={handleUpdateMessage}+ onStateUpdate={handleStateUpdate}+ initialState={initialState}/></AssistantMessageContainer>);diff --git a/packages/react-ui/src/components/OpenUIChat/GenUIUserMessage.tsx b/packages/react-ui/src/components/OpenUIChat/GenUIUserMessage.tsxnew file mode 100644index 000000000..6b11b2ab2--- /dev/null+++ b/packages/react-ui/src/components/OpenUIChat/GenUIUserMessage.tsx@@ -0,0 +1,124 @@+"use client";++import type { UserMessage } from "@openuidev/react-headless";+import { ChevronDown } from "lucide-react";+import { useState } from "react";+import { separateContentAndContext } from "../../utils/contentParser";++/**+ * Extracts the first plain object from a context string.+ * The triggerAction context format is: ["action description string", { formState }]+ */+function parseContextForDisplay(contextString: string | null): Record<string, any> {+ if (!contextString) return {};+ try {+ const parsed = JSON.parse(contextString);+ if (Array.isArray(parsed)) {+ const stateObj = parsed.find(+ (item) => item !== null && typeof item === "object" && !Array.isArray(item),+ );+ return stateObj ?? {};+ }+ if (typeof parsed === "object" && parsed !== null) {+ return parsed;+ }+ return {};+ } catch {+ return {};+ }+}++function getEntries(state: Record<string, any>): { label: string; value: string }[] {+ // Detect nested (form-named) shape+ const isNested = Object.values(state).some(+ (v) =>+ v !== null &&+ typeof v === "object" &&+ !("value" in v) &&+ Object.values(v).some((f) => f !== null && typeof f === "object" && "value" in f),+ );++ const entries: { label: string; value: string }[] = [];++ if (isNested) {+ for (const [, fields] of Object.entries(state)) {+ if (typeof fields !== "object" || fields === null) continue;+ for (const [fieldName, field] of Object.entries(fields as Record<string, any>)) {+ if (field && typeof field === "object" && "value" in field) {+ const val = field.value;+ if (val !== undefined && val !== null && val !== "") {+ entries.push({ label: fieldName, value: String(val) });+ }+ }+ }+ }+ } else {+ for (const [fieldName, field] of Object.entries(state)) {+ if (field && typeof field === "object" && "value" in field) {+ const val = field.value;+ if (val !== undefined && val !== null && val !== "") {+ entries.push({ label: fieldName, value: String(val) });+ }+ }+ }+ }++ return entries;+}++function FormDataAccordion({ state }: { state: Record<string, any> }) {+ const [isExpanded, setIsExpanded] = useState(false);+ const entries = getEntries(state);++ if (entries.length === 0) return null;++ return (+ <div className="openui-genui-user-message__form-state">+ <button+ className="openui-genui-user-message__form-state-header"+ onClick={() => setIsExpanded((v) => !v)}+ type="button"+ >+ <span className="openui-genui-user-message__form-state-label">+ Form data ({entries.length} {entries.length === 1 ? "field" : "fields"})+ </span>+ <ChevronDown+ size={14}+ className={`openui-genui-user-message__form-state-chevron${isExpanded ? " openui-genui-user-message__form-state-chevron--expanded" : ""}`}+ />+ </button>+ {isExpanded && (+ <div className="openui-genui-user-message__form-state-content">+ {entries.map(({ label, value }) => (+ <div key={label} className="openui-genui-user-message__form-field">+ <span className="openui-genui-user-message__form-field-label">{label}:</span>+ <span className="openui-genui-user-message__form-field-value">{value}</span>+ </div>+ ))}+ </div>+ )}+ </div>+ );+}++/**+ * Renders a user message, handling both plain text messages and+ * XML-formatted messages from form submissions (which contain <content> and <context> tags).+ */+export const GenUIUserMessage = ({ message }: { message: UserMessage }) => {+ const rawContent = typeof message.content === "string" ? message.content : "";+ const { content: humanText, contextString } = separateContentAndContext(rawContent);+ const formState = parseContextForDisplay(contextString);+ const hasFormData = Object.keys(formState).length > 0;++ return (+ <div className="openui-shell-thread-message-user">+ <div className="openui-genui-user-message">+ {hasFormData && <FormDataAccordion state={formState} />}+ <div className="openui-shell-thread-message-user__content">+ {humanText && <div>{humanText}</div>}+ </div>+ </div>+ </div>+ );+};diff --git a/packages/react-ui/src/components/OpenUIChat/index.ts b/packages/react-ui/src/components/OpenUIChat/index.tsindex a6760fede..2afe1c22f 100644--- a/packages/react-ui/src/components/OpenUIChat/index.ts+++ b/packages/react-ui/src/components/OpenUIChat/index.ts@@ -1,6 +1,7 @@export { BottomTray } from "./ComposedBottomTray";export { Copilot } from "./ComposedCopilot";export { FullScreen } from "./ComposedStandalone";+export { GenUIUserMessage } from "./GenUIUserMessage";export type {AssistantMessageComponent,ComposerComponent,diff --git a/packages/react-ui/src/components/OpenUIChat/withChatProvider.tsx b/packages/react-ui/src/components/OpenUIChat/withChatProvider.tsxindex 7bdf5c219..c20bbe14f 100644--- a/packages/react-ui/src/components/OpenUIChat/withChatProvider.tsx+++ b/packages/react-ui/src/components/OpenUIChat/withChatProvider.tsx@@ -1,9 +1,10 @@import type { Library } from "@openuidev/lang-react";-import type { AssistantMessage, ChatProviderProps } from "@openuidev/react-headless";+import type { AssistantMessage, ChatProviderProps, UserMessage } from "@openuidev/react-headless";import { ChatProvider } from "@openuidev/react-headless";import { useMemo } from "react";import { ThemeProps, ThemeProvider } from "../ThemeProvider";import { GenUIAssistantMessage } from "./GenUIAssistantMessage";+import { GenUIUserMessage } from "./GenUIUserMessage";import type { SharedChatUIProps } from "./types";type ThemeWrapperProps = {@@ -54,6 +55,7 @@ export function withChatProvider<ExtraProps = {}>(WrappedComponent: React.Componconst componentLibrary = innerProps["componentLibrary"] as Library | undefined;const customAssistantMessage = innerProps["assistantMessage"];+ const customUserMessage = innerProps["userMessage"];const genUIAssistantMessage = useMemo(() => {if (customAssistantMessage || !componentLibrary) return undefined;@@ -62,9 +64,17 @@ export function withChatProvider<ExtraProps = {}>(WrappedComponent: React.Compon);}, [customAssistantMessage, componentLibrary]);+ const genUIUserMessage = useMemo(() => {+ if (customUserMessage || !componentLibrary) return undefined;+ return ({ message }: { message: UserMessage }) => <GenUIUserMessage message={message} />;+ }, [customUserMessage, componentLibrary]);+if (genUIAssistantMessage && !customAssistantMessage) {innerProps["assistantMessage"] = genUIAssistantMessage;}+ if (genUIUserMessage && !customUserMessage) {+ innerProps["userMessage"] = genUIUserMessage;+ }const ThemeProviderComponent = disableThemeProvider ? DummyThemeProvider : ThemeProvider;diff --git a/packages/react-ui/src/components/SectionBlock/FoldableSection.tsx b/packages/react-ui/src/components/SectionBlock/FoldableSection.tsxnew file mode 100644index 000000000..d6bd451a9--- /dev/null+++ b/packages/react-ui/src/components/SectionBlock/FoldableSection.tsx@@ -0,0 +1,102 @@+import * as AccordionPrimitive from "@radix-ui/react-accordion";+import clsx from "clsx";+import { ChevronRight } from "lucide-react";+import React, { forwardRef } from "react";+import { IconButton } from "../IconButton";+import { Separator } from "../Separator";+import "./foldableSection.scss";++export type FoldableSectionRootProps = AccordionPrimitive.AccordionMultipleProps;++export const FoldableSectionRoot = forwardRef<+ React.ComponentRef<typeof AccordionPrimitive.Root>,+ FoldableSectionRootProps+>(({ className, style, ...props }, ref) => (+ <AccordionPrimitive.Root+ ref={ref}+ className={clsx("openui-foldable-section-root", className)}+ style={style}+ {...props}+ />+));+FoldableSectionRoot.displayName = "FoldableSectionRoot";++export interface FoldableSectionItemProps+ extends React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item> {+ className?: string;+ style?: React.CSSProperties;+ value: string;+}++export const FoldableSectionItem = forwardRef<+ React.ComponentRef<typeof AccordionPrimitive.Item>,+ FoldableSectionItemProps+>(({ className, style, value, ...props }, ref) => (+ <AccordionPrimitive.Item+ ref={ref}+ className={clsx("openui-foldable-section-item", className)}+ style={style}+ value={value}+ {...props}+ />+));+FoldableSectionItem.displayName = "FoldableSectionItem";++export interface FoldableSectionTriggerProps+ extends React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger> {+ className?: string;+ style?: React.CSSProperties;+ text: React.ReactNode;+}++export const FoldableSectionTrigger = forwardRef<+ React.ComponentRef<typeof AccordionPrimitive.Trigger>,+ FoldableSectionTriggerProps+>(({ className, style, text, ...props }, ref) => (+ <AccordionPrimitive.Header className="openui-foldable-section-header">+ <AccordionPrimitive.Trigger+ ref={ref}+ className={clsx("openui-foldable-section-trigger", className)}+ style={style}+ {...props}+ >+ <div className="openui-foldable-section-trigger-content-wrapper">+ <Separator className="openui-foldable-section-trigger-content-separator" />+ <div className="openui-foldable-section-trigger-content-icon-button-wrapper">+ <IconButton+ icon={+ <ChevronRight className="openui-foldable-section-trigger-content-icon-button-icon" />+ }+ size="3-extra-small"+ variant="secondary"+ className="openui-foldable-section-trigger-content-icon-button"+ />+ <div className="openui-foldable-section-trigger-content-text">{text}</div>+ </div>+ </div>+ </AccordionPrimitive.Trigger>+ </AccordionPrimitive.Header>+));+FoldableSectionTrigger.displayName = "FoldableSectionTrigger";++export interface FoldableSectionContentProps+ extends React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content> {+ className?: string;+ style?: React.CSSProperties;+ children?: React.ReactNode;+}++export const FoldableSectionContent = forwardRef<+ React.ComponentRef<typeof AccordionPrimitive.Content>,+ FoldableSectionContentProps+>(({ className, style, children, ...props }, ref) => (+ <AccordionPrimitive.Content+ ref={ref}+ className={clsx("openui-foldable-section-content", className)}+ style={style}+ {...props}+ >+ {children}+ </AccordionPrimitive.Content>+));+FoldableSectionContent.displayName = "FoldableSectionContent";diff --git a/packages/react-ui/src/components/SectionBlock/SectionV2.tsx b/packages/react-ui/src/components/SectionBlock/SectionV2.tsxnew file mode 100644index 000000000..3f57087bf--- /dev/null+++ b/packages/react-ui/src/components/SectionBlock/SectionV2.tsx@@ -0,0 +1,22 @@+import React from "react";+import { Separator } from "../Separator";+import "./sectionV2.scss";++interface SectionV2Props {+ trigger: string;+ children?: React.ReactNode;+}++export const SectionV2 = ({ trigger, children }: SectionV2Props) => {+ return (+ <div className="openui-section-v2">+ <div className="openui-section-v2-wrapper">+ <Separator orientation="horizontal" />+ <div className="openui-section-v2-header">+ <div className="openui-section-v2-header-trigger">{trigger}</div>+ </div>+ <div className="openui-section-v2-content">{children}</div>+ </div>+ </div>+ );+};diff --git a/packages/react-ui/src/components/SectionBlock/foldableSection.scss b/packages/react-ui/src/components/SectionBlock/foldableSection.scssnew file mode 100644index 000000000..1fd984501--- /dev/null+++ b/packages/react-ui/src/components/SectionBlock/foldableSection.scss@@ -0,0 +1,103 @@+@use "../../cssUtils" as cssUtils;++.openui-foldable-section {+ box-sizing: border-box;+ padding: 0;+ margin: 0;+ width: 100%;++ &-root {+ display: flex;+ flex-direction: column;+ gap: cssUtils.$space-l;+ }++ &-item {+ width: 100%;+ display: flex;+ flex-direction: column;+ gap: cssUtils.$space-l;+ }++ &-header {+ display: flex;+ margin-block-start: 0;+ margin-block-end: 0;+ margin-inline-start: 0;+ margin-inline-end: 0;+ }++ &-trigger {+ background-color: transparent;+ border: none;+ padding: cssUtils.$space-m 0 cssUtils.$space-xs 0;+ width: 100%;+ flex: 1;+ display: flex;+ align-items: center;+ justify-content: space-between;+ color: cssUtils.$text-neutral-primary;+ cursor: pointer;++ &-content-wrapper {+ display: flex;+ flex-direction: column;+ gap: cssUtils.$space-l;+ align-items: start;+ justify-content: center;+ width: 100%;+ }++ &-content-separator {+ margin: cssUtils.$space-3xs;+ }++ &-content-icon-button-wrapper {+ display: flex;+ align-items: center;+ justify-content: start;+ gap: cssUtils.$space-s;+ width: 100%;+ }++ &-content-icon-button {+ flex-shrink: 0;++ &-icon {+ transition: transform 300ms cubic-bezier(0.87, 0, 0.13, 1);+ }+ }++ &[data-state="open"] {+ .openui-foldable-section-trigger-content-icon-button-icon {+ transform: rotate(90deg);+ }+ }++ &-content-text {+ @include cssUtils.typography(heading, small);+ flex-grow: 1;+ display: flex;+ align-items: center;+ justify-content: start;+ padding: 0;+ margin: 0;+ }+ }++ &-content {+ width: 100%;+ display: flex;+ flex-direction: column;+ gap: cssUtils.$space-xl;+ padding: 0 0 0 28px;++ &[data-state="open"] {+ height: fit-content;+ }++ &[data-state="closed"] {+ height: 0;+ }+ }+}diff --git a/packages/react-ui/src/components/SectionBlock/index.ts b/packages/react-ui/src/components/SectionBlock/index.tsnew file mode 100644index 000000000..17d82fc98--- /dev/null+++ b/packages/react-ui/src/components/SectionBlock/index.ts@@ -0,0 +1,2 @@+export * from "./FoldableSection";+export * from "./SectionV2";diff --git a/packages/react-ui/src/components/SectionBlock/sectionBlock.scss b/packages/react-ui/src/components/SectionBlock/sectionBlock.scssnew file mode 100644index 000000000..be055bed2--- /dev/null+++ b/packages/react-ui/src/components/SectionBlock/sectionBlock.scss@@ -0,0 +1,2 @@+@forward "./foldableSection.scss";+@forward "./sectionV2.scss";diff --git a/packages/react-ui/src/components/SectionBlock/sectionV2.scss b/packages/react-ui/src/components/SectionBlock/sectionV2.scssnew file mode 100644index 000000000..189f65b4c--- /dev/null+++ b/packages/react-ui/src/components/SectionBlock/sectionV2.scss@@ -0,0 +1,40 @@+@use "../../cssUtils" as cssUtils;++.openui-section-v2 {+ display: flex;+ flex-direction: column;+ align-items: flex-start;+ justify-content: center;+ gap: cssUtils.$space-xl;+ margin-top: cssUtils.$space-m;++ &-wrapper {+ display: flex;+ flex-direction: column;+ align-items: flex-start;+ justify-content: center;+ width: 100%;+ gap: cssUtils.$space-xl;+ }++ &-header {+ display: flex;+ flex-direction: row;+ align-items: center;+ justify-content: flex-start;+ gap: cssUtils.$space-s;+ margin-bottom: cssUtils.$space-2xs;++ &-trigger {+ @include cssUtils.typography(heading, small);+ color: cssUtils.$text-neutral-primary;+ }+ }++ &-content {+ width: 100%;+ gap: cssUtils.$space-xl;+ display: flex;+ flex-direction: column;+ }+}diff --git a/packages/react-ui/src/components/Shell/thread.scss b/packages/react-ui/src/components/Shell/thread.scssindex 996f7a596..63ec352f8 100644--- a/packages/react-ui/src/components/Shell/thread.scss+++ b/packages/react-ui/src/components/Shell/thread.scss@@ -268,3 +268,81 @@ $center-align-spacing: calc(32px + cssUtils.$space-s);display: flex;padding: 0 $center-align-spacing;}++// =============================================================================+// GenUI User Message — form data accordion above the user bubble+// =============================================================================++.openui-genui-user-message {+ display: flex;+ flex-direction: column;+ align-items: flex-end;+ gap: cssUtils.$space-s;+ max-width: 85%;+}++.openui-genui-user-message__form-state {+ border: 1px solid cssUtils.$border-interactive;+ border-radius: cssUtils.$radius-m;+ overflow: hidden;+ background-color: cssUtils.$foreground;+ width: 100%;+ transition: border-color 0.15s ease;++ &:hover {+ border-color: cssUtils.$border-interactive-emphasis;+ }+}++.openui-genui-user-message__form-state-header {+ @include cssUtils.button-reset;+ display: flex;+ align-items: center;+ justify-content: space-between;+ width: 100%;+ padding: cssUtils.$space-s cssUtils.$space-m;+ cursor: pointer;+ background-color: transparent;+}++.openui-genui-user-message__form-state-label {+ @include cssUtils.typography(label, small);+ color: cssUtils.$text-neutral-secondary;+}++.openui-genui-user-message__form-state-chevron {+ flex-shrink: 0;+ color: cssUtils.$text-neutral-secondary;+ transition: transform 0.2s ease;++ &--expanded {+ transform: rotate(180deg);+ }+}++.openui-genui-user-message__form-state-content {+ border-top: 1px solid cssUtils.$border-default;+ display: flex;+ flex-direction: column;+ gap: cssUtils.$space-xs;+ padding: cssUtils.$space-s cssUtils.$space-m;+}++.openui-genui-user-message__form-field {+ display: flex;+ gap: cssUtils.$space-xs;+ align-items: baseline;+}++.openui-genui-user-message__form-field-label {+ @include cssUtils.typography(label, small);+ color: cssUtils.$text-neutral-secondary;+ flex-shrink: 0;+}++.openui-genui-user-message__form-field-value {+ @include cssUtils.typography(label, small);+ color: cssUtils.$text-neutral-primary;+ overflow-wrap: break-word;+ min-width: 0;+}diff --git a/packages/react-ui/src/genui-lib/Action/schema.ts b/packages/react-ui/src/genui-lib/Action/schema.tsnew file mode 100644index 000000000..60d59f3fd--- /dev/null+++ b/packages/react-ui/src/genui-lib/Action/schema.ts@@ -0,0 +1,24 @@+import { BuiltinActionType } from "@openuidev/lang-react";+import { z } from "zod";++const continueConversationAction = z.object({+ type: z.literal(BuiltinActionType.ContinueConversation),+ /** Extra context string passed to the LLM — useful for carousel/list item data. */+ context: z.string().optional(),+});++const openUrlAction = z.object({+ type: z.literal(BuiltinActionType.OpenUrl),+ url: z.string(),+});++const customAction = z.object({+ type: z.string(),+ params: z.record(z.string(), z.any()).optional(),+});++export const actionSchema = z+ .union([openUrlAction, continueConversationAction, customAction])+ .optional();++export type ActionSchema = z.infer<typeof actionSchema>;diff --git a/packages/react-ui/src/genui-lib/Button/index.tsx b/packages/react-ui/src/genui-lib/Button/index.tsxindex 4329ef2fc..02ddbc3d8 100644--- a/packages/react-ui/src/genui-lib/Button/index.tsx+++ b/packages/react-ui/src/genui-lib/Button/index.tsx@@ -1,6 +1,7 @@"use client";import {+ BuiltinActionType,defineComponent,useFormName,useFormValidation,@@ -28,6 +29,7 @@ export const Button = defineComponent({const formName = useFormName();const isStreaming = useIsStreaming();const formValidation = useFormValidation();+ const label = props.label as string;return (<OpenUIButton@@ -36,16 +38,36 @@ export const Button = defineComponent({buttonType={props.type as "normal" | "destructive"}disabled={isStreaming}onClick={() => {- if (formValidation) {+ const action = props.action as+ | { type?: string; url?: string; context?: string; params?: Record<string, any> }+ | undefined;+ const actionType = action?.type ?? BuiltinActionType.ContinueConversation;++ // Only validate for primary buttons with continue_conversation action (form submit).+ // Secondary/tertiary buttons (e.g. "Ask to customize") skip validation.+ const variant = (props.variant as string) || "primary";+ if (+ formValidation &&+ variant === "primary" &&+ actionType === BuiltinActionType.ContinueConversation+ ) {const valid = formValidation.validateForm();if (!valid) return;}- const label = props.label as string;- const action = props.action as string;- triggerAction(label, `User clicked on Button: ${action}`, formName);+ const actionParams =+ actionType === BuiltinActionType.OpenUrl+ ? { url: action?.url }+ : {+ ...(action?.params ?? {}),+ ...(action?.context ? { context: action.context } : {}),+ };+ triggerAction(label, formName, {+ type: actionType,+ params: actionParams,+ });}}>- {props.label as string}+ {label}</OpenUIButton>);},diff --git a/packages/react-ui/src/genui-lib/Button/schema.ts b/packages/react-ui/src/genui-lib/Button/schema.tsindex ff27e3cc7..1d012a5f1 100644--- a/packages/react-ui/src/genui-lib/Button/schema.ts+++ b/packages/react-ui/src/genui-lib/Button/schema.ts@@ -1,8 +1,11 @@import { z } from "zod";+import { actionSchema } from "../Action/schema";++export { actionSchema, type ActionSchema } from "../Action/schema";export const ButtonSchema = z.object({label: z.string(),- action: z.string(),+ action: actionSchema,variant: z.enum(["primary", "secondary", "tertiary"]).optional(),type: z.enum(["normal", "destructive"]).optional(),size: z.enum(["extra-small", "small", "medium", "large"]).optional(),diff --git a/packages/react-ui/src/genui-lib/Carousel/index.tsx b/packages/react-ui/src/genui-lib/Carousel/index.tsxindex d139c76bd..cb9735491 100644--- a/packages/react-ui/src/genui-lib/Carousel/index.tsx+++ b/packages/react-ui/src/genui-lib/Carousel/index.tsx@@ -10,23 +10,22 @@ import {CarouselNext as OpenUICarouselNext,CarouselPrevious as OpenUICarouselPrevious,} from "../../components/Carousel";-import { Stack } from "../Stack";+import { ContentChildUnion } from "../unions";export const Carousel = defineComponent({name: "Carousel",props: z.object({- children: z.array(Stack.ref),-+ children: z.array(z.array(ContentChildUnion)),variant: z.enum(["card", "sunk"]).optional(),}),- description: "Horizontal scrollable carousel of Stack slides",+ description: "Horizontal scrollable carousel",component: ({ props, renderNode }) => {const items = props.children ?? [];return (<OpenUICarousel showButtons={true} variant={props.variant}><OpenUICarouselContent>{items.map((item, i) => (- <OpenUICarouselItem key={i}>{renderNode(item.props.children)}</OpenUICarouselItem>+ <OpenUICarouselItem key={i}>{renderNode(item)}</OpenUICarouselItem>))}</OpenUICarouselContent><OpenUICarouselPrevious icon={<ChevronLeft />} />diff --git a/packages/react-ui/src/genui-lib/Charts/ScatterChart.ts b/packages/react-ui/src/genui-lib/Charts/ScatterChart.tsindex 570098a6f..05e8f145f 100644--- a/packages/react-ui/src/genui-lib/Charts/ScatterChart.ts+++ b/packages/react-ui/src/genui-lib/Charts/ScatterChart.ts@@ -4,7 +4,7 @@ import { defineComponent } from "@openuidev/lang-react";import React from "react";import { z } from "zod";import { ScatterChart as ScatterChartComponent } from "../../components/Charts";-import { hasAllProps } from "../helpers";+import { asArray, hasAllProps } from "../helpers";import { ScatterSeriesSchema } from "./ScatterSeries";export const ScatterChartSchema = z.object({@@ -13,21 +13,30 @@ export const ScatterChartSchema = z.object({yLabel: z.string().optional(),});+const unwrap = (node: any) => (node?.type === "element" ? node.props : node);+export const ScatterChart = defineComponent({name: "ScatterChart",props: ScatterChartSchema,description: "X/Y scatter plot; use for correlations, distributions, and clustering",component: ({ props }) => {if (!hasAllProps(props as Record<string, unknown>, "datasets")) return null;- const datasets = (props as any).datasets as any[];- const data = datasets.map((ds: any) => ({- name: ds.name as string,- data: ((ds.points ?? []) as any[]).map((pt: any) => ({- x: pt.x as number,- y: pt.y as number,- ...(pt.z != null ? { z: pt.z as number } : {}),- })),- }));+ const rawDatasets = asArray((props as any).datasets);+ const data = rawDatasets.map((ds: any) => {+ const dsProps = unwrap(ds);+ const rawPoints = asArray(dsProps?.points);+ return {+ name: (dsProps?.name ?? "") as string,+ data: rawPoints.map((pt: any) => {+ const ptProps = unwrap(pt);+ return {+ x: Number(ptProps?.x),+ y: Number(ptProps?.y),+ ...(ptProps?.z != null ? { z: Number(ptProps.z) } : {}),+ };+ }),+ };+ });if (!data.length) return null;return React.createElement(ScatterChartComponent, {data,diff --git a/packages/react-ui/src/genui-lib/CheckBoxGroup/index.tsx b/packages/react-ui/src/genui-lib/CheckBoxGroup/index.tsxindex 3e5cf8857..dd86a8f52 100644--- a/packages/react-ui/src/genui-lib/CheckBoxGroup/index.tsx+++ b/packages/react-ui/src/genui-lib/CheckBoxGroup/index.tsx@@ -2,12 +2,11 @@import {defineComponent,- parseRules,+ parseStructuredRules,useFormName,useFormValidation,useGetFieldValue,useIsStreaming,- useSetDefaultValue,useSetFieldValue,type SubComponentOf,} from "@openuidev/lang-react";@@ -15,57 +14,17 @@ import React from "react";import { z } from "zod";import { CheckBoxGroup as OpenUICheckBoxGroup } from "../../components/CheckBoxGroup";import { CheckBoxItem as OpenUICheckBoxItem } from "../../components/CheckBoxItem";+import { rulesSchema } from "../rules";import { CheckBoxItemSchema } from "./schema";export { CheckBoxItemSchema } from "./schema";-type CheckBoxItemProps = z.infer<typeof CheckBoxItemSchema>;--function CheckBoxItemControlled({- item,- formName,- getFieldValue,- setFieldValue,- isStreaming,- onChangeExtra,-}: {- item: SubComponentOf<CheckBoxItemProps>;- formName: string | undefined;- getFieldValue: (formName: string | undefined, name: string) => any;- setFieldValue: (- formName: string | undefined,- componentType: string | undefined,- name: string,- value: any,- shouldTriggerSaveCallback?: boolean,- ) => void;- isStreaming: boolean;- onChangeExtra?: (childName: string, newVal: boolean) => void;-}) {- const existingValue = getFieldValue(formName, item.props.name);-- useSetDefaultValue({- formName,- componentType: "CheckBoxItem",- name: item.props.name,- existingValue,- defaultValue: item.props.defaultChecked,- });-- return (- <OpenUICheckBoxItem- name={item.props.name}- label={item.props.label}- description={item.props.description || ""}- checked={existingValue ?? item.props.defaultChecked}- onChange={(val: boolean) => {- setFieldValue(formName, "CheckBoxItem", item.props.name, val, true);- onChangeExtra?.(item.props.name, val);- }}- disabled={isStreaming}- />- );-}+type CheckBoxItemProps = {+ name: string;+ label: string;+ description: string;+ defaultChecked?: boolean;+};export const CheckBoxItem = defineComponent({name: "CheckBoxItem",@@ -79,7 +38,7 @@ export const CheckBoxGroup = defineComponent({props: z.object({name: z.string(),items: z.array(CheckBoxItem.ref),- rules: z.array(z.string()).optional(),+ rules: rulesSchema,}),description: "",component: ({ props }) => {@@ -89,44 +48,58 @@ export const CheckBoxGroup = defineComponent({const isStreaming = useIsStreaming();const formValidation = useFormValidation();- const rules = React.useMemo(() => parseRules(props.rules), [props.rules]);- const items = props.items ?? [];+ const fieldName = props.name as string;+ const rules = React.useMemo(() => parseStructuredRules(props.rules), [props.rules]);+ const items = (props.items ?? []) as Array<SubComponentOf<CheckBoxItemProps>>;- const getAggregateValue = React.useCallback(() => {- const aggregate: Record<string, boolean> = {};+ const getAggregate = React.useCallback((): Record<string, boolean> => {+ const stored = getFieldValue(formName, fieldName) as Record<string, boolean> | undefined;+ const result: Record<string, boolean> = {};for (const item of items) {- aggregate[item.props.name] = !!getFieldValue(formName, item.props.name);+ result[item.props.name] = stored?.[item.props.name] ?? item.props.defaultChecked ?? false;}- return aggregate;- }, [items, formName, getFieldValue]);+ return result;+ }, [formName, fieldName, items, getFieldValue]);++ React.useEffect(() => {+ if (!isStreaming && items.length > 0 && getFieldValue(formName, fieldName) == null) {+ const initial: Record<string, boolean> = {};+ for (const item of items) {+ initial[item.props.name] = item.props.defaultChecked ?? false;+ }+ setFieldValue(formName, "CheckBoxGroup", fieldName, initial, false);+ }+ }, [isStreaming]);React.useEffect(() => {if (!isStreaming && rules.length > 0 && formValidation) {- formValidation.registerField(props.name, rules, getAggregateValue);- return () => formValidation.unregisterField(props.name);+ formValidation.registerField(fieldName, rules, () => getFieldValue(formName, fieldName));+ return () => formValidation.unregisterField(fieldName);}return undefined;}, [isStreaming, rules.length > 0]);if (!items.length) return null;+ const aggregate = getAggregate();+return (<OpenUICheckBoxGroup>{items.map((item, i) => (- <CheckBoxItemControlled+ <OpenUICheckBoxItemkey={i}- item={item}- formName={formName}- getFieldValue={getFieldValue}- setFieldValue={setFieldValue}- isStreaming={isStreaming}- onChangeExtra={(childName: string, newVal: boolean) => {+ name={item.props.name}+ label={item.props.label}+ description={item.props.description || ""}+ checked={aggregate[item.props.name] ?? item.props.defaultChecked ?? false}+ onChange={(val: boolean) => {+ const newAggregate = { ...getAggregate(), [item.props.name]: val };+ setFieldValue(formName, "CheckBoxGroup", fieldName, newAggregate, true);if (rules.length > 0) {- const aggregate = getAggregateValue();- aggregate[childName] = newVal;- formValidation?.validateField(props.name, aggregate, rules);+ formValidation?.validateField(fieldName, newAggregate, rules);}}}+ disabled={isStreaming}/>))}</OpenUICheckBoxGroup>diff --git a/packages/react-ui/src/genui-lib/CheckBoxGroup/schema.ts b/packages/react-ui/src/genui-lib/CheckBoxGroup/schema.tsindex 02355a24f..f02dc15af 100644--- a/packages/react-ui/src/genui-lib/CheckBoxGroup/schema.ts+++ b/packages/react-ui/src/genui-lib/CheckBoxGroup/schema.ts@@ -1,4 +1,5 @@import { z } from "zod";+import { rulesSchema } from "../rules";export const CheckBoxItemSchema = z.object({label: z.string(),@@ -6,3 +7,9 @@ export const CheckBoxItemSchema = z.object({name: z.string(),defaultChecked: z.boolean().optional(),});++export const CheckBoxGroupSchema = z.object({+ name: z.string(),+ items: z.array(z.any()), // filled by CheckBoxItem.ref in index+ rules: rulesSchema,+});diff --git a/packages/react-ui/src/genui-lib/DatePicker/index.tsx b/packages/react-ui/src/genui-lib/DatePicker/index.tsxindex a5e8de612..4f289fb93 100644--- a/packages/react-ui/src/genui-lib/DatePicker/index.tsx+++ b/packages/react-ui/src/genui-lib/DatePicker/index.tsx@@ -2,7 +2,7 @@import {defineComponent,- parseRules,+ parseStructuredRules,useFormName,useFormValidation,useGetFieldValue,@@ -28,7 +28,7 @@ export const DatePicker = defineComponent({const fieldName = (props.name as string) || "date";const mode = (props.mode as "single" | "range") || "single";- const rules = React.useMemo(() => parseRules(props.rules), [props.rules]);+ const rules = React.useMemo(() => parseStructuredRules(props.rules), [props.rules]);const value = getFieldValue(formName, fieldName);React.useEffect(() => {diff --git a/packages/react-ui/src/genui-lib/DatePicker/schema.ts b/packages/react-ui/src/genui-lib/DatePicker/schema.tsindex 881e66716..f3ff46773 100644--- a/packages/react-ui/src/genui-lib/DatePicker/schema.ts+++ b/packages/react-ui/src/genui-lib/DatePicker/schema.ts@@ -1,9 +1,8 @@import { z } from "zod";--const validationRules = z.array(z.string()).optional();+import { rulesSchema } from "../rules";export const DatePickerSchema = z.object({name: z.string(),mode: z.enum(["single", "range"]),- rules: validationRules,+ rules: rulesSchema,});diff --git a/packages/react-ui/src/genui-lib/FollowUpBlock/index.tsx b/packages/react-ui/src/genui-lib/FollowUpBlock/index.tsxnew file mode 100644index 000000000..afcc5c7ab--- /dev/null+++ b/packages/react-ui/src/genui-lib/FollowUpBlock/index.tsx@@ -0,0 +1,28 @@+"use client";++import { defineComponent, useTriggerAction } from "@openuidev/lang-react";+import { z } from "zod";+import { FollowUpBlock as OpenUIFollowUpBlock } from "../../components/FollowUpBlock";+import { FollowUpItem as OpenUIFollowUpItem } from "../../components/FollowUpItem";+import { FollowUpItem } from "../FollowUpItem";++export const FollowUpBlock = defineComponent({+ name: "FollowUpBlock",+ props: z.object({+ items: z.array(FollowUpItem.ref),+ }),+ description: "List of clickable follow-up suggestions placed at the end of a response",+ component: ({ props }) => {+ const triggerAction = useTriggerAction();+ const items = (props.items ?? []) as any[];++ return (+ <OpenUIFollowUpBlock>+ {items.map((item, i) => {+ const text = String(item?.props?.text ?? "");+ return <OpenUIFollowUpItem key={i} text={text} onClick={() => triggerAction(text)} />;+ })}+ </OpenUIFollowUpBlock>+ );+ },+});diff --git a/packages/react-ui/src/genui-lib/FollowUpItem/index.tsx b/packages/react-ui/src/genui-lib/FollowUpItem/index.tsxnew file mode 100644index 000000000..691c74824--- /dev/null+++ b/packages/react-ui/src/genui-lib/FollowUpItem/index.tsx@@ -0,0 +1,13 @@+"use client";++import { defineComponent } from "@openuidev/lang-react";+import { z } from "zod";++export const FollowUpItem = defineComponent({+ name: "FollowUpItem",+ props: z.object({+ text: z.string(),+ }),+ description: "Clickable follow-up suggestion — when clicked, sends text as user message",+ component: () => null,+});diff --git a/packages/react-ui/src/genui-lib/Form/schema.ts b/packages/react-ui/src/genui-lib/Form/schema.tsindex 09a053322..518fe987d 100644--- a/packages/react-ui/src/genui-lib/Form/schema.ts+++ b/packages/react-ui/src/genui-lib/Form/schema.ts@@ -4,6 +4,6 @@ import { FormControl } from "../FormControl";export const FormSchema = z.object({name: z.string(),- fields: z.array(FormControl.ref),buttons: Buttons.ref,+ fields: z.array(FormControl.ref).default([]),});diff --git a/packages/react-ui/src/genui-lib/FormControl/index.tsx b/packages/react-ui/src/genui-lib/FormControl/index.tsxindex 78dece342..b22529845 100644--- a/packages/react-ui/src/genui-lib/FormControl/index.tsx+++ b/packages/react-ui/src/genui-lib/FormControl/index.tsx@@ -19,10 +19,13 @@ export const FormControl = defineComponent({const fieldName =inputObj?.type === "element" ? (inputObj.props?.name as string | undefined) : undefined;const error = fieldName ? formValidation?.errors[fieldName] : undefined;+ const isRequired = inputObj?.type === "element" && inputObj.props?.rules?.required === true;return (<OpenUIFormControl>- <OpenUILabel className="text-sm font-medium">{props.label as string}</OpenUILabel>+ <OpenUILabel className="text-sm font-medium" required={isRequired}>+ {props.label as string}+ </OpenUILabel>{renderNode(props.input)}{error ? (<OpenUIHint hasError={true}>diff --git a/packages/react-ui/src/genui-lib/Input/index.tsx b/packages/react-ui/src/genui-lib/Input/index.tsxindex 6999facee..9beee3cb1 100644--- a/packages/react-ui/src/genui-lib/Input/index.tsx+++ b/packages/react-ui/src/genui-lib/Input/index.tsx@@ -2,7 +2,7 @@import {defineComponent,- parseRules,+ parseStructuredRules,useFormName,useFormValidation,useGetFieldValue,@@ -27,7 +27,7 @@ export const Input = defineComponent({const formValidation = useFormValidation();const fieldName = props.name as string;- const rules = React.useMemo(() => parseRules(props.rules), [props.rules]);+ const rules = React.useMemo(() => parseStructuredRules(props.rules), [props.rules]);const savedValue = getFieldValue(formName, fieldName) ?? "";React.useEffect(() => {diff --git a/packages/react-ui/src/genui-lib/Input/schema.ts b/packages/react-ui/src/genui-lib/Input/schema.tsindex 4a531612d..948938a86 100644--- a/packages/react-ui/src/genui-lib/Input/schema.ts+++ b/packages/react-ui/src/genui-lib/Input/schema.ts@@ -1,10 +1,9 @@import { z } from "zod";--const validationRules = z.array(z.string()).optional();+import { rulesSchema } from "../rules";export const InputSchema = z.object({name: z.string(),placeholder: z.string().optional(),type: z.enum(["text", "email", "password", "number", "url"]).optional(),- rules: validationRules,+ rules: rulesSchema,});diff --git a/packages/react-ui/src/genui-lib/ListBlock/index.tsx b/packages/react-ui/src/genui-lib/ListBlock/index.tsxnew file mode 100644index 000000000..7a5255f42--- /dev/null+++ b/packages/react-ui/src/genui-lib/ListBlock/index.tsx@@ -0,0 +1,68 @@+"use client";++import { BuiltinActionType, defineComponent, useTriggerAction } from "@openuidev/lang-react";+import { ChevronRight } from "lucide-react";+import { z } from "zod";+import { ListBlock as OpenUIListBlock } from "../../components/ListBlock";+import { ListItem as OpenUIListItem } from "../../components/ListItem";+import { ActionSchema } from "../Action/schema";+import { ListItem } from "../ListItem";++export const ListBlock = defineComponent({+ name: "ListBlock",+ props: z.object({+ items: z.array(ListItem.ref),+ variant: z.enum(["number", "image"]).optional(),+ }),+ description:+ "A list of items with number or image indicators. Each item can optionally have an action.",+ component: ({ props }) => {+ const triggerAction = useTriggerAction();+ const items = (props.items ?? []) as any[];+ const variant = (props.variant as "number" | "image") ?? "number";+ const listHasSubtitle = items.some((item) => !!item?.props?.subtitle);++ return (+ <OpenUIListBlock variant={variant}>+ {items.map((item, index) => {+ const title = String(item?.props?.title ?? "");+ const subtitle = item?.props?.subtitle ? String(item.props.subtitle) : undefined;+ const image = item?.props?.image as { src: string; alt: string } | undefined;+ const actionLabel = item?.props?.actionLabel ? String(item.props.actionLabel) : undefined;+ const action = item?.props?.action as ActionSchema;+ const hasAction = !!action;++ const handleClick = hasAction+ ? () => {+ const actionType = action.type ?? BuiltinActionType.ContinueConversation;+ const actionParams =+ actionType === BuiltinActionType.OpenUrl+ ? { url: (action as any).url }+ : {+ ...((action as any).params ?? {}),+ ...((action as any).context ? { context: (action as any).context } : {}),+ };+ triggerAction(title, undefined, {+ type: actionType,+ params: actionParams,+ });+ }+ : undefined;++ return (+ <OpenUIListItem+ key={index}+ title={title}+ subtitle={subtitle}+ listHasSubtitle={listHasSubtitle}+ image={variant === "image" ? image : undefined}+ actionLabel={hasAction ? actionLabel : undefined}+ actionIcon={hasAction ? <ChevronRight size={16} /> : undefined}+ onClick={handleClick}+ />+ );+ })}+ </OpenUIListBlock>+ );+ },+});diff --git a/packages/react-ui/src/genui-lib/ListItem/index.tsx b/packages/react-ui/src/genui-lib/ListItem/index.tsxnew file mode 100644index 000000000..52284bb62--- /dev/null+++ b/packages/react-ui/src/genui-lib/ListItem/index.tsx@@ -0,0 +1,24 @@+"use client";++import { defineComponent } from "@openuidev/lang-react";+import { z } from "zod";+import { actionSchema } from "../Action/schema";++export const ListItem = defineComponent({+ name: "ListItem",+ props: z.object({+ title: z.string(),+ subtitle: z.string().optional(),+ image: z+ .object({+ src: z.string(),+ alt: z.string(),+ })+ .optional(),+ actionLabel: z.string().optional(),+ action: actionSchema,+ }),+ description:+ "Item in a ListBlock — displays a title with an optional subtitle and image. When action is provided, the item becomes clickable.",+ component: () => null,+});diff --git a/packages/react-ui/src/genui-lib/RadioGroup/index.tsx b/packages/react-ui/src/genui-lib/RadioGroup/index.tsxindex ab2c949bf..e7476b940 100644--- a/packages/react-ui/src/genui-lib/RadioGroup/index.tsx+++ b/packages/react-ui/src/genui-lib/RadioGroup/index.tsx@@ -2,18 +2,18 @@import {defineComponent,- parseRules,+ parseStructuredRules,useFormName,useFormValidation,useGetFieldValue,useIsStreaming,- useSetDefaultValue,useSetFieldValue,} from "@openuidev/lang-react";import React from "react";import { z } from "zod";import { RadioGroup as OpenUIRadioGroup } from "../../components/RadioGroup";import { RadioItem as OpenUIRadioItem } from "../../components/RadioItem";+import { rulesSchema } from "../rules";import { RadioItemSchema } from "./schema";export { RadioItemSchema } from "./schema";@@ -31,7 +31,7 @@ export const RadioGroup = defineComponent({name: z.string(),items: z.array(RadioItem.ref),defaultValue: z.string().optional(),- rules: z.array(z.string()).optional(),+ rules: rulesSchema,}),description: "",component: ({ props }) => {@@ -41,36 +41,42 @@ export const RadioGroup = defineComponent({const isStreaming = useIsStreaming();const formValidation = useFormValidation();- const rules = React.useMemo(() => parseRules(props.rules), [props.rules]);- const existingValue = getFieldValue(formName, props.name);+ const fieldName = props.name as string;+ const rules = React.useMemo(() => parseStructuredRules(props.rules), [props.rules]);+ const items = (props.items ?? []) as Array<{+ props: { value: string; label?: string; description?: string };+ }>;- useSetDefaultValue({- formName,- componentType: "RadioGroup",- name: props.name,- existingValue,- defaultValue: props.defaultValue,- });+ const value = (getFieldValue(formName, fieldName) ?? props.defaultValue) as string | undefined;++ React.useEffect(() => {+ if (+ !isStreaming &&+ props.defaultValue != null &&+ getFieldValue(formName, fieldName) == null+ ) {+ setFieldValue(formName, "RadioGroup", fieldName, props.defaultValue, false);+ }+ }, [isStreaming]);React.useEffect(() => {if (!isStreaming && rules.length > 0 && formValidation) {- formValidation.registerField(props.name, rules, () => getFieldValue(formName, props.name));- return () => formValidation.unregisterField(props.name);+ formValidation.registerField(fieldName, rules, () => getFieldValue(formName, fieldName));+ return () => formValidation.unregisterField(fieldName);}return undefined;}, [isStreaming, rules.length > 0]);- const items = props.items ?? [];if (!items.length) return null;return (<OpenUIRadioGroup- name={props.name}- value={existingValue ?? props.defaultValue}+ name={fieldName}+ value={value ?? ""}onValueChange={(val: string) => {- setFieldValue(formName, "RadioGroup", props.name, val, true);+ setFieldValue(formName, "RadioGroup", fieldName, val, true);if (rules.length > 0) {- formValidation?.validateField(props.name, val, rules);+ formValidation?.validateField(fieldName, val, rules);}}}disabled={isStreaming}diff --git a/packages/react-ui/src/genui-lib/SectionBlock/index.tsx b/packages/react-ui/src/genui-lib/SectionBlock/index.tsxnew file mode 100644index 000000000..5f475b523--- /dev/null+++ b/packages/react-ui/src/genui-lib/SectionBlock/index.tsx@@ -0,0 +1,88 @@+"use client";++import { defineComponent, useIsStreaming } from "@openuidev/lang-react";+import React from "react";+import { z } from "zod";+import {+ FoldableSectionContent,+ FoldableSectionItem,+ FoldableSectionRoot,+ FoldableSectionTrigger,+} from "../../components/SectionBlock/FoldableSection";+import { SectionV2 } from "../../components/SectionBlock/SectionV2";+import { SectionItem } from "../SectionItem";++export const SectionBlock = defineComponent({+ name: "SectionBlock",+ props: z.object({+ sections: z.array(SectionItem.ref),+ isFoldable: z.boolean().optional(),+ }),+ description:+ "Collapsible accordion sections. Auto-opens sections as they stream in. Use SectionItem for each section.",+ component: ({ props, renderNode }) => {+ const items = (props.sections ?? []) as any[];+ const isFoldable = props.isFoldable !== false;+ const isStreaming = useIsStreaming();++ const firstItemValue = items[0]?.props?.value as string | undefined;++ const [openItems, setOpenItems] = React.useState<string[]>([]);+ const userSelected = React.useRef(false);+ const prevLengthRef = React.useRef(0);+ const prevIsStreaming = React.useRef(isStreaming);++ // During streaming: auto-open each new section as it arrives+ React.useEffect(() => {+ if (items.length === 0) return;++ if (isStreaming && items.length > prevLengthRef.current && !userSelected.current) {+ const last = items[items.length - 1];+ const lastValue = last?.props?.value as string | undefined;+ if (lastValue) {+ setOpenItems((prev) => (prev.includes(lastValue) ? prev : [...prev, lastValue]));+ }+ } else {+ setOpenItems((prev) => (prev.length === 0 && firstItemValue ? [firstItemValue] : prev));+ }++ prevLengthRef.current = items.length;+ }, [items.length, isStreaming, firstItemValue]);++ // When streaming ends: collapse back to first item (unless user interacted)+ React.useEffect(() => {+ if (prevIsStreaming.current && !isStreaming && !userSelected.current && items.length > 0) {+ setOpenItems(firstItemValue ? [firstItemValue] : []);+ }+ prevIsStreaming.current = isStreaming;+ }, [isStreaming]);++ const handleValueChange = React.useCallback((value: string[] | undefined) => {+ userSelected.current = true;+ setOpenItems(value ?? []);+ }, []);++ if (!isFoldable) {+ return (+ <>+ {items.map((item, index) => (+ <SectionV2 key={index} trigger={String(item?.props?.trigger ?? "")}>+ {renderNode(item?.props?.content)}+ </SectionV2>+ ))}+ </>+ );+ }++ return (+ <FoldableSectionRoot type="multiple" value={openItems} onValueChange={handleValueChange}>+ {items.map((item, index) => (+ <FoldableSectionItem key={index} value={String(item?.props?.value ?? index)}>+ <FoldableSectionTrigger text={String(item?.props?.trigger ?? "")} />+ <FoldableSectionContent>{renderNode(item?.props?.content)}</FoldableSectionContent>+ </FoldableSectionItem>+ ))}+ </FoldableSectionRoot>+ );+ },+});diff --git a/packages/react-ui/src/genui-lib/SectionItem/index.tsx b/packages/react-ui/src/genui-lib/SectionItem/index.tsxnew file mode 100644index 000000000..5187bfb0e--- /dev/null+++ b/packages/react-ui/src/genui-lib/SectionItem/index.tsx@@ -0,0 +1,16 @@+"use client";++import { defineComponent } from "@openuidev/lang-react";+import { z } from "zod";+import { SectionContentChildUnion } from "../sectionContentUnion";++export const SectionItem = defineComponent({+ name: "SectionItem",+ props: z.object({+ value: z.string(),+ trigger: z.string(),+ content: z.array(SectionContentChildUnion),+ }),+ description: "Section with a label and collapsible content — used inside SectionBlock",+ component: () => null,+});diff --git a/packages/react-ui/src/genui-lib/Select/index.tsx b/packages/react-ui/src/genui-lib/Select/index.tsxindex b329f81ae..ea3137456 100644--- a/packages/react-ui/src/genui-lib/Select/index.tsx+++ b/packages/react-ui/src/genui-lib/Select/index.tsx@@ -2,7 +2,7 @@import {defineComponent,- parseRules,+ parseStructuredRules,useFormName,useFormValidation,useGetFieldValue,@@ -10,7 +10,6 @@ import {useSetFieldValue,} from "@openuidev/lang-react";import React from "react";-import { z } from "zod";import {Select as OpenUISelect,SelectContent as OpenUISelectContent,@@ -18,7 +17,7 @@ import {SelectTrigger as OpenUISelectTrigger,SelectValue as OpenUISelectValue,} from "../../components/Select";-import { SelectItemSchema } from "./schema";+import { SelectItemSchema, createSelectSchema } from "./schema";export { SelectItemSchema } from "./schema";@@ -31,12 +30,7 @@ export const SelectItem = defineComponent({export const Select = defineComponent({name: "Select",- props: z.object({- name: z.string(),- items: z.array(SelectItem.ref),- placeholder: z.string().optional(),- rules: z.array(z.string()).optional(),- }),+ props: createSelectSchema(SelectItem),description: "",component: ({ props }) => {const formName = useFormName();@@ -45,8 +39,10 @@ export const Select = defineComponent({const isStreaming = useIsStreaming();const formValidation = useFormValidation();- const rules = React.useMemo(() => parseRules(props.rules), [props.rules]);- const items = (props.items ?? []).filter((item) => item.props.value);+ const rules = React.useMemo(() => parseStructuredRules(props.rules), [props.rules]);+ const items = (+ (props.items ?? []) as Array<{ props: { value: string; label?: string } }>+ ).filter((item) => item.props.value);const value = getFieldValue(formName, props.name);React.useEffect(() => {diff --git a/packages/react-ui/src/genui-lib/Select/schema.ts b/packages/react-ui/src/genui-lib/Select/schema.tsindex 6577419eb..1d09c1cba 100644--- a/packages/react-ui/src/genui-lib/Select/schema.ts+++ b/packages/react-ui/src/genui-lib/Select/schema.ts@@ -1,4 +1,5 @@import { z } from "zod";+import { rulesSchema } from "../rules";type RefComponent = { ref: z.ZodTypeAny };@@ -12,6 +13,6 @@ export function createSelectSchema(SelectItem: RefComponent) {name: z.string(),items: z.array(SelectItem.ref),placeholder: z.string().optional(),- rules: z.array(z.string()).optional(),+ rules: rulesSchema,});}diff --git a/packages/react-ui/src/genui-lib/Slider/index.tsx b/packages/react-ui/src/genui-lib/Slider/index.tsxindex 555a17612..8ba149419 100644--- a/packages/react-ui/src/genui-lib/Slider/index.tsx+++ b/packages/react-ui/src/genui-lib/Slider/index.tsx@@ -2,7 +2,7 @@import {defineComponent,- parseRules,+ parseStructuredRules,useFormName,useFormValidation,useGetFieldValue,@@ -19,7 +19,7 @@ export { SliderSchema } from "./schema";export const Slider = defineComponent({name: "Slider",props: SliderSchema,- description: "",+ description: "Numeric slider input; supports continuous and discrete (stepped) variants",component: ({ props }) => {const formName = useFormName();const getFieldValue = useGetFieldValue();@@ -28,9 +28,9 @@ export const Slider = defineComponent({const formValidation = useFormValidation();const fieldName = props.name as string;- const rules = React.useMemo(() => parseRules(props.rules), [props.rules]);+ const rules = React.useMemo(() => parseStructuredRules(props.rules), [props.rules]);const existingValue = getFieldValue(formName, fieldName);- const defaultVal = props.defaultValue as number | undefined;+ const defaultVal = props.defaultValue;useSetDefaultValue({formName,@@ -57,7 +57,7 @@ export const Slider = defineComponent({min={props.min as number}max={props.max as number}step={props.step as number | undefined}- value={value != null ? [value as number] : undefined}+ defaultValue={value != null ? value : undefined}onValueCommit={(vals: number[]) => {setFieldValue(formName, "Slider", fieldName, vals[0], true);if (rules.length > 0) {diff --git a/packages/react-ui/src/genui-lib/Slider/schema.ts b/packages/react-ui/src/genui-lib/Slider/schema.tsindex 57977daf5..2e510fda9 100644--- a/packages/react-ui/src/genui-lib/Slider/schema.ts+++ b/packages/react-ui/src/genui-lib/Slider/schema.ts@@ -1,6 +1,5 @@import { z } from "zod";--const validationRules = z.array(z.string()).optional();+import { rulesSchema } from "../rules";export const SliderSchema = z.object({name: z.string(),@@ -8,6 +7,6 @@ export const SliderSchema = z.object({min: z.number(),max: z.number(),step: z.number().optional(),- defaultValue: z.number().optional(),- rules: validationRules,+ defaultValue: z.array(z.number()).optional(),+ rules: rulesSchema,});diff --git a/packages/react-ui/src/genui-lib/SwitchGroup/index.tsx b/packages/react-ui/src/genui-lib/SwitchGroup/index.tsxindex dfdd39ef6..1b94ed809 100644--- a/packages/react-ui/src/genui-lib/SwitchGroup/index.tsx+++ b/packages/react-ui/src/genui-lib/SwitchGroup/index.tsx@@ -1,6 +1,14 @@"use client";-import { defineComponent } from "@openuidev/lang-react";+import {+ defineComponent,+ useFormName,+ useGetFieldValue,+ useIsStreaming,+ useSetFieldValue,+ type SubComponentOf,+} from "@openuidev/lang-react";+import React from "react";import { z } from "zod";import { SwitchGroup as OpenUISwitchGroup } from "../../components/SwitchGroup";import { SwitchItem as OpenUISwitchItem } from "../../components/SwitchItem";@@ -8,6 +16,13 @@ import { SwitchItemSchema } from "./schema";export { SwitchItemSchema } from "./schema";+type SwitchItemProps = {+ name: string;+ label?: string;+ description?: string;+ defaultChecked?: boolean;+};+export const SwitchItem = defineComponent({name: "SwitchItem",props: SwitchItemSchema,@@ -18,24 +33,47 @@ export const SwitchItem = defineComponent({export const SwitchGroup = defineComponent({name: "SwitchGroup",props: z.object({+ name: z.string(),items: z.array(SwitchItem.ref),variant: z.enum(["clear", "card", "sunk"]).optional(),}),description: "Group of switch toggles",component: ({ props }) => {- const items = props.items ?? [];+ const formName = useFormName();+ const getFieldValue = useGetFieldValue();+ const setFieldValue = useSetFieldValue();+ const isStreaming = useIsStreaming();++ const fieldName = props.name as string;+ const items = (props.items ?? []) as Array<SubComponentOf<SwitchItemProps>>;++ const getAggregate = React.useCallback((): Record<string, boolean> => {+ const stored = getFieldValue(formName, fieldName) as Record<string, boolean> | undefined;+ const result: Record<string, boolean> = {};+ for (const item of items) {+ result[item.props.name] = stored?.[item.props.name] ?? item.props.defaultChecked ?? false;+ }+ return result;+ }, [formName, fieldName, items, getFieldValue]);++ if (!items.length) return null;++ const aggregate = getAggregate();+return (- <OpenUISwitchGroup variant={props.variant || "clear"}>+ <OpenUISwitchGroup variant={(props.variant as any) || "clear"}>{items.map((item, i) => (<OpenUISwitchItemkey={i}- label={item.props.label}- description={item.props.description}name={item.props.name}- value={item.props.value}- checked={item.props.checked}- defaultChecked={item.props.defaultChecked}- disabled={item.props.disabled}+ label={item.props.label}+ description={item.props.description || ""}+ checked={aggregate[item.props.name] ?? item.props.defaultChecked ?? false}+ onChange={(val: boolean) => {+ const newAggregate = { ...getAggregate(), [item.props.name]: val };+ setFieldValue(formName, "SwitchGroup", fieldName, newAggregate, true);+ }}+ disabled={isStreaming}/>))}</OpenUISwitchGroup>diff --git a/packages/react-ui/src/genui-lib/SwitchGroup/schema.ts b/packages/react-ui/src/genui-lib/SwitchGroup/schema.tsindex 1659493de..3ec0ebf54 100644--- a/packages/react-ui/src/genui-lib/SwitchGroup/schema.ts+++ b/packages/react-ui/src/genui-lib/SwitchGroup/schema.ts@@ -3,9 +3,12 @@ import { z } from "zod";export const SwitchItemSchema = z.object({label: z.string().optional(),description: z.string().optional(),- name: z.string().optional(),- value: z.string().optional(),- checked: z.boolean().optional(),+ name: z.string(),defaultChecked: z.boolean().optional(),- disabled: z.boolean().optional(),+});++export const SwitchGroupSchema = z.object({+ name: z.string(),+ items: z.array(z.any()), // filled by SwitchItem.ref in index+ variant: z.enum(["clear", "card", "sunk"]).optional(),});diff --git a/packages/react-ui/src/genui-lib/TextArea/index.tsx b/packages/react-ui/src/genui-lib/TextArea/index.tsxindex 2ab253f88..6c4985a04 100644--- a/packages/react-ui/src/genui-lib/TextArea/index.tsx+++ b/packages/react-ui/src/genui-lib/TextArea/index.tsx@@ -2,7 +2,7 @@import {defineComponent,- parseRules,+ parseStructuredRules,useFormName,useFormValidation,useGetFieldValue,@@ -27,7 +27,7 @@ export const TextArea = defineComponent({const formValidation = useFormValidation();const fieldName = props.name as string;- const rules = React.useMemo(() => parseRules(props.rules), [props.rules]);+ const rules = React.useMemo(() => parseStructuredRules(props.rules), [props.rules]);const savedValue = getFieldValue(formName, fieldName) ?? "";React.useEffect(() => {diff --git a/packages/react-ui/src/genui-lib/TextArea/schema.ts b/packages/react-ui/src/genui-lib/TextArea/schema.tsindex 20e5af76a..376136872 100644--- a/packages/react-ui/src/genui-lib/TextArea/schema.ts+++ b/packages/react-ui/src/genui-lib/TextArea/schema.ts@@ -1,10 +1,9 @@import { z } from "zod";--const validationRules = z.array(z.string()).optional();+import { rulesSchema } from "../rules";export const TextAreaSchema = z.object({name: z.string(),placeholder: z.string().optional(),rows: z.number().optional(),- rules: validationRules,+ rules: rulesSchema,});diff --git a/packages/react-ui/src/genui-lib/TextContent/index.tsx b/packages/react-ui/src/genui-lib/TextContent/index.tsxindex 2396429a5..c4d1e222b 100644--- a/packages/react-ui/src/genui-lib/TextContent/index.tsx+++ b/packages/react-ui/src/genui-lib/TextContent/index.tsx@@ -29,9 +29,10 @@ export const TextContent = defineComponent({"--openui-text-body-default": `var(${varName})`,"--openui-text-body-default-letter-spacing": `var(${varName}-letter-spacing)`,} as React.CSSProperties);+ const text = props.text == null ? "" : String(props.text);return (<div style={style}>- <MarkDownRenderer textMarkdown={props.text as string} />+ <MarkDownRenderer textMarkdown={text} /></div>);},diff --git a/packages/react-ui/src/genui-lib/helpers.ts b/packages/react-ui/src/genui-lib/helpers.tsindex ce68456eb..767cbf0a4 100644--- a/packages/react-ui/src/genui-lib/helpers.ts+++ b/packages/react-ui/src/genui-lib/helpers.ts@@ -25,6 +25,26 @@ export function buildChartData(series: unknown,): Record<string, string | number>[] {const lbls = asArray(labels) as string[];++ // Tabular format: labels = column names, series = 2D rows from Query results+ // e.g. AreaChart(data.columns, data.results) where columns=["day","views","users"]+ // and results=[["Mon",100,50],["Tue",200,75]]+ const rows = asArray(series);+ if (rows.length > 0 && Array.isArray(rows[0])) {+ // Column 0 = category labels, columns 1+ = series values+ const seriesNames = lbls.slice(1);+ return rows.map((row) => {+ const cells = row as unknown[];+ const point: Record<string, string | number> = { category: String(cells[0] ?? "") };+ seriesNames.forEach((name, si) => {+ const val = cells[si + 1];+ point[name] = typeof val === "number" ? val : Number(val) || 0;+ });+ return point;+ });+ }++ // Original format: labels = x-axis values, series = Series() elementsconst seriesNodes = asElementNodes(series);return lbls.map((label, i) => {const point: Record<string, string | number> = { category: label };diff --git a/packages/react-ui/src/genui-lib/index.ts b/packages/react-ui/src/genui-lib/index.tsindex 2bb95af70..f1ba4ffd3 100644--- a/packages/react-ui/src/genui-lib/index.ts+++ b/packages/react-ui/src/genui-lib/index.ts@@ -1,7 +1,15 @@export {- defaultAdditionalRules,- defaultComponentGroups,- defaultExamples,- defaultLibrary,- defaultPromptOptions,-} from "./defaultLibrary";+ openuiAdditionalRules,+ openuiComponentGroups,+ openuiExamples,+ openuiLibrary,+ openuiPromptOptions,+} from "./openuiLibrary";++export {+ openuiChatAdditionalRules,+ openuiChatComponentGroups,+ openuiChatExamples,+ openuiChatLibrary,+ openuiChatPromptOptions,+} from "./openuiChatLibrary";diff --git a/packages/react-ui/src/genui-lib/openuiChatLibrary.tsx b/packages/react-ui/src/genui-lib/openuiChatLibrary.tsxnew file mode 100644index 000000000..2c8a074a0--- /dev/null+++ b/packages/react-ui/src/genui-lib/openuiChatLibrary.tsx@@ -0,0 +1,359 @@+"use client";++import type { ComponentGroup, PromptOptions } from "@openuidev/lang-react";+import { createLibrary, defineComponent } from "@openuidev/lang-react";+import { z } from "zod";+import { Card as OpenUICard } from "../components/Card";++// Content+import { Callout } from "./Callout";+import { CardHeader } from "./CardHeader";+import { CodeBlock } from "./CodeBlock";+import { Image } from "./Image";+import { ImageBlock } from "./ImageBlock";+import { ImageGallery } from "./ImageGallery";+import { MarkDownRenderer } from "./MarkDownRenderer";+import { Separator } from "./Separator";+import { TextCallout } from "./TextCallout";+import { TextContent } from "./TextContent";++// Charts+import {+ AreaChartCondensed,+ BarChartCondensed,+ HorizontalBarChart,+ LineChartCondensed,+ PieChart,+ Point,+ RadarChart,+ RadialChart,+ ScatterChart,+ ScatterSeries,+ Series,+ SingleStackedBarChart,+ Slice,+} from "./Charts";++// Forms+import { CheckBoxGroup, CheckBoxItem } from "./CheckBoxGroup";+import { DatePicker } from "./DatePicker";+import { Form } from "./Form";+import { FormControl } from "./FormControl";+import { Input } from "./Input";+import { Label } from "./Label";+import { RadioGroup, RadioItem } from "./RadioGroup";+import { Select, SelectItem } from "./Select";+import { Slider } from "./Slider";+import { SwitchGroup, SwitchItem } from "./SwitchGroup";+import { TextArea } from "./TextArea";++// Buttons+import { Button } from "./Button";+import { Buttons } from "./Buttons";++// Layout (no Stack)+import { Accordion, AccordionItem } from "./Accordion";+import { Carousel } from "./Carousel";+import { Steps, StepsItem } from "./Steps";+import { TabItem, Tabs } from "./Tabs";++// Data Display+import { Col, Table } from "./Table";+import { Tag } from "./Tag";+import { TagBlock } from "./TagBlock";++// Chat-specific+import { FollowUpBlock } from "./FollowUpBlock";+import { FollowUpItem } from "./FollowUpItem";+import { ListBlock } from "./ListBlock";+import { ListItem } from "./ListItem";+import { SectionBlock } from "./SectionBlock";+import { SectionItem } from "./SectionItem";++import { ChatContentChildUnion } from "./unions";++// Tabs and Carousel are added here (not in unions.ts) to avoid the circular dep:+// Tabs/schema.ts imports ContentChildUnion from unions.ts.+const ChatCardChildUnion = z.union([...ChatContentChildUnion.options, Tabs.ref, Carousel.ref]);++// ── Locked Chat Card — no design params, always vertical ──++const ChatCard = defineComponent({+ name: "Card",+ props: z.object({+ children: z.array(ChatCardChildUnion),+ }),+ description:+ "Vertical container for all content in a chat response. Children stack top to bottom automatically.",+ component: ({ props, renderNode }) => (+ <OpenUICard+ width="full"+ style={{+ display: "flex",+ flexDirection: "column",+ gap: "var(--openui-space-m)",+ }}+ >+ {renderNode(props.children)}+ </OpenUICard>+ ),+});++// ── Component Groups ──++export const openuiChatComponentGroups: ComponentGroup[] = [+ {+ name: "Content",+ components: [+ "CardHeader",+ "TextContent",+ "MarkDownRenderer",+ "Callout",+ "TextCallout",+ "Image",+ "ImageBlock",+ "ImageGallery",+ "CodeBlock",+ "Separator",+ ],+ },+ {+ name: "Tables",+ components: ["Table", "Col"],+ },+ {+ name: "Charts (2D)",+ components: [+ "BarChart",+ "LineChart",+ "AreaChart",+ "RadarChart",+ "HorizontalBarChart",+ "Series",+ ],+ },+ {+ name: "Charts (1D)",+ components: ["PieChart", "RadialChart", "SingleStackedBarChart", "Slice"],+ },+ {+ name: "Charts (Scatter)",+ components: ["ScatterChart", "ScatterSeries", "Point"],+ },+ {+ name: "Forms",+ components: [+ "Form",+ "FormControl",+ "Label",+ "Input",+ "TextArea",+ "Select",+ "SelectItem",+ "DatePicker",+ "Slider",+ "CheckBoxGroup",+ "CheckBoxItem",+ "RadioGroup",+ "RadioItem",+ "SwitchGroup",+ "SwitchItem",+ ],+ notes: [+ "- Define EACH FormControl as its own reference — do NOT inline all controls in one array.",+ "- NEVER nest Form inside Form.",+ "- Form requires explicit buttons. Always pass a Buttons(...) reference as the third Form argument.",+ "- rules is an optional object: { required: true, email: true, min: 8, maxLength: 100 }",+ "- The renderer shows error messages automatically — do NOT generate error text in the UI",+ ],+ },+ {+ name: "Buttons",+ components: ["Button", "Buttons"],+ },+ {+ name: "Lists & Follow-ups",+ components: ["ListBlock", "ListItem", "FollowUpBlock", "FollowUpItem"],+ notes: [+ "- Use ListBlock with ListItem references for numbered, clickable lists.",+ "- Use FollowUpBlock with FollowUpItem references at the end of a response to suggest next actions.",+ "- Clicking a ListItem or FollowUpItem sends its text to the LLM as a user message.",+ '- Example: list = ListBlock([item1, item2]) item1 = ListItem("Option A", "Details about A")',+ ],+ },+ {+ name: "Sections",+ components: ["SectionBlock", "SectionItem"],+ notes: [+ "- SectionBlock renders collapsible accordion sections that auto-open as they stream.",+ "- Each section needs a unique `value` id, a `trigger` label, and a `content` array.",+ '- Example: sections = SectionBlock([s1, s2]) s1 = SectionItem("intro", "Introduction", [content1])',+ "- Set isFoldable=false to render sections as flat headers instead of accordion.",+ ],+ },+ {+ name: "Layout",+ components: ["Tabs", "TabItem", "Accordion", "AccordionItem", "Steps", "StepsItem", "Carousel"],+ notes: [+ "- Use Tabs to present alternative views — each TabItem has a value id, trigger label, and content array.",+ "- Carousel takes an array of slides, where each slide is an array of content: carousel = Carousel([[t1, img1], [t2, img2]])",+ "- IMPORTANT: Every slide in a Carousel must have the same structure — same component types in the same order.",+ "- For image carousels use: [[title, image, description, tags], ...] — every slide must follow this exact pattern.",+ "- Use real, publicly accessible image URLs (e.g. https://picsum.photos/seed/KEYWORD/800/500). Never hallucinate image URLs.",+ ],+ },+ {+ name: "Data Display",+ components: ["TagBlock", "Tag"],+ },+];++// ── Examples ──++export const openuiChatExamples: string[] = [+ `Example 1 — Table with follow-ups:+root = Card([title, tbl, followUps])+title = TextContent("Top Languages", "large-heavy")+tbl = Table(cols, rows)+cols = [Col("Language", "string"), Col("Users (M)", "number"), Col("Year", "number")]+rows = [["Python", 15.7, 1991], ["JavaScript", 14.2, 1995], ["Java", 12.1, 1995]]+followUps = FollowUpBlock([fu1, fu2])+fu1 = FollowUpItem("Tell me more about Python")+fu2 = FollowUpItem("Show me a JavaScript comparison")`,++ `Example 2 — Clickable list:+root = Card([title, list])+title = TextContent("Choose a topic", "large-heavy")+list = ListBlock([item1, item2, item3])+item1 = ListItem("Getting started", "New to the platform? Start here.")+item2 = ListItem("Advanced features", "Deep dives into powerful capabilities.")+item3 = ListItem("Troubleshooting", "Common issues and how to fix them.")`,++ `Example 3 — Image carousel with consistent slides + follow-ups:+root = Card([header, carousel, followups])+header = CardHeader("Featured Destinations", "Discover highlights and best time to visit")+carousel = Carousel([[t1, img1, d1, tags1], [t2, img2, d2, tags2], [t3, img3, d3, tags3]], "card")+t1 = TextContent("Paris, France", "large-heavy")+img1 = ImageBlock("https://picsum.photos/seed/paris/800/500", "Eiffel Tower at night")+d1 = TextContent("City of light — best Apr–Jun and Sep–Oct.", "default")+tags1 = TagBlock(["Landmark", "City Break", "Culture"])+t2 = TextContent("Kyoto, Japan", "large-heavy")+img2 = ImageBlock("https://picsum.photos/seed/kyoto/800/500", "Bamboo grove in Arashiyama")+d2 = TextContent("Temples and bamboo groves — best Mar–Apr and Nov.", "default")+tags2 = TagBlock(["Temples", "Autumn", "Culture"])+t3 = TextContent("Machu Picchu, Peru", "large-heavy")+img3 = ImageBlock("https://picsum.photos/seed/machupicchu/800/500", "Inca citadel in the clouds")+d3 = TextContent("High-altitude Inca citadel — best May–Sep.", "default")+tags3 = TagBlock(["Andes", "Hike", "UNESCO"])+followups = FollowUpBlock([fu1, fu2])+fu1 = FollowUpItem("Show me only beach destinations")+fu2 = FollowUpItem("Turn this into a comparison table")`,++ `Example 4 — Form with validation:+root = Card([title, form])+title = TextContent("Contact Us", "large-heavy")+form = Form("contact", btns, [nameField, emailField, msgField])+nameField = FormControl("Name", Input("name", "Your name", "text", { required: true, minLength: 2 }))+emailField = FormControl("Email", Input("email", "[email protected]", "email", { required: true, email: true }))+msgField = FormControl("Message", TextArea("message", "Tell us more...", 4, { required: true, minLength: 10 }))+btns = Buttons([Button("Submit", { type: "continue_conversation" }, "primary")])`,+];++export const openuiChatAdditionalRules: string[] = [+ "Every response is a single Card(children) — children stack vertically automatically. No layout params are needed on Card.",+ "Card is the only layout container. Do NOT use Stack. Use Tabs to switch between sections, Carousel for horizontal scroll.",+ "Use FollowUpBlock at the END of a Card to suggest what the user can do or ask next.",+ "Use ListBlock when presenting a set of options or steps the user can click to select.",+ "Use SectionBlock to group long responses into collapsible sections — good for reports, FAQs, and structured content.",+ "Use SectionItem inside SectionBlock: each item needs a unique value id, a trigger (header label), and a content array.",+ "Carousel takes an array of slides, where each slide is an array of content: carousel = Carousel([[t1, img1], [t2, img2]])",+ "IMPORTANT: Every slide in a Carousel must use the same component structure in the same order — e.g. all slides: [title, image, description, tags].",+ "For image carousels, always use real accessible URLs like https://picsum.photos/seed/KEYWORD/800/500. Never hallucinate or invent image URLs.",+ "For forms, define one FormControl reference per field so controls can stream progressively.",+ "For forms, always provide the second Form argument with Buttons(...) actions: Form(name, buttons, fields).",+ "Never nest Form inside Form.",+];++export const openuiChatPromptOptions: PromptOptions = {+ examples: openuiChatExamples,+ additionalRules: openuiChatAdditionalRules,+};++// ── Library ──++export const openuiChatLibrary = createLibrary({+ root: "Card",+ componentGroups: openuiChatComponentGroups,+ components: [+ // Root+ ChatCard,+ CardHeader,+ // Content+ TextContent,+ MarkDownRenderer,+ Callout,+ TextCallout,+ Image,+ ImageBlock,+ ImageGallery,+ CodeBlock,+ Separator,+ // Tables+ Table,+ Col,+ // Charts (2D)+ BarChartCondensed,+ LineChartCondensed,+ AreaChartCondensed,+ RadarChart,+ HorizontalBarChart,+ Series,+ // Charts (1D)+ PieChart,+ RadialChart,+ SingleStackedBarChart,+ Slice,+ // Charts (Scatter)+ ScatterChart,+ ScatterSeries,+ Point,+ // Forms+ Form,+ FormControl,+ Label,+ Input,+ TextArea,+ Select,+ SelectItem,+ DatePicker,+ Slider,+ CheckBoxGroup,+ CheckBoxItem,+ RadioGroup,+ RadioItem,+ SwitchGroup,+ SwitchItem,+ // Buttons+ Button,+ Buttons,+ // Lists & Follow-ups+ ListBlock,+ ListItem,+ FollowUpBlock,+ FollowUpItem,+ // Sections+ SectionBlock,+ SectionItem,+ // Layout (no Stack)+ Tabs,+ TabItem,+ Accordion,+ AccordionItem,+ Steps,+ StepsItem,+ Carousel,+ // Data Display+ TagBlock,+ Tag,+ ],+});diff --git a/packages/react-ui/src/genui-lib/defaultLibrary.tsx b/packages/react-ui/src/genui-lib/openuiLibrary.tsxsimilarity index 89%rename from packages/react-ui/src/genui-lib/defaultLibrary.tsxrename to packages/react-ui/src/genui-lib/openuiLibrary.tsxindex 8f1f25158..7d87e757e 100644--- a/packages/react-ui/src/genui-lib/defaultLibrary.tsx+++ b/packages/react-ui/src/genui-lib/openuiLibrary.tsx@@ -64,7 +64,7 @@ import { TagBlock } from "./TagBlock";// ── Component Groups ──-export const defaultComponentGroups: ComponentGroup[] = [+export const openuiComponentGroups: ComponentGroup[] = [{name: "Layout",components: [@@ -162,7 +162,7 @@ export const defaultComponentGroups: ComponentGroup[] = [// ── Examples ──-export const defaultExamples: string[] = [+export const openuiExamples: string[] = [`Example 1 — Table:root = Stack([title, tbl])title = TextContent("Top Languages", "large-heavy")@@ -181,13 +181,13 @@ s2 = Series("Product B", [90, 110, 140])`,`Example 3 — Form with validation:root = Stack([title, form])title = TextContent("Contact Us", "large-heavy")-form = Form("contact", [nameField, emailField, countryField, msgField], btns)-nameField = FormControl("Name", Input("name", "Your name", "text", ["required", "minLength:2"]))-emailField = FormControl("Email", Input("email", "[email protected]", "email", ["required", "email"]))-countryField = FormControl("Country", Select("country", countryOpts, "Select...", ["required"]))-msgField = FormControl("Message", TextArea("message", "Tell us more...", 4, ["required", "minLength:10"]))+form = Form("contact", btns, [nameField, emailField, countryField, msgField])+nameField = FormControl("Name", Input("name", "Your name", "text", { required: true, minLength: 2 }))+emailField = FormControl("Email", Input("email", "[email protected]", "email", { required: true, email: true }))+countryField = FormControl("Country", Select("country", countryOpts, "Select...", { required: true }))+msgField = FormControl("Message", TextArea("message", "Tell us more...", 4, { required: true, minLength: 10 }))countryOpts = [SelectItem("us", "United States"), SelectItem("uk", "United Kingdom"), SelectItem("de", "Germany")]-btns = Buttons([Button("Submit", "submit:contact", "primary"), Button("Cancel", "action:cancel_contact", "secondary")])`,+btns = Buttons([Button("Submit", { type: "continue_conversation" }, "primary"), Button("Cancel", { type: "continue_conversation" }, "secondary")])`,`Example 4 — Tabs with mixed content:root = Stack([title, tabs])@@ -199,23 +199,23 @@ reactContent = [TextContent("React is a library by Meta for building UIs."), CalvueContent = [TextContent("Vue is a progressive framework by Evan You."), Callout("success", "Tip", "Vue has a gentle learning curve.")]`,];-export const defaultAdditionalRules: string[] = [+export const openuiAdditionalRules: string[] = ['For grid-like layouts, use Stack with direction "row" and wrap=true. Avoid justify="between" unless you specifically want large gutters.',"For forms, define one FormControl reference per field so controls can stream progressively.",- "For forms, always provide the third Form argument with Buttons(...) actions.",+ "For forms, always provide the second Form argument with Buttons(...) actions: Form(name, buttons, fields).","Never nest Form inside Form.",];-export const defaultPromptOptions: PromptOptions = {- examples: defaultExamples,- additionalRules: defaultAdditionalRules,+export const openuiPromptOptions: PromptOptions = {+ examples: openuiExamples,+ additionalRules: openuiAdditionalRules,};// ── Library ──-export const defaultLibrary = createLibrary({+export const openuiLibrary = createLibrary({root: "Stack",- componentGroups: defaultComponentGroups,+ componentGroups: openuiComponentGroups,components: [// ContentCard,diff --git a/packages/react-ui/src/genui-lib/rules.ts b/packages/react-ui/src/genui-lib/rules.tsnew file mode 100644index 000000000..1dbb36b1a--- /dev/null+++ b/packages/react-ui/src/genui-lib/rules.ts@@ -0,0 +1,22 @@+import { z } from "zod";++/**+ * Structured validation rules for form field components.+ * Example: { required: true, email: true, minLength: 5, max: 100 }+ * Available keys: required, email, url, numeric, min (number), max (number), minLength (number), maxLength (number), pattern (regex string)+ */+export const rulesSchema = z+ .object({+ required: z.boolean().optional(),+ email: z.boolean().optional(),+ url: z.boolean().optional(),+ numeric: z.boolean().optional(),+ min: z.number().optional(),+ max: z.number().optional(),+ minLength: z.number().optional(),+ maxLength: z.number().optional(),+ pattern: z.string().optional(),+ })+ .optional();++export type RulesSchema = z.infer<typeof rulesSchema>;diff --git a/packages/react-ui/src/genui-lib/sectionContentUnion.ts b/packages/react-ui/src/genui-lib/sectionContentUnion.tsnew file mode 100644index 000000000..df269375d--- /dev/null+++ b/packages/react-ui/src/genui-lib/sectionContentUnion.ts@@ -0,0 +1,63 @@+import { z } from "zod";++import { Callout } from "./Callout";+import { CardHeader } from "./CardHeader";+import { CodeBlock } from "./CodeBlock";+import { Image } from "./Image";+import { ImageBlock } from "./ImageBlock";+import { ImageGallery } from "./ImageGallery";+import { MarkDownRenderer } from "./MarkDownRenderer";+import { Separator } from "./Separator";+import { TextCallout } from "./TextCallout";+import { TextContent } from "./TextContent";++import {+ AreaChartCondensed,+ BarChartCondensed,+ HorizontalBarChart,+ LineChartCondensed,+ PieChart,+ RadarChart,+ RadialChart,+ ScatterChart,+ SingleStackedBarChart,+} from "./Charts";++import { Buttons } from "./Buttons";+import { FollowUpBlock } from "./FollowUpBlock";+import { Form } from "./Form";+import { ListBlock } from "./ListBlock";+import { Steps } from "./Steps";+import { Table } from "./Table";+import { TagBlock } from "./TagBlock";++// Content allowed inside a SectionBlock section.+// Does NOT include SectionBlock (no nesting), Tabs, or Accordion (avoids circular deps).+export const SectionContentChildUnion = z.union([+ TextContent.ref,+ MarkDownRenderer.ref,+ CardHeader.ref,+ Callout.ref,+ TextCallout.ref,+ CodeBlock.ref,+ Image.ref,+ ImageBlock.ref,+ ImageGallery.ref,+ Separator.ref,+ HorizontalBarChart.ref,+ RadarChart.ref,+ PieChart.ref,+ RadialChart.ref,+ SingleStackedBarChart.ref,+ ScatterChart.ref,+ AreaChartCondensed.ref,+ BarChartCondensed.ref,+ LineChartCondensed.ref,+ Table.ref,+ TagBlock.ref,+ Form.ref,+ Buttons.ref,+ Steps.ref,+ ListBlock.ref,+ FollowUpBlock.ref,+]);diff --git a/packages/react-ui/src/genui-lib/unions.ts b/packages/react-ui/src/genui-lib/unions.tsindex 85538d888..cb10d5146 100644--- a/packages/react-ui/src/genui-lib/unions.ts+++ b/packages/react-ui/src/genui-lib/unions.ts@@ -31,6 +31,10 @@ import { Form } from "./Form";import { Steps } from "./Steps";+import { FollowUpBlock } from "./FollowUpBlock";+import { ListBlock } from "./ListBlock";+import { SectionBlock } from "./SectionBlock";+export const ContentChildUnion = z.union([TextContent.ref,MarkDownRenderer.ref,@@ -57,3 +61,13 @@ export const ContentChildUnion = z.union([Buttons.ref,Steps.ref,]);++// Chat-specific content union — no Stack, adds ListBlock / FollowUpBlock / SectionBlock+// Note: Tabs and Carousel are NOT included here to avoid circular deps (Tabs/schema.ts imports ContentChildUnion).+// ChatCardChildUnion (which adds Tabs + Carousel) is defined in openuiChatLibrary.tsx.+export const ChatContentChildUnion = z.union([+ ...ContentChildUnion.options,+ ListBlock.ref,+ FollowUpBlock.ref,+ SectionBlock.ref,+]);diff --git a/packages/react-ui/src/index.ts b/packages/react-ui/src/index.tsindex eea2745ae..463ba3773 100644--- a/packages/react-ui/src/index.ts+++ b/packages/react-ui/src/index.ts@@ -31,6 +31,7 @@ export * from "./components/MessageLoading";export * from "./components/OpenUIChat";export * from "./components/RadioGroup";export * from "./components/RadioItem";+export * from "./components/SectionBlock";export * from "./components/Select";export * from "./components/Separator";export * as Shell from "./components/Shell";@@ -58,11 +59,16 @@ export * from "./components/ToolResult";// Genui-lib standard libraryexport {- defaultAdditionalRules,- defaultComponentGroups,- defaultExamples,- defaultLibrary,- defaultPromptOptions,+ openuiAdditionalRules,+ openuiChatAdditionalRules,+ openuiChatComponentGroups,+ openuiChatExamples,+ openuiChatLibrary,+ openuiChatPromptOptions,+ openuiComponentGroups,+ openuiExamples,+ openuiLibrary,+ openuiPromptOptions,} from "./genui-lib";// this is the context providers that are used in the shelldiff --git a/packages/react-ui/src/utils/contentParser.ts b/packages/react-ui/src/utils/contentParser.tsnew file mode 100644index 000000000..9b2daa206--- /dev/null+++ b/packages/react-ui/src/utils/contentParser.ts@@ -0,0 +1,35 @@+const openTag = (tag: string) => `<${tag}>`;+const closeTag = (tag: string) => `</${tag}>`;++export function wrapContent(text: string): string {+ return `${openTag("content")}${text}${closeTag("content")}`;+}++export function wrapContext(json: string): string {+ return `${openTag("context")}${json}${closeTag("context")}`;+}++/**+ * Separate openui-lang code from <context> tag in a message.+ * Returns { content: the message/code, contextString: raw JSON or null }+ */+export function separateContentAndContext(raw: string): {+ content: string;+ contextString: string | null;+} {+ const contextMatch = raw.match(/<context>([\s\S]*)<\/context>\s*$/);+ let content = raw;+ let contextString: string | null = null;++ if (contextMatch) {+ contextString = contextMatch[1] ?? null;+ content = raw.slice(0, contextMatch.index!).trimEnd();+ }++ const contentMatch = content.match(/^<content>([\s\S]*)<\/content>\s*$/);+ if (contentMatch) {+ content = contentMatch[1] ?? content;+ }++ return { content, contextString };+}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 88e73c820..70b0c0d85 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -231,7 +231,7 @@ importers:version: 6.22.0([email protected])([email protected])vitest:specifier: ^4.0.18- version: 4.0.18(@opentelemetry/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])+ version: 4.0.18(@opentelemetry/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])packages/react-ui:dependencies:@@ -455,6 +455,9 @@ importers:packages:+ '@acemir/[email protected]':+ resolution: {integrity: sha512-ZnR3GSaH+/vJ0YlHau21FjfLYjMpYVIzTD8M8vIEQvIGxeOXyXdzCI140rrCY862p/C/BbzWsjc1dgnM9mkoTA==}+'@adobe/[email protected]':resolution: {integrity: sha512-VQKMkwriZbaOgVCby1UDY/LDk5fIjhQicCvVPFqfe+69fWaPWydbWJ3wRt59/YzIwda1I81loas3oCoHxnqvdA==}@@ -469,6 +472,16 @@ packages:resolution: {integrity: sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==}engines: {node: '>=6.0.0'}+ '@asamuzakjp/[email protected]':+ resolution: {integrity: sha512-2SZFvqMyvboVV1d15lMf7XiI3m7SDqXUuKaTymJYLN6dSGadqp+fVojqJlVoMlbZnlTmu3S0TLwLTJpvBMO1Aw==}+ engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}++ '@asamuzakjp/[email protected]':+ resolution: {integrity: sha512-MvRz1nCqW0fsy8Qz4dnLIvhOlMzqDVBabZx6lH+YywFDdjXhMY37SmpV1XFX3JzG5GWHn63j6HX6QPr3lZXHvQ==}++ '@asamuzakjp/[email protected]':+ resolution: {integrity: sha512-n8GuYSrI9bF7FFZ/SjhwevlHc8xaVlb/7HmHelnc/PZXBD2ZR49NnN9sMMuDdEGPeeRQ5d0hqlSlEpgCX3Wl0Q==}+'@babel/[email protected]':resolution: {integrity: sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==}engines: {node: '>=6.9.0'}@@ -595,12 +608,47 @@ packages:resolution: {integrity: sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A==}engines: {node: '>=6.9.0'}+ '@bramus/[email protected]':+ resolution: {integrity: sha512-ctxtJ/eA+t+6q2++vj5j7FYX3nRu311q1wfYH3xjlLOsczhlhxAg2FWNUXhpGvAw3BWo1xBcvOV6/YLc2r5FJw==}+ hasBin: true+'@chromatic-com/[email protected]':resolution: {integrity: sha512-FDmn5Ry2DzQdik+eq2sp/kJMMT36Ewe7ONXUXM2Izd97c7r6R/QyGli8eyh/F0iyqVvbLveNYFyF0dBOJNwLqw==}engines: {node: '>=16.0.0', yarn: '>=1.22.18'}peerDependencies:storybook: ^8.2.0 || ^8.3.0-0 || ^8.4.0-0 || ^8.5.0-0 || ^8.6.0-0+ '@csstools/[email protected]':+ resolution: {integrity: sha512-LMGQLS9EuADloEFkcTBR3BwV/CGHV7zyDxVRtVDTwdI2Ca4it0CCVTT9wCkxSgokjE5Ho41hEPgb8OEUwoXr6Q==}+ engines: {node: '>=20.19.0'}++ '@csstools/[email protected]':+ resolution: {integrity: sha512-HJ26Z/vmsZQqs/o3a6bgKslXGFAungXGbinULZO3eMsOyNJHeBBZfup5FiZInOghgoM4Hwnmw+OgbJCNg1wwUQ==}+ engines: {node: '>=20.19.0'}+ peerDependencies:+ '@csstools/css-parser-algorithms': ^4.0.0+ '@csstools/css-tokenizer': ^4.0.0++ '@csstools/[email protected]':+ resolution: {integrity: sha512-0GEfbBLmTFf0dJlpsNU7zwxRIH0/BGEMuXLTCvFYxuL1tNhqzTbtnFICyJLTNK4a+RechKP75e7w42ClXSnJQw==}+ engines: {node: '>=20.19.0'}+ peerDependencies:+ '@csstools/css-parser-algorithms': ^4.0.0+ '@csstools/css-tokenizer': ^4.0.0++ '@csstools/[email protected]':+ resolution: {integrity: sha512-+B87qS7fIG3L5h3qwJ/IFbjoVoOe/bpOdh9hAjXbvx0o8ImEmUsGXN0inFOnk2ChCFgqkkGFQ+TpM5rbhkKe4w==}+ engines: {node: '>=20.19.0'}+ peerDependencies:+ '@csstools/css-tokenizer': ^4.0.0++ '@csstools/[email protected]':+ resolution: {integrity: sha512-H4tuz2nhWgNKLt1inYpoVCfbJbMwX/lQKp3g69rrrIMIYlFD9+zTykOKhNR8uGrAmbS/kT9n6hTFkmDkxLgeTA==}++ '@csstools/[email protected]':+ resolution: {integrity: sha512-QxULHAm7cNu72w97JUNCBFODFaXpbDg+dP8b/oWFAZ2MTRppA3U00Y2L1HqaS4J6yBqxwa/Y3nMBaxVKbB/NsA==}+ engines: {node: '>=20.19.0'}+'@date-fns/[email protected]':resolution: {integrity: sha512-LBrd7MiJZ9McsOgxqWX7AaxrDjcFVjWH/tIKJd7pnR7McaslGYOP1QmmiBXdJH/H/yLCT+rcQ7FaPBUxRGUtrg==}@@ -1129,6 +1177,15 @@ packages:resolution: {integrity: sha512-bIZEUzOI1jkhviX2cp5vNyXQc6olzb2ohewQubuYlMXZ2Q/XjBO0x0XhGPvc9fjSIiUN0vw+0hq53BJ4eQSJKQ==}engines: {node: ^20.19.0 || ^22.13.0 || >=24}+ '@exodus/[email protected]':+ resolution: {integrity: sha512-UY0nlA+feH81UGSHv92sLEPLCeZFjXOuHhrIo0HQydScuQc8s0A7kL/UdgwgDq8g8ilksmuoF35YVTNphV2aBQ==}+ engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}+ peerDependencies:+ '@noble/hashes': ^1.8.0 || ^2.0.0+ peerDependenciesMeta:+ '@noble/hashes':+ optional: true+'@floating-ui/[email protected]':resolution: {integrity: sha512-azI0DrjMMfIug/ExbBaeDVJXcY0a7EPvPjb2xAJPa4HeimBX+Z18HK8QQR3jb6356SnDDdxx+hinMLcJEDdOjw==}@@ -3325,6 +3382,10 @@ packages:engines: {node: '>=0.4.0'}hasBin: true+ resolution: {integrity: sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==}+ engines: {node: '>= 14'}+resolution: {integrity: sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==}peerDependencies:@@ -3479,6 +3540,9 @@ packages:resolution: {integrity: sha512-aVNobHnJqLiUelTaHat9DZ1qM2w0C0Eym4LPI/3JxOnSokGVdsl1T1kN7TFvsEAD8G47A6VKQ0TVHqbBnYMJlQ==}engines: {node: '>=12.0.0'}+ resolution: {integrity: sha512-RKshQI1R3YQ+n9YJz2QQ147P66ELpa1FQEg20Dk8oW9t2KgLbpDLLp9aGZ7y8WHSshDknG0bknqGw5/tyCs5tw==}+resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==}engines: {node: '>=8'}@@ -3684,6 +3748,10 @@ packages:resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==}engines: {node: '>= 8'}+ resolution: {integrity: sha512-X7sjQzceUhu1u7Y/ylrRZFU2FS6LRiFVp6rKLPg23y3x3c3DOKAwuXGDp+PAGjh6CSnCjYeAul8pcT8bAl+lSA==}+ engines: {node: ^10 || ^12.20.0 || ^14.13.0 || >=15.0.0}+resolution: {integrity: sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==}@@ -3692,6 +3760,10 @@ packages:engines: {node: '>=4'}hasBin: true+ resolution: {integrity: sha512-Fm5NvhYathRnXNVndkUsCCuR63DCLVVwGOOwQw782coXFi5HhkXdu289l59HlXZBawsyNccXfWRYvLzcDCdDig==}+ engines: {node: '>=20'}+resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==}@@ -3742,6 +3814,10 @@ packages:resolution: {integrity: sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==}+ resolution: {integrity: sha512-23XHcCF+coGYevirZceTVD7NdJOqVn+49IHyxgszm+JIiHLoB2TkmPtsYkNWT1pvRSGkc35L6NHs0yHkN2SumA==}+ engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}+resolution: {integrity: sha512-EmKO5V3OLXh1rtK2wgXRansaK1/mtVdTUEiEI0W8RkvgT05kfxaH29PliLnpLP73yYO6142Q72QNa8Wx/A5CqQ==}engines: {node: '>= 0.4'}@@ -3789,6 +3865,9 @@ packages:resolution: {integrity: sha512-qIMFpTMZmny+MMIitAB6D7iVPEorVw6YQRWkvarTkT4tBeSLLiHzcwj6q0MmYSFCiVpiqPJTJEYIrpcPzVEIvg==}+ resolution: {integrity: sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==}+resolution: {integrity: sha512-c6fcElNV6ShtZXmsgNgFFV5tVX2PaV4g+MOAkb8eXHvn6sryJBrZa9r0zV6+dtTyoCKxtDy5tyQ5ZwQuidtd+Q==}@@ -4587,12 +4666,24 @@ packages:resolution: {integrity: sha512-PDEfEF102G23vHmPhLyPboFCD+BkMGu+GuJe2d9/eH4FsCwvgBpnc9n0pGE+ffKdph38s6foEZiEjdgHdzp+IA==}+ resolution: {integrity: sha512-CV9TW3Y3f8/wT0BRFc1/KAVQ3TUHiXmaAb6VW9vtiMFf7SLoMd1PdAc4W3KFOFETBJUb90KatHqlsZMWV+R9Gg==}+ engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}+resolution: {integrity: sha512-ol6UPyBWqsrO6EJySPz2O7ZSr856WDrEzM5zMqp+FJJLGMW35cLYmmZnl0vztAZxRUoNZJFTCohfjuIJ8I4QBQ==}resolution: {integrity: sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==}+ resolution: {integrity: sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==}+ engines: {node: '>= 14'}++ resolution: {integrity: sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==}+ engines: {node: '>= 14'}+resolution: {integrity: sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==}engines: {node: '>=0.10.0'}@@ -4751,6 +4842,9 @@ packages:resolution: {integrity: sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==}engines: {node: '>=12'}+ resolution: {integrity: sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==}+resolution: {integrity: sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==}engines: {node: '>= 0.4'}@@ -4831,6 +4925,15 @@ packages:resolution: {integrity: sha512-Hicd6JK5Njt2QB6XYFS7ok9e37O8AYk3jTcppG4YVQnYjOemymvTcmc7OWsmq/Qqj5TdRFO5/x/tIPmBeRtGHg==}engines: {node: '>=12.0.0'}+ resolution: {integrity: sha512-0+MoQNYyr2rBHqO1xilltfDjV9G7ymYGlAUazgcDLQaUf8JDHbuGwsxN6U9qWaElZ4w1B2r7yEGIL3GdeW3Rug==}+ engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}+ peerDependencies:+ canvas: ^3.0.0+ peerDependenciesMeta:+ canvas:+ optional: true+resolution: {integrity: sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==}engines: {node: '>=6'}@@ -4998,6 +5101,10 @@ packages:resolution: {integrity: sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==}+ resolution: {integrity: sha512-ESL2CrkS/2wTPfuend7Zhkzo2u0daGJ/A2VucJOgQ/C48S/zB8MMeMHSGKYpXhIjbPxfuezITkaBH1wqv00DDQ==}+ engines: {node: 20 || >=22}+resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==}@@ -5098,6 +5205,9 @@ packages:resolution: {integrity: sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==}+ resolution: {integrity: sha512-9Yubnt3e8A0OKwxYSXyhLymGW4sCufcLG6VdiDdUGVkPhpqLxlvP5vl1983gQjJl3tqbrM731mjaZaP68AgosQ==}+resolution: {integrity: sha512-/EuHYwAPdLtXwAwSZkh/Gutery6pD2KYd44oQLhAvQp/50mpyduZh8Q7PYHXTCJ+wuXxt7oij2LXyIJOOYFPog==}@@ -5442,6 +5552,9 @@ packages:resolution: {integrity: sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==}+ resolution: {integrity: sha512-9m4m5GSgXjL4AjumKzq1Fgfp3Z8rsvjRNbnkVwfu2ImRqE5D0LnY2QfDen18FSY9C573YU5XxSapdHZTZ2WolA==}+resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==}engines: {node: '>=8'}@@ -5918,6 +6031,10 @@ packages:engines: {node: '>=14.0.0'}hasBin: true+ resolution: {integrity: sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==}+ engines: {node: '>=v12.22.7'}+resolution: {integrity: sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==}@@ -6140,6 +6257,9 @@ packages:resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==}engines: {node: '>= 0.4'}+ resolution: {integrity: sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==}+resolution: {integrity: sha512-Bh7QjT8/SuKUIfObSXNHNSK6WHo6J1tHCqJsuaFDP7gP0fkzSfTxI8y85JrppZ0h8l0maIgc2tfuZQ6/t3GtnQ==}engines: {node: ^14.18.0 || >=16.0.0}@@ -6213,10 +6333,25 @@ packages:resolution: {integrity: sha512-n1cw8k1k0x4pgA2+9XrOkFydTerNcJ1zWCO5Nn9scWHTD+5tp8dghT2x1uduQePZTZgd3Tupf+x9BxJjeJi77Q==}engines: {node: '>=14.0.0'}+ resolution: {integrity: sha512-ZjCZK0rppSBu7rjHYDYsEaMOIbbT+nWF57hKkv4IUmZWBNrBWBOjIElc0mKRgLM8bm7x/BBlof6t2gi/Oq/Asw==}++ resolution: {integrity: sha512-keinCnPbwXEUG3ilrWQZU+CqcTTzHq9m2HhoUP2l7Xmi8l1LuijAXLpAJ5zRW+ifKTNscs4NdCkfkDCBYm352w==}+ hasBin: true+resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}engines: {node: '>=8.0'}+ resolution: {integrity: sha512-kXuRi1mtaKMrsLUxz3sQYvVl37B0Ns6MzfrtV5DvJceE9bPyspOqk9xxv7XbZWcfLWbFmm997vl83qUWVJA64w==}+ engines: {node: '>=16'}++ resolution: {integrity: sha512-bLVMLPtstlZ4iMQHpFHTR7GAGj2jxi8Dg0s2h2MafAE4uSWF98FC/3MomU51iQAMf8/qDUbKWf5GxuvvVcXEhw==}+ engines: {node: '>=20'}+resolution: {integrity: sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==}hasBin: true@@ -6300,6 +6435,10 @@ packages:resolution: {integrity: sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==}+ resolution: {integrity: sha512-RqslV2Us5BrllB+JeiZnK4peryVTndy9Dnqq62S3yYRRTj0tFQCwEniUy2167skdGOy3vqRzEvl1Dm4sV2ReDg==}+ engines: {node: '>=20.18.1'}+resolution: {integrity: sha512-yLSH4py7oFH3oG/9K+XWrz1pSi3dfUrWEnInbxMfArOfc1+33BlGPQtLsOYwvdMy11AwUBetYuaRxSPqgkq+8g==}engines: {node: '>=4'}@@ -6506,6 +6645,10 @@ packages:jsdom:optional: true+ resolution: {integrity: sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==}+ engines: {node: '>=18'}+resolution: {integrity: sha512-c5EGNOiyxxV5qmTtAB7rbiXxi1ooX1pQKMLX/MIabJjRA0SJBQOjKF+KSVfHkr9U1cADPon0mRiVe/riyaiDUA==}engines: {node: '>=10.13.0'}@@ -6516,6 +6659,10 @@ packages:resolution: {integrity: sha512-ArI3kx5jI0atlTtmV0fWU3fjpLmq/nD3Zr1iFFlJLaqa5wLBkUSzINwBPySCX/8jRyjlmy1Volw1kz1g9XE4Jg==}+ resolution: {integrity: sha512-BMhLD/Sw+GbJC21C/UgyaZX41nPt8bUTg+jWyDeg7e7YN4xOM05YPSIXceACnXVtqyEw/LMClUQMtMZ+PGGpqQ==}+ engines: {node: '>=20'}+resolution: {integrity: sha512-ykKKus8lqlgXX/1WjudpIEjqsafjOTcOJqxnAbMLAu/KCsDCJ6GBtvscewvTkrn24HsnvFwrSCbenFrhtcCsAA==}engines: {node: '>=10.13.0'}@@ -6533,6 +6680,14 @@ packages:webpack-cli:optional: true+ resolution: {integrity: sha512-sXcNcHOC51uPGF0P/D4NVtrkjSU2fNsm9iog4ZvZJsL3rjoDAzXZhkm2MWt1y+PUdggKAYVoMAIYcs78wJ51Cw==}+ engines: {node: '>=20'}++ resolution: {integrity: sha512-1to4zXBxmXHV3IiSSEInrreIlu02vUOvrhxJJH5vcxYTBDAx51cqZiKdyTxlecdKNSjj8EcxGBxNf6Vg+945gw==}+ engines: {node: ^20.19.0 || ^22.12.0 || >=24.0.0}+resolution: {integrity: sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA==}engines: {node: '>= 0.4'}@@ -6583,6 +6738,13 @@ packages:utf-8-validate:optional: true+ resolution: {integrity: sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==}+ engines: {node: '>=18'}++ resolution: {integrity: sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==}+resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==}engines: {node: '>=0.4'}@@ -6643,6 +6805,9 @@ packages:snapshots:+ '@acemir/[email protected]':+ optional: true+'@adobe/[email protected]': {}'@ag-ui/[email protected]':@@ -6657,6 +6822,27 @@ snapshots:'@jridgewell/gen-mapping': 0.3.8'@jridgewell/trace-mapping': 0.3.25+ '@asamuzakjp/[email protected]':+ dependencies:+ '@csstools/css-calc': 3.1.1(@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])+ '@csstools/css-color-parser': 4.0.2(@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])+ '@csstools/css-parser-algorithms': 4.0.0(@csstools/[email protected])+ '@csstools/css-tokenizer': 4.0.0+ lru-cache: 11.2.6+ optional: true++ '@asamuzakjp/[email protected]':+ dependencies:+ '@asamuzakjp/nwsapi': 2.3.9+ bidi-js: 1.0.3+ css-tree: 3.2.1+ is-potential-custom-element-name: 1.0.1+ lru-cache: 11.2.6+ optional: true++ '@asamuzakjp/[email protected]':+ optional: true+'@babel/[email protected]':dependencies:'@babel/helper-validator-identifier': 7.27.1@@ -6853,6 +7039,11 @@ snapshots:'@babel/helper-string-parser': 7.27.1'@babel/helper-validator-identifier': 7.28.5+ '@bramus/[email protected]':+ dependencies:+ css-tree: 3.2.1+ optional: true+dependencies:chromatic: 11.29.0@@ -6866,6 +7057,34 @@ snapshots:- '@chromatic-com/playwright'- react+ '@csstools/[email protected]':+ optional: true++ '@csstools/[email protected](@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])':+ dependencies:+ '@csstools/css-parser-algorithms': 4.0.0(@csstools/[email protected])+ '@csstools/css-tokenizer': 4.0.0+ optional: true++ '@csstools/[email protected](@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])':+ dependencies:+ '@csstools/color-helpers': 6.0.2+ '@csstools/css-calc': 3.1.1(@csstools/[email protected](@csstools/[email protected]))(@csstools/[email protected])+ '@csstools/css-parser-algorithms': 4.0.0(@csstools/[email protected])+ '@csstools/css-tokenizer': 4.0.0+ optional: true++ '@csstools/[email protected](@csstools/[email protected])':+ dependencies:+ '@csstools/css-tokenizer': 4.0.0+ optional: true++ '@csstools/[email protected]':+ optional: true++ '@csstools/[email protected]':+ optional: true+'@date-fns/[email protected]': {}'@emnapi/[email protected]':@@ -7189,6 +7408,9 @@ snapshots:'@eslint/core': 1.1.0levn: 0.4.1+ '@exodus/[email protected]':+ optional: true+'@floating-ui/[email protected]':dependencies:'@floating-ui/utils': 0.2.9@@ -9467,6 +9689,9 @@ snapshots:+ optional: true+optionalDependencies:ajv: 8.17.1@@ -9636,6 +9861,11 @@ snapshots:dependencies:open: 8.4.2+ dependencies:+ require-from-string: 2.0.2+ optional: true+@@ -9819,10 +10049,24 @@ snapshots:shebang-command: 2.0.0which: 2.0.2+ dependencies:+ mdn-data: 2.27.1+ source-map-js: 1.2.1+ optional: true++ dependencies:+ '@asamuzakjp/css-color': 5.0.1+ '@csstools/css-syntax-patches-for-csstree': 1.1.0+ css-tree: 3.2.1+ lru-cache: 11.2.6+ optional: true+@@ -9865,6 +10109,14 @@ snapshots:+ dependencies:+ whatwg-mimetype: 5.0.0+ whatwg-url: 16.0.1+ transitivePeerDependencies:+ - '@noble/hashes'+ optional: true+dependencies:call-bound: 1.0.4@@ -9901,6 +10153,9 @@ snapshots:+ optional: true+dependencies:character-entities: 2.0.2@@ -11158,10 +11413,33 @@ snapshots:+ dependencies:+ '@exodus/bytes': 1.15.0+ transitivePeerDependencies:+ - '@noble/hashes'+ optional: true++ dependencies:+ agent-base: 7.1.4+ debug: 4.4.3+ transitivePeerDependencies:+ - supports-color+ optional: true++ dependencies:+ agent-base: 7.1.4+ debug: 4.4.3+ transitivePeerDependencies:+ - supports-color+ optional: true+dependencies:safer-buffer: 2.1.2@@ -11304,6 +11582,9 @@ snapshots:+ optional: true+dependencies:call-bound: 1.0.4@@ -11388,6 +11669,34 @@ snapshots:+ dependencies:+ '@acemir/cssom': 0.9.31+ '@asamuzakjp/dom-selector': 6.8.1+ '@bramus/specificity': 2.4.2+ '@exodus/bytes': 1.15.0+ cssstyle: 6.2.0+ data-urls: 7.0.0+ decimal.js: 10.6.0+ html-encoding-sniffer: 6.0.0+ http-proxy-agent: 7.0.2+ https-proxy-agent: 7.0.6+ is-potential-custom-element-name: 1.0.1+ parse5: 8.0.0+ saxes: 6.0.0+ symbol-tree: 3.2.4+ tough-cookie: 6.0.0+ undici: 7.22.0+ w3c-xmlserializer: 5.0.0+ webidl-conversions: 8.0.1+ whatwg-mimetype: 5.0.0+ whatwg-url: 16.0.1+ xml-name-validator: 5.0.0+ transitivePeerDependencies:+ - '@noble/hashes'+ - supports-color+ optional: true+@@ -11520,6 +11829,9 @@ snapshots:+ optional: true+dependencies:yallist: 3.1.1@@ -11738,6 +12050,9 @@ snapshots:dependencies:'@types/mdast': 4.0.4+ optional: true+dependencies:map-or-similar: 1.5.0@@ -12282,6 +12597,11 @@ snapshots:dependencies:entities: 6.0.1+ dependencies:+ entities: 6.0.1+ optional: true+@@ -12892,6 +13212,11 @@ snapshots:optionalDependencies:'@parcel/watcher': 2.5.1+ dependencies:+ xmlchars: 2.2.0+ optional: true+@@ -13189,6 +13514,9 @@ snapshots:+ optional: true+dependencies:'@pkgr/core': 0.2.9@@ -13269,10 +13597,28 @@ snapshots:+ optional: true++ dependencies:+ tldts-core: 7.0.25+ optional: true+dependencies:is-number: 7.0.0+ dependencies:+ tldts: 7.0.25+ optional: true++ dependencies:+ punycode: 2.3.1+ optional: true+@@ -13383,6 +13729,9 @@ snapshots:+ optional: true+@@ -13572,7 +13921,7 @@ snapshots:tsx: 4.20.3yaml: 2.8.0- [email protected](@opentelemetry/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected]):+ [email protected](@opentelemetry/[email protected])(@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected]):dependencies:'@vitest/expect': 4.0.18'@vitest/mocker': 4.0.18([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))@@ -13597,6 +13946,7 @@ snapshots:optionalDependencies:'@opentelemetry/api': 1.9.0'@types/node': 25.3.2+ jsdom: 28.1.0transitivePeerDependencies:- jiti- less@@ -13610,6 +13960,11 @@ snapshots:- tsx- yaml+ dependencies:+ xml-name-validator: 5.0.0+ optional: true+dependencies:glob-to-regexp: 0.4.1@@ -13619,6 +13974,9 @@ snapshots:+ optional: true+@@ -13654,6 +14012,18 @@ snapshots:- esbuild- uglify-js+ optional: true++ dependencies:+ '@exodus/bytes': 1.15.0+ tr46: 6.0.0+ webidl-conversions: 8.0.1+ transitivePeerDependencies:+ - '@noble/hashes'+ optional: true+dependencies:is-bigint: 1.1.0@@ -13720,6 +14090,12 @@ snapshots:+ optional: true++ optional: true+