export { C as CreateUiGeneratorOptions, c as createUiGenerator, e as extractComponentCode } from './create-ui-generator-CF0EL0Li.js'; export { P as ProviderRetryInfo } from './llm-router-BEVtbAb9.js'; export { CreateInMemoryGeneratorRegistryOptions, createInMemoryGeneratorRegistry } from '@ggui-ai/mcp-server-core/in-memory'; import { UiGenerator } from '@ggui-ai/mcp-server-core'; export { R as RenderingContext, b as buildContractsContext, a as buildRenderingContext, c as buildVarianceContext, i as injectContracts, d as injectRenderingContext, e as injectVariance } from './prompts-BVhtH3M1.js'; import Anthropic from '@anthropic-ai/sdk'; import '@ggui-ai/gadgets'; import './types-public-DIpjC-OA.js'; import '@ggui-ai/protocol'; import './axes-CzLEMDeB.js'; import './types-BOvHNG7K.js'; import './llm.js'; /** * Compile raw JSX/TSX component code emitted by `createUiGenerator` into * plain ESM that the browser's `ReactComponentRenderer` can mount. * * The OSS generator (`createUiGenerator`) ships one provider call out → * raw source in. The source typically carries JSX syntax, TypeScript * annotations, and bare ESM `import` specifiers (`react`, * `@ggui-ai/design/primitives`). Modern browsers can execute ESM * directly — but NOT JSX, and only with already-resolved specifiers. * This module bridges that gap with a single esbuild `transform` pass: * * - `loader: 'tsx'` → strips types + desugars JSX to `jsx-runtime` * calls. * - `jsx: 'automatic'` → emits `import { jsx as _jsx } from 'react/jsx-runtime'` * which the viewer's import-rewriting layer (see * `@ggui-ai/design/rendering`) resolves to the host React via a * `data:` URL shim. * - `format: 'esm'` → keeps static `import` declarations at the top * of the module so `loadModule()`'s blob-URL dynamic import sees a * valid ESM module. * * The dependency on esbuild is loaded lazily via a function-scoped * dynamic `import('esbuild')` so consumers who never call the compiler * (the hosted runtime, which has its own esbuild-based generator) don't pay * the cold-start cost. * * Browser-side vs server-side compile: there are two ways to land * compiled code in the viewer — esbuild-wasm in the browser, OR * server-side compile + ship ESM down the render channel. ggui * compiles server-side: (a) the CLI already runs in Node, (b) shipping * esbuild-wasm into a frontend bundle is prohibitively large, (c) the * hosted surface also compiles server-side, so the viewer contract * stays identical across deployments. `withBrowserCompile` is the * wrapper that takes a raw-source `UiGenerator` and upgrades it to emit * browser-ready ESM on the component-code surface. */ /** * Thrown when `compileComponentCode` can't transform the generator's * raw source. Carries the underlying esbuild message so upstream * consumers can surface a readable failure on the render channel * instead of blowing up the whole render RPC. */ declare class CompileComponentCodeError extends Error { /** Original error from esbuild (or the module loader) if any. */ readonly cause?: unknown | undefined; constructor(message: string, /** Original error from esbuild (or the module loader) if any. */ cause?: unknown | undefined); } /** * Transform raw JSX/TSX source from `createUiGenerator` into plain ESM * that `loadModule` (blob-URL dynamic import) can execute in the * browser. Bare specifiers (`react`, `@ggui-ai/design/*`) are left as * static imports — the renderer's `rewriteImports` step resolves them * to `data:`-URL shims that read from `globalThis.__ggui__` at mount * time. * * Pure function: no filesystem, no network, no globals mutated. * * @throws {CompileComponentCodeError} when esbuild rejects the source. */ declare function compileComponentCode(source: string): Promise; /** * Wrap a `UiGenerator` so that successful outputs carry browser-ready * ESM on `response.componentCode` (and the parallel `response.sourceCode` * field) — the original JSX/TSX source is preserved on * `response.sourceCode` so downstream consumers that want human-readable * source (benchmarks, blueprint cache seeding) still have it. * * const raw = createUiGenerator(); * const oss = withBrowserCompile(raw); * const out = await oss.generate({ ... }); * // out.response.componentCode → ESM (browser-ready) * // out.response.sourceCode → original JSX/TSX * * Compile failures are funnelled into the generator's * `PRODUCTION_FAILED` error channel, NOT thrown. Consumers (the OSS * render handler) already classify generator failures and commit an * error-only render — so a compile failure shows up in the viewer * with the same "couldn't render" ergonomics as a provider failure. * Throwing out of `generate()` would break the handler's invariant that * the generator never rejects. */ declare function withBrowserCompile(generator: UiGenerator): UiGenerator; /** * Construct an Anthropic SDK client from a raw API key string. * * - `string` → standard `apiKey` path (sends `x-api-key`). * - `undefined` → still construct a client; SDK auto-reads * `process.env.ANTHROPIC_API_KEY` or throws on first call. * * **SINGLE SOURCE OF TRUTH for Anthropic client construction.** Every * adapter that constructs an Anthropic client MUST go through this * helper — no inline `new Anthropic(...)` allowed in adapter code. */ declare function createAnthropicClient(rawKey: string | undefined): Anthropic; export { CompileComponentCodeError, compileComponentCode, createAnthropicClient, withBrowserCompile };