Licence
MIT
Version
0.0.5
Deps
5
Size
186 kB
Vulns
0
Weekly
699
@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,
});
}