@hitl-kit/react
v0.4.2
Published
HitlEventRenderer, a typed dispatcher that maps validated HITL events to React primitives. Pair with @hitl-kit/core and any shadcn-installed HITL primitives.
Maintainers
Readme
@hitl-kit/react
<HitlEventRenderer />— type-safe dispatcher that maps validated HITL events to React primitives.
Pair with @hitl-kit/core for the event schemas and
any HITL Kit primitives installed via npx shadcn@latest add.
pnpm add @hitl-kit/core @hitl-kit/reactUsage
Install the primitive(s) your agent emits. They land under
components/hitl/:npx shadcn@latest add https://www.hitlkit.dev/r/hitl-card.json npx shadcn@latest add https://www.hitlkit.dev/r/subagent-status-card.jsonBuild a registry that maps event kinds to your primitive components:
import { createRegistry, HitlEventRenderer } from "@hitl-kit/react"; import { HitlCard } from "@/components/hitl/HitlCard"; import { SubagentStatusCard } from "@/components/hitl/SubagentStatusCard"; const registry = createRegistry({ "hitl.card": (event) => ( <HitlCard config={{ id: event.id ?? "default", kind: event.variant, title: event.title, subtitle: event.subtitle, steps: event.steps, runLabel: event.runLabel, editPlaceholder: event.editPlaceholder, openTab: "human", }} /> ), "subagent.status": (event) => ( <SubagentStatusCard status={event.status} label={event.label} detail={event.detail} /> ), });Render any streamed HITL event:
<HitlEventRenderer event={someEvent} registry={registry} onAction={(action) => { // called by the primitive when the human acts }} fallback={<p>Unknown event.</p>} />
What the renderer does
- Runtime-validates
eventvia the shared Zod schema from@hitl-kit/core - Narrows the type to the correct event variant
- Looks up the right component in the registry by
event.kind - Spreads the event onto the component, plus the optional
onActioncallback
API
HitlEventRenderer— the dispatcher.validatedefaults totrue.createRegistry— identity helper for strongly typed registry definitions.HitlRegistry,HitlEventOfKind<K>— type utilities.
Part of HITL Kit
- Schemas → @hitl-kit/core
- Components → install via shadcn CLI from hitlkit.dev/registry
- Adapters →
@hitl-kit/langgraph,@hitl-kit/ai-sdk,@hitl-kit/mcp - 15 primitive event kinds since v0.6a — full list in
@hitl-kit/core - Repo → github.com/akaieuan/HITL-KIT
License
MIT License
Copyright (c) 2023-2026 Ubik, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
