import { GadgetCatalogAdapter } from '@ggui-ai/gadgets'; import { GeneratorTier, UiGenerator } from '@ggui-ai/mcp-server-core'; import { Q as QualityConfig } from './types-public-DIpjC-OA.js'; import { A as AgentConfig } from './llm-router-BEVtbAb9.js'; interface CreateUiGeneratorOptions { /** * Wire `DEFAULT_RUNTIME_RENDER_CHECK` into the harness's check leg. * When `true`, every coding turn ends with a happy-dom runtime-render * probe that catches contract-wiring bugs (missing `useAction()`, * wrong stream channel name, etc.). * * Default: `false` for OSS — keeps cold-start light. The probe pulls * happy-dom + @testing-library on first use (~700-1500ms cold). Bench * enables it via dispatch's own default for stricter quality gating. */ readonly enableRuntimeRender?: boolean; /** Maximum coding attempts per generation pass. */ readonly maxAttempts?: number; /** Maximum evaluation rounds. */ readonly maxEvalRounds?: number; /** Quality config controlling eval tiers + improvement behavior. */ readonly qualityConfig?: QualityConfig; /** * Generator identity — registry key + parsed components. * * The tier + model determine the {@link UiGenerator.slug} the * factory bakes onto the returned generator. Defaults to * `{tier: 'default', model: 'haiku-4-5'}` → slug * `ui-gen-default-haiku-4-5`, the OSS seed. * * The actual model used per request still comes from * `UiGenerateInput.llm.model` (operators may override via BYOK). * The identity here is the registry-level handle, not a runtime * model constraint. * * Mutually-exclusive shortcut: pass `slug` instead and the factory * parses it for you. The slug + tier/model overloads conflict; the * factory throws if both are supplied. */ readonly tier?: GeneratorTier; readonly model?: string; readonly slug?: string; /** * Per-deployment gadget descriptor source. Wired once at factory * time; the generator resolves descriptors per-call via * `gadgetCatalog.list(input.appId)` when `input.appGadgets` is * absent. See {@link GadgetCatalogAdapter} (`@ggui-ai/gadgets`) for * the port + the two batteries-included implementations. * * Wiring patterns: * * ```ts * // OSS: stdlib seed, no app-specific catalogs. * createUiGenerator({ * gadgetCatalog: InMemoryGadgetCatalog.withDefault(STDLIB_GADGETS), * }); * * // Cloud / prod: TTL cache over a registry-backed adapter. * createUiGenerator({ * gadgetCatalog: new CachingGadgetCatalog( * new DynamoGadgetCatalog(appMetadataStore), * { ttlMs: 30_000 }, * ), * }); * ``` * * Per-call resolution precedence (in {@link UiGenerator.generate}): * * 1. `input.appGadgets` (pre-fetched by caller — handler-side path) * 2. `gadgetCatalog.list(input.appId)` (factory path, this option) * 3. empty list (legacy callers — no gadgets resolved) * * Optional. When omitted, callers MUST pre-fetch and pass * `appGadgets` themselves; the legacy handler path stays unchanged. */ readonly gadgetCatalog?: GadgetCatalogAdapter; /** * When `true`, `generate()` never mutates `process.env` — the * resolved provider route is threaded structurally into the * dispatch call instead of being written to and restored from the * process environment. Use this when running concurrent * generations in one process (the default backup/mutate/restore * dance is NOT concurrency-safe: two simultaneous calls race on * the shared `process.env`). * * Default `false` — preserves the original env-mutation behavior * for callers that don't need concurrent generations in-process. */ readonly disableEnvMutation?: boolean; /** * Retry observer (#489) — see `AgentConfig.onRetry`. Bound ONCE at * factory construction time (mirrors `disableEnvMutation`), not * per-call: `generate()` is invoked once per request, but the * generator instance itself is typically long-lived and cached by * the caller, so a single observer covers every generation it runs. * Fires whenever any agent's `apiCall()` retries a rate-limited * request. Absent (default) is a no-op — retries still happen and * still log via `console.warn`, just without a caller-side hook. */ readonly onRetry?: AgentConfig['onRetry']; } declare function createUiGenerator(options?: CreateUiGeneratorOptions): UiGenerator; declare function extractComponentCode(raw: string): string; export { type CreateUiGeneratorOptions as C, createUiGenerator as c, extractComponentCode as e };