@lynx-js/genui
Generative UI primitives for Lynx applications.
@lynx-js/genui is the single npm package for the GenUI toolchain. It exposes
A2UI rendering, OpenUI rendering, A2UI prompt/catalog utilities, Lynx XML utilities, ReactLynx generation/build utilities, and the CLI
from one package while keeping implementation directories private to this
monorepo.
Installation
@lynx-js/react is a peer dependency. Some built-in A2UI components and the
default OpenUI Library also use @lynx-js/lynx-ui; install it when your app
uses those surfaces.
Entry Points
The root entry point exports the stable APIs most applications and tools need:
- A2UI ReactLynx renderer and data-store helpers.
- OpenUI parser, library, and renderer APIs.
- A2UI prompt builders.
- A2UI catalog extraction utilities.
- ReactLynx generation prompts, source validation, and Node.js compilation.
Focused subpaths are also available:
@lynx-js/genui/lynx-xml provides system prompts,
deterministic artifact assembly, and normalizeLynxXmlArtifact for document
normalization and validation. It is headless and does not require an agent or
renderer.
Catalog manifests are exported through a single public catalog entry:
A2UI
A2UI renders agent-generated UI messages that follow the A2UI v0.9 protocol.
Create a message store, push protocol messages into it from your transport, and
render the latest surface with <A2UI>.
Use the A2UI style entry when you want the packaged component styles:
See a2ui/README.md for catalog composition and custom
component details.
OpenUI
OpenUI renders OpenUI Lang v0.5 responses through a configurable component library.
For streamed model output, pass the full accumulated text and generation state:
Append each delta to your application state; replace it when receiving a full
snapshot. The renderer caches completed statements and previews the unfinished
tail. Keep isStreaming true until successful completion, then apply the final
text and set it false together, even if the text is unchanged. On failure or
cancellation, clear the partial response. See the
streaming guide for transport handlers
and session lifecycle.
Import the optional OpenUI theme tokens once in your app:
The renderer and component styles are imported by their modules.
To opt out of the default component set, use the explicit entry and import every built-in definition the Library still needs from its component subpath:
The flag controls which definitions and groups belong to the Library. The main
openui entry still has a static dependency on the default catalog; use
openui/explicit with individual catalog subpaths when omitted built-ins must
stay outside the static dependency graph.
See openui/README.md for streaming and custom library
examples.
ReactLynx
Generate complete App.tsx and App.css files with REACTLYNX_SYSTEM_PROMPT,
validate the response with parseReactLynxSource, and compile it on Node.js with
buildReactLynx. Publish all returned assets before loading the Web or Native
bundle in your host. Keep @lynx-js/genui/reactlynx external in server bundles
so its compiler worker remains beside its entry point.
See the ReactLynx guide.
CLI
The package installs the GenUI CLI and the low-level catalog extractor binary:
a2ui-cli is also kept as a compatibility alias for existing A2UI scripts. New
scripts should prefer the namespace-first genui a2ui ... or
genui openui ... form.
Generate catalog artifacts:
Generate an A2UI system prompt:
Generate an OpenUI system prompt:
Published Package Layout
Only @lynx-js/genui is intended to be published. The package contains compiled
JavaScript and declarations under dist/ directories, plus CLI entry points,
README files, styles, and extractor skills.
The root index.ts is compiled during build. Do not hand-write
dist/index.js or dist/index.d.ts; run:
Before publishing, verify the package contents:
License
Apache-2.0
The opt-in OpenUI Chat library uses the official Chat positional contracts and provides a server-safe schema entry.