@arnilo/liveframe
v0.4.1
Published
Runtime-composable UI: primitives, design-system recipes and TSX widgets that change an app's UI without a deployment.
Maintainers
Readme
Liveframe
Runtime-composable UI for apps: people and AI agents install TSX widgets at runtime and the app's UI changes, with no deployment.
An app ships a small set of trusted primitive components and a design system. Widgets are ordinary TSX written against those primitives. Widget code runs on the app's backend; the browser only draws a validated tree with the app's own components, so the UI looks native and no widget code runs in the page.
Four rules, none of them optional:
- Widget code never runs in the browser. Only the app's compiled primitives run there.
- The UI tree is data, and it is validated before the renderer reads it.
- Widget code never sets colours or raw CSS. Look comes from the design system; layout comes from token-constrained style props.
- A widget never holds authority. Data is resolved and actions are run by the app, as the viewer.
Getting started · Specification · How a surface is built · Security model · Compatibility · Changelog
Install
bun add @arnilo/liveframeThe workspace has four packages. The three optional companions share the core version and peer on @arnilo/liveframe. The A2UI converter joined the workspace in 0.4.0.
bun add @arnilo/liveframe-runner-quickjs # an isolated runner for widget code you do not trust
bun add @arnilo/liveframe-starter # a conforming catalog, primitives, themes and styles to start from
bun add @arnilo/liveframe-a2ui # convert an A2UI v0.9/v0.9.1 surface to element JSONThe A2UI converter's guide has the mapping and what it refuses.
Each peer is optional and only the subpaths that need it use it:
| Peer | Range | Needed by |
|---|---|---|
| react, react-dom | ^19.0.0 | /react, /preview/react, /conformance/react |
| playwright | ^1.49.0 | liveframe preview capture, the MCP server's capture_preview |
| @modelcontextprotocol/server | ^2.0.0 | liveframe mcp |
The backend subpaths (/store/fs, /preview/worker, the in-process package loader and the CLI) need Bun ≥ 1.4.2. The host-API-free subpaths need ES2022 plus only the globals listed below. The browser subpaths (/css, /react, /dom, /preview/react, /conformance/react, /conformance/dom) need any ESM bundler. The package ships compiled ES2022 JavaScript with .d.ts declarations and the published JSON Schemas; spec §13 has the runtime matrix and package contents.
| Host-API-free subpath | Non-ECMAScript globals |
|---|---|
| . | none |
| sdk | none |
| css | none |
| authoring | TextEncoder, TextDecoder, URL, console |
| runner-kit | none |
| template | none |
| surface | none |
| host | console |
| preview/capture | TextEncoder, TextDecoder, URL |
| conformance | setTimeout, clearTimeout, TextDecoder, console |
| pack | TextDecoder, console |
| store | console |
| preview | setTimeout, clearTimeout, TextDecoder, console |
Paths are relative to @arnilo/liveframe; . is the root export. The sdk row includes /sdk/gen and both JSX runtimes; /runner-kit.bundle.js and /validator.bundle.js also need no non-ECMAScript globals. Entries include bundled dependencies: Acorn guards its unused console warning, and the packer's source-map codec optionally uses TextDecoder with a pure JavaScript fallback. Preview timers bound module loading, and the runner conformance cases reach them through the reference renderers; capture needs the Encoding and URL APIs. Authoring reaches capture. Source, compiled output and browser bundles are checked against this table in CI.
Quickstart
A catalog, its React implementations and a validator are all a surface needs. compileValidator takes the validated catalog, capabilities and manifest for one widget; createRenderer returns the <Surface> that draws a tree it has validated.
import { type Catalog, compileValidator, defineComponent, obj, str, type UiTree } from "@arnilo/liveframe";
import { createRenderer, implement } from "@arnilo/liveframe/react";
const text = defineComponent({
kind: "text",
description: "One line of text.",
props: obj({ value: str({ maxLength: 200 }) }),
children: "none",
variants: ["default"],
defaultVariant: "default",
slots: ["root"],
events: {},
styleProps: [],
a11y: { role: "paragraph" },
});
const catalog = {
format: "liveframe-catalog/1",
catalogId: "acme.ui@1",
description: "The app's primitives.",
vocabulary: {
colourRoles: ["text.primary", "surface.base", "accent.primary"],
surfaceRoles: ["surface.base"],
fillableRoles: ["accent.primary"],
typographyRoles: ["body"],
space: ["space.1"],
radius: ["radius.control"],
size: ["size.glyph"],
breakpoints: ["bp.sm"],
tones: { default: "text.primary" },
surfaceTypography: "body",
},
definitions: [text],
} as const satisfies Catalog;
const capabilities = { format: "liveframe-capabilities/1", sources: {}, actions: {} };
const manifest = {
format: "liveframe-manifest/1",
id: "hello",
version: "1.0.0",
catalogId: catalog.catalogId,
params: obj({}),
state: obj({}),
context: obj({}),
initialState: {},
sources: {},
actions: [],
};
const Text = implement(text, ({ props, slot, style }) => (
<p className={slot("root")} style={style}>
{props.value}
</p>
));
const { Surface } = createRenderer({ catalog, implementations: [Text] });
const validator = compileValidator({ catalog, capabilities, manifest });
const identity = { id: "acme", version: "1.0.0" };
/** Draw a validated tree that the app's backend rendered. */
export function Hello({
tree,
onIntent,
}: {
tree: unknown;
onIntent: (intent: { type: "setState" | "action" }) => void;
}) {
return (
<Surface
tree={tree}
validator={validator}
theme={identity}
designSystem={identity}
onIntent={onIntent}
fallback={null}
/>
);
}
export const tree: UiTree = {
format: "liveframe/1",
catalogId: catalog.catalogId,
surfaceId: "hello",
revision: 1,
root: { id: "root", kind: "text", props: { value: "Hello from Liveframe" } },
};Widgets are authored separately with the SDK, which exports render() and the JSX runtime and emits the tree Hello receives. The preview guide shows the backend runners that execute widget code, and the package guide shows how a rendered widget becomes an immutable package a host stores and places.
For streaming updates, diffTrees(prev, next) emits an optional liveframe/tree-patch/1 patch on the backend, and the browser host applies it with applyPatch(base, patch) and passes the patched tree to <Surface> (which validates the whole tree on arrival):
import { applyPatch, diffTrees } from "@arnilo/liveframe";
const next = {
...tree,
revision: 2,
root: { id: "root", kind: "text", props: { value: "Hello again" } },
};
const patch = diffTrees(tree, next);
if (patch.ok) {
const updated = applyPatch(tree, patch.value);
if (updated.ok) Hello({ tree: updated.value, onIntent: () => {} });
}What is in the package
| Import | Holds |
|---|---|
| @arnilo/liveframe | Definition, catalog, theme, design-system, UI-tree and tree-patch formats; validateTreePatch, diffTrees and applyPatch; the validator; the recipe resolver; LiveframeFailure and LiveframeError |
| @arnilo/liveframe/sdk | The JSX runtime (/sdk/jsx-runtime, /sdk/jsx-dev-runtime), intent helpers and render() |
| @arnilo/liveframe/sdk/gen | The host-side emitters behind liveframe gen: generate(), generateDefinitions(), generateElementsSchema(), generateTemplateSchema() and generateDigest() (the agent digest, liveframe gen --digest) |
| @arnilo/liveframe/react | The renderer: createRenderer(), <Surface> and implement() |
| @arnilo/liveframe/surface | The framework-independent surface core under /react: createSurfaceCore(), node contexts and local state |
| @arnilo/liveframe/css | The scoped CSS projection and the class, style, scope and variable helpers; the host inserts sheets |
| @arnilo/liveframe/pack | Package and scenario formats, structural validators, pack(), verifyPackage(), checkPackages(), canonicalJson() and packageHash() |
| @arnilo/liveframe/store | Record formats, the Store interface, memoryStore() and loadPlacement() |
| @arnilo/liveframe/host | renderPlacement(), handleIntent() and dependents(): the ordered, stateless request-time render and intent pipeline, and which placements a change touches |
| @arnilo/liveframe/store/fs | fileStore(dir), which reads and writes the file system |
| @arnilo/liveframe/preview | The Runner interface, inProcessRunner(), templateRunner() and createPreview() |
| @arnilo/liveframe/authoring | Nine typed authoring operations without MCP; the host supplies its runner |
| @arnilo/liveframe/runner-kit | renderModule() and linkPackage(), the in-sandbox half of a runner |
| @arnilo/liveframe/template | validateTemplate(), renderTemplate() and the expression language of template widgets |
| @arnilo/liveframe/runner-kit.bundle.js | The kit, SDK and validator as one import-free ES module for isolates |
| @arnilo/liveframe/validator.bundle.js | The root exports as one import-free ES module for hosts that validate without rendering |
| @arnilo/liveframe/preview/capture | Capture as bytes with a pluggable backend |
| @arnilo/liveframe/dom | The plain DOM adapter: createDomRenderer(), implement() and place(), with no framework |
| @arnilo/liveframe/preview/worker | workerRunner(), which needs the Worker global |
| @arnilo/liveframe/preview/react | <Preview> |
| @arnilo/liveframe/conformance | Host-API-free catalog, design-system and store suites |
| @arnilo/liveframe/conformance/react | The renderer suites and conformancePage() |
| @arnilo/liveframe/conformance/dom | The same renderer cases against /dom implementations, and domConformancePage() |
| @arnilo/liveframe/schemas/<format>.json | The JSON Schema for every format |
The spec defines each subpath's contract.
Use it with a coding agent
liveframe mcp is an MCP server over stdio that lets a coding agent read your catalog, write a draft widget and look at its renders. It is authoring only: no tool installs, places or approves a widget, or runs an action.
- Install the optional peers:
bun add -d @modelcontextprotocol/server, andbunx playwright install chromiumif the agent should capture screenshots. - Write a config module that default-exports an
AuthoringConfig(yourcatalog,capabilities,runnerand, for captures, apreview(binding)that starts your<Preview>page).examples/demo-host/mcp.config.tsis a working one. - Register it with the agent. For Claude Code, put this in
.mcp.jsonin your app; Claude Desktop and other clients use the samemcpServersshape in their own config file:
{ "mcpServers": { "liveframe": { "command": "bunx", "args": ["liveframe", "mcp", "./mcp.config.ts"] } } }The client starts the server itself. The MCP guide covers the nine tools, captures and errors.
Guides
- The model — what runs where, and who owns each step
- Formats and validation — catalogs, themes, design systems, capabilities, manifests, trees
- Writing widgets — the TSX SDK, intent helpers and
liveframe gen - The renderer — primitives, implementations,
<Surface>and intent handling - Styling — recipes, the three sheets and scoped CSS
- Localisation — locale through
context, host-formatted text and what stays deterministic - Template widgets — data-bound widgets as JSON, installable without a sandbox
- The host pipeline — one ordered, stateless pipeline: load, resolve as the viewer, render, validate, diff; then check the intent, authorise, dispatch, record, re-render
- Packages, stores and runners —
pack(),fileStore, choosing amonginProcessRunner,workerRunner,templateRunnerandquickjsRunner - Preview and capture — preview sessions,
<Preview>andliveframe preview capture - Conformance — the test kit for an app's catalog, styling, renderer and store
- Agent authoring over MCP —
liveframe mcpand its nine tools - Agent walkthrough for the demo — author, capture, install and place a draft
- Security model — what is validated where, and what is not a sandbox
- Security checklist — what the library checks and what your app must do, row by row
- Compatibility — what a version bump may change
- Migrating to 0.3.0 — each break with before, after and a checklist
- What 0.3.0 gives adopters — each adopter request, its shipped API and its limit
Status
Liveframe is pre-1.0. The latest published release is 0.4.1 (2026-11-24), a security patch of 0.4.0. See the release notes, migration guide, adopter notes and what 0.4.1 changes. The compatibility policy covers the public API, formats and on-disk fileStore layout.
Development
bun install
bun run check # build, generated output, typecheck, lint, format, testsRepository layout, roadmap and plans: roadmap.md, plans/. Contributing with agents: AGENTS.md. Security reports: SECURITY.md.
License
MIT — see LICENSE.
