Files
wehub-resource-sync 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
chore: import upstream snapshot with attribution
2026-07-13 13:40:13 +08:00
..

@assistant-ui/x-generative-compiler

Internal package. Not meant for direct use. Use a build integration such as @assistant-ui/next or @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 render and any "use client" execute (frontend tools), drops backend execute and humanTool() sentinels, and stamps each tool's inferred type.
  • server — keeps the backend execute (importing server-only), drops render, and omits externally-defined backend tools marked with externalTool().

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,
  });
}