e30e75b5d4
Changesets / Create Version PR (push) Has been cancelled
Deploy Shadcn Registry / Deploy Production (push) Has been cancelled
Template Metrics / LOC + Bundle Size (push) Has been cancelled
Code Quality / Oxlint + Oxfmt (push) Has been cancelled
Code Quality / Template Sync (push) Has been cancelled
Code Quality / Build Changed Packages (push) Has been cancelled
Code Quality / Test Changed Packages (push) Has been cancelled
Deploy Expo Example / Deploy Production (push) Has been cancelled
Deploy Ink Example / Deploy Production (push) Has been cancelled
Python Tests / pytest (assistant-stream, 3.10) (push) Has been cancelled
Python Tests / pytest (assistant-stream, 3.12) (push) Has been cancelled
Python Tests / pytest (assistant-ui-sync-server-api, 3.10) (push) Has been cancelled
Python Tests / pytest (assistant-ui-sync-server-api, 3.12) (push) Has been cancelled
@assistant-ui/x-generative-compiler
Internal package. Not meant for direct use. Use a build integration such as
@assistant-ui/nextor@assistant-ui/vite.
The framework-agnostic "use generative" compiler. It takes a module that
colocates a tool's schema, its server-only execute, and its client-only
render, and rewrites it for a single build target:
- client — keeps
renderand any"use client"execute(frontend tools), drops backendexecuteandhumanTool()sentinels, and stamps each tool's inferredtype. - server — keeps the backend
execute(importingserver-only), dropsrender, and omits externally-defined backend tools marked withexternalTool().
The marker functions a "use generative" file imports — defineToolkit and
humanTool — live in @assistant-ui/core/react (re-exported from
@assistant-ui/react). This package only recognizes them by name and strips them
at build time.
API
import {
compileGenerative,
isGenerativeModule,
GenerativeCompileError,
DIRECTIVE,
type Target,
} from "@assistant-ui/x-generative-compiler";
if (isGenerativeModule(code)) {
const { code: out, map } = compileGenerative(code, {
target: "server", // or "client"
filename,
sourceMaps: true,
});
}