API

The entry points of every package, and the options of each function.

Packages and entry points

Import fromWhat it holds
@open-intelligent-ui/coreparse, Surface, defineLibrary, defineComponent, defineWidget, view, librarySpec, validateLibrary, parseDesign, designFromCss, colorSources. No framework
@open-intelligent-ui/core/promptbuildSystemPrompt, describeComponent, the guides and the UI SDK catalog. Import it on the server
@open-intelligent-ui/core/checkcheckMarkup, repairMessage. No DOM
@open-intelligent-ui/core/designspaper, noir, heritage, signal as DESIGN.md text
@open-intelligent-ui/core/chartsechartsCharts, g2Charts; types ChartEngine, ChartSpec, ChartContext, ChartHandle
@open-intelligent-ui/core/motionmotionAdapter, gsapAdapter, waapiAdapter, createMotionAdapter, cssKeyframes, cubicBezier; types MotionAdapter, MotionPreset, MotionTiming
@open-intelligent-ui/reactIntelligentUI, preloadUiSdk, and the define* functions again. /recharts has rechartsCharts; /styles.css is the stylesheet
@open-intelligent-ui/vue, /svelte, /solidThe same for each framework, with /styles.css
@open-intelligent-ui/webmount, and /define to register <intelligent-ui>; /styles.css, and /elements.css for a page that already loads another renderer's stylesheet
open-intelligent-uiThe unscoped name. Re-exports @open-intelligent-ui/core with /prompt, /check, /designs, /charts and /motion

<IntelligentUI>

The same props in every renderer. In Vue the callbacks are props that take a function (:on-action="fn"). On the <intelligent-ui> element, text options are attributes and properties, the rest are properties, and each callback is also an event.

PropType
sourcestringThe markup. May be incomplete while streaming
streamingbooleanTrue while source is still arriving
designstring | DesignA DESIGN.md, or one read with parseDesign. Default: Paper
scheme"light" | "dark" | "auto"Which colors to use. Default auto
libraryLibraryWhat the product adds, made with defineLibrary
componentsRecord<string, Component>Components by name, without descriptions or checks. Prefer library
toolsRecord<string, Tool>Functions the surface reads with <query> and writes with call()
callTool(name, input) => unknownCalled for tools not found in tools
onAction(action) => boolean | undefinedsend, open, copy, toast. Return true to replace the default
onTool(event) => voidEach tool call: start, then done or error
onWarning(message) => voidProblems found while drawing
onDiagnostics(diagnostics) => voidParse problems for the current source, with codes and positions
onStateChange(state) => voidThe surface's state after each change
initialStateRecord<string, unknown>State to start with, over the declared values
functionsRecord<string, Function>Extra pure functions for expressions
actionsRecord<string, Function>Extra actions for handlers
locale, currencystringFor number, date and currency formatting
storage, storageKeyStorageLike, stringWhere <state persist> values are kept
allowUrl(url, kind) => booleanReturn false to refuse a link or media address

The handle (ref in React and Solid, a template ref in Vue, bind:this in Svelte, the element itself on the web):

Method
getState()The surface's state, as plain data
setState(values)Writes state, as if the reader had changed it
reset(...names)Puts state back to its declared values
refetch(...ids)Reloads the named queries, or all of them

buildSystemPrompt

import { buildSystemPrompt } from "@open-intelligent-ui/core/prompt"

const system = buildSystemPrompt(options)
Option
libraryA Library, or the JSON written by librarySpec. Its components, chart types, motion presets, design and instructions are described
designA DESIGN.md or a parsed design, when there is no library. Default: Paper
tools[{ name, kind: "read" | "write", description, input?, output? }]
componentsWhich UI SDK components get an example: "core" (the default), "all", or a list such as ["tabs", "dialog"]. The others are listed by name
motionfalse leaves the motion section out. Text replaces it
instructionsProduct-specific instructions, added at the end

The default prompt is about 34,000 characters. To shorten it, list fewer components, set motion: false, and offer describeComponent(name, { props: true }) as a tool the model calls when it needs a component in full.

checkMarkup and repairMessage

import { checkMarkup, repairMessage } from "@open-intelligent-ui/core/check"

const result = checkMarkup(source, options)
const message = repairMessage(result, { limit: 12 })
Option
libraryA Library or its librarySpec JSON
toolsThe tools the host answers: names, or the descriptions given to buildSystemPrompt
components, state, functions, actionsWhat the host passes to the renderer as components, initialState, functions and actions, or just the names

result is { ok, errors, warnings, issues }. An issue is { code, severity, message, hint?, line, column, excerpt }. Correct output lists the codes.

repairMessage returns an empty string when there is nothing to send: no errors, unless warnings: true is set and there are warnings. limit caps how many issues are listed (12 by default).

Library

import { defineComponent, defineLibrary, defineWidget, librarySpec, validateLibrary, view } from "@open-intelligent-ui/core"
Function
defineLibrary({ name, design, components, charts, motion, instructions })What a product adds, for the renderer, the prompt and the checker
defineComponent({ name, description, props, events, children, example, component })A framework component with declared props. Your components
defineWidget({ name, description, props, events, example, setup })A component drawn with view(), for every renderer. Widgets
validateLibrary(library)What is wrong with the library, as sentences. Empty when nothing is
librarySpec(library)The library as JSON, for a server

Design

import { colorSources, designFromCss, parseDesign } from "@open-intelligent-ui/core"
Function
parseDesign(source, { tokens, roles, prose })Reads a DESIGN.md. The options fill in what it leaves open. design.issues lists what couldn't be read
designFromCss(css, { name, prose })Reads a theme stylesheet's variables as a design
colorSources(design)Which token each color role was taken from

Lower level

parse(source) returns the document tree with diagnostics. Surface is the state store and action runner a renderer drives. @open-intelligent-ui/core/renderer holds what the five renderers share (directives, primitives, presets, charts), for someone writing a renderer for another framework. These are stable enough to build on within a minor version, and less documented than the rest.