npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@czap/genui

v0.10.0

Published

Render AI-generated UI safely in LiteShip: validate a model's proposed component tree against a host-owned catalog and draw only trusted, whitelisted components.

Readme

@czap/genui

Host-owned generated UI: validate the structured UI trees a model proposes against a catalog you control, then render trusted components only — never model HTML.

You usually don't install this directly — it's host-wired through @czap/astro, @czap/web, and @czap/mcp-server, which own the catalog and interaction authority for you. Install one of those unless you need the validator standalone.

Install

pnpm add @czap/genui

30 seconds

import {
  DEMO_COMPONENT_CATALOG,
  tryParseGeneratedUIChunk,
  validateGeneratedUITree,
  renderHash,
} from '@czap/genui';

// A model emits one structured chunk: { "_genui": true, "name": ..., "props": ... }
const node = tryParseGeneratedUIChunk(
  '{"_genui":true,"name":"Card","props":{"title":"Hello"},"children":[{"name":"Text","props":{"text":"From the model"}}]}',
);

if (node) {
  const result = validateGeneratedUITree(node, DEMO_COMPONENT_CATALOG);
  if (result.ok) {
    console.log(renderHash(node, DEMO_COMPONENT_CATALOG)); // stable content address
  } else {
    console.error(result.error.code, result.error.path); // e.g. 'genui/unknown-component'
  }
}

tryParseGeneratedUIChunk returns null for ordinary token/text/HTML output, so this is safe to run over every streamed chunk. validateGeneratedUITree rejects unknown component names, bad props, and malformed children/slots before anything reaches the DOM. In the browser, renderFromCatalog(node, { catalog, target }) validates then builds elements from your trusted catalog, wiring interaction props to genui:interaction CustomEvents the host interprets — model strings are opaque action ids, never markup.

Where it sits

Define a catalog with defineComponentCatalog — the only components that can ever render. Its only @czap dependencies are @czap/_spine (the shared genui type vocabulary), @czap/canonical (catalog/render bytes), and @czap/error. The model proposes a tree; this package validates it against the catalog and renders allowlisted attributes only. catalogHash and renderHash mint stable content addresses for cache, replay, and tests. What to generate is decided elsewhere — @czap/mcp-server projects the catalog to a model, hosts own admission and interaction authority.

Trust boundary

This package never renders model HTML and never trusts model-controlled keys — component and prop names are looked up as own-properties only, so constructor/__proto__-style names are unknown components, full stop. A tree that fails validation is not rendered. The catalog, and what each interaction does, are always the host's.

Docs


Part of LiteShip — powered by the CZAP engine (Content-Zoned Adaptive Projection), distributed as @czap/* packages.