@ggui-ai/ui-gen 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/generation-dispatch.d.ts +21 -4
- package/dist/adapters/generation-dispatch.js +913 -350
- package/dist/adapters/generation-dispatch.js.map +1 -1
- package/dist/adapters/index.js +26 -22
- package/dist/adapters/index.js.map +1 -1
- package/dist/advanced/index.d.ts +17 -12
- package/dist/advanced/index.js +966 -374
- package/dist/advanced/index.js.map +1 -1
- package/dist/boilerplate.d.ts +16 -1
- package/dist/boilerplate.js +579 -245
- package/dist/boilerplate.js.map +1 -1
- package/dist/check/index.d.ts +17 -3
- package/dist/check/index.js +32 -25
- package/dist/check/index.js.map +1 -1
- package/dist/{create-ui-generator-D6TKuv9V.d.ts → create-ui-generator-CCIeQaEe.d.ts} +77 -10
- package/dist/design-mode-BHEE7flj.d.ts +67 -0
- package/dist/{dispatch-BuZfTh9r.d.ts → dispatch-BA5dJcg-.d.ts} +4 -1
- package/dist/evaluation/axis-checks/index.d.ts +4 -3
- package/dist/evaluation/axis-checks/index.js +3 -1
- package/dist/evaluation/axis-checks/index.js.map +1 -1
- package/dist/evaluation/axis-checks/registry.d.ts +2 -1
- package/dist/evaluation/axis-checks/registry.js +1 -0
- package/dist/evaluation/axis-checks/registry.js.map +1 -1
- package/dist/evaluation/index.d.ts +143 -3
- package/dist/evaluation/index.js +3866 -92
- package/dist/evaluation/index.js.map +1 -1
- package/dist/{generate-BTfvELgl.d.ts → generate-8L_bc2iP.d.ts} +10 -1
- package/dist/harness/check/runtime-render/index.d.ts +2 -1
- package/dist/harness/index.d.ts +2 -1
- package/dist/harness/index.js +589 -248
- package/dist/harness/index.js.map +1 -1
- package/dist/harness/llm-trace-sink.d.ts +3 -3
- package/dist/harness/llm-trace-sink.js.map +1 -1
- package/dist/harness/prompts.d.ts +2 -1
- package/dist/harness/prompts.js +3 -0
- package/dist/harness/prompts.js.map +1 -1
- package/dist/harness/result-types.d.ts +17 -5
- package/dist/harness/result-types.js.map +1 -1
- package/dist/harness/runtime.d.ts +19 -3
- package/dist/harness/runtime.js +602 -261
- package/dist/harness/runtime.js.map +1 -1
- package/dist/harness/types-public.d.ts +28 -1
- package/dist/harness/types-public.js +589 -248
- package/dist/harness/types-public.js.map +1 -1
- package/dist/harness/validator-trace-sink.d.ts +2 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.js +973 -372
- package/dist/index.js.map +1 -1
- package/dist/patch.d.ts +2 -1
- package/dist/{prompts-BVhtH3M1.d.ts → prompts-k6m6reqe.d.ts} +11 -1
- package/dist/providers/index.d.ts +2 -2
- package/dist/providers/index.js.map +1 -1
- package/dist/tools/get-primitives-ts.d.ts +1 -1
- package/dist/tools/get-primitives-ts.js +1 -1
- package/dist/tools/get-primitives-ts.js.map +1 -1
- package/dist/{types-public-CkNWEov9.d.ts → types-public-D24JLJgl.d.ts} +49 -5
- package/dist/validation/index.d.ts +1 -1
- package/dist/validation/index.js +4 -4
- package/dist/validation/index.js.map +1 -1
- package/dist/workflows.d.ts +2 -1
- package/package.json +12 -12
- package/src/adapters/generation-dispatch.ts +57 -4
- package/src/adapters/provider-router.ts +7 -6
- package/src/adapters/tools.ts +5 -5
- package/src/advanced/generator.ts +11 -10
- package/src/advanced/index.ts +5 -4
- package/src/boilerplate/free-design-prompt.ts +329 -0
- package/src/boilerplate/generate.ts +10 -1
- package/src/boilerplate/hard-sections.ts +242 -0
- package/src/boilerplate/render.ts +32 -8
- package/src/boilerplate/system-prompt.ts +81 -229
- package/src/boilerplate/templates/base-free.tsx.tmpl +24 -0
- package/src/check/run-tier0.ts +80 -20
- package/src/coding-agent/tools.ts +8 -2
- package/src/contract-context.ts +28 -0
- package/src/create-harness.ts +11 -0
- package/src/create-ui-generator.ts +71 -25
- package/src/design-mode.ts +182 -0
- package/src/design-system-docs.ts +17 -13
- package/src/evaluation/axis-checks/dispatch.ts +4 -0
- package/src/evaluation/axis-checks/extras.ts +5 -0
- package/src/evaluation/cost-tracker.ts +2 -3
- package/src/evaluation/index.ts +46 -2
- package/src/evaluation/llm-evaluator.ts +77 -21
- package/src/evaluation/types-public.ts +103 -8
- package/src/evaluation/visual-evaluator.ts +301 -29
- package/src/harness/coding/dupe-break.ts +0 -0
- package/src/harness/coding/init-session.ts +1 -0
- package/src/harness/coding/run-coding-turn.ts +3 -0
- package/src/harness/coding/run-eval-round.ts +15 -2
- package/src/harness/llm-trace-sink.ts +3 -3
- package/src/harness/result-types.ts +15 -3
- package/src/harness/runtime.ts +18 -0
- package/src/harness/types-public.ts +27 -0
- package/src/index.ts +26 -0
- package/src/internal/extract-call-signatures.ts +2 -2
- package/src/providers/bedrock.ts +4 -4
- package/src/run-check.ts +1 -0
- package/src/tools/get-primitives-ts.ts +1 -1
- package/src/validation/allowed-imports.ts +8 -2
- package/src/validation/primitives.ts +1 -1
|
@@ -1,8 +1,45 @@
|
|
|
1
|
+
import { ModelRef } from '@ggui-ai/protocol';
|
|
1
2
|
import { GadgetCatalogAdapter } from '@ggui-ai/gadgets';
|
|
2
3
|
import { GeneratorTier, UiGenerator } from '@ggui-ai/mcp-server-core';
|
|
3
|
-
import {
|
|
4
|
+
import { GenerationResult } from './harness/result-types.js';
|
|
5
|
+
import { D as DesignMode } from './design-mode-BHEE7flj.js';
|
|
6
|
+
import { Q as QualityConfig } from './types-public-D24JLJgl.js';
|
|
4
7
|
import { A as AgentConfig } from './llm-router-D7fjBhtr.js';
|
|
5
8
|
|
|
9
|
+
/**
|
|
10
|
+
* `createUiGenerator` — full-harness UI generation factory.
|
|
11
|
+
*
|
|
12
|
+
* Returns a {@link UiGenerator} backed by `dispatchGeneration` — the
|
|
13
|
+
* same multi-turn coding-agent path the benchmark validates. OSS
|
|
14
|
+
* production (`ggui serve`, hosted `ggui_render`) all route through
|
|
15
|
+
* this seam, so bench == prod by construction.
|
|
16
|
+
*
|
|
17
|
+
* Pipeline:
|
|
18
|
+
*
|
|
19
|
+
* 1. `resolveRoute` + `applyRouteToEnv` — install BYOK key into
|
|
20
|
+
* the process env so dispatch's adapters can read it.
|
|
21
|
+
* 2. `createGeneratorTools` — assemble the coding-agent tool surface
|
|
22
|
+
* (compile_component, validate_component, self_check,
|
|
23
|
+
* get_primitives, get_design_system).
|
|
24
|
+
* 3. `injectRenderingContext` + `injectContracts` — enrich the user
|
|
25
|
+
* prompt with rendering hints + contract docs.
|
|
26
|
+
* 4. `dispatchGeneration` — multi-turn loop with apply_changes,
|
|
27
|
+
* self-check, evaluate, regenerate. The harness builds its own
|
|
28
|
+
* rich system prompt with primitives doc + design-system docs +
|
|
29
|
+
* pitfalls.
|
|
30
|
+
*
|
|
31
|
+
* This factory deliberately keeps a minimal surface — provider
|
|
32
|
+
* routing, compilation, and the system prompt are all internal:
|
|
33
|
+
*
|
|
34
|
+
* - `adapter` option — provider routing is internal to dispatch
|
|
35
|
+
* - `compileFn` option — `compile_component` tool runs inline
|
|
36
|
+
* - `systemPromptBuilder` option — harness builds its own
|
|
37
|
+
* - `withBrowserCompile` wrapper — dispatch returns compiled JS
|
|
38
|
+
*
|
|
39
|
+
* Callers who want a lightweight single-shot path can build it
|
|
40
|
+
* themselves.
|
|
41
|
+
*/
|
|
42
|
+
|
|
6
43
|
interface CreateUiGeneratorOptions {
|
|
7
44
|
/**
|
|
8
45
|
* Wire `DEFAULT_RUNTIME_RENDER_CHECK` into the harness's check leg.
|
|
@@ -22,24 +59,25 @@ interface CreateUiGeneratorOptions {
|
|
|
22
59
|
/** Quality config controlling eval tiers + improvement behavior. */
|
|
23
60
|
readonly qualityConfig?: QualityConfig;
|
|
24
61
|
/**
|
|
25
|
-
* Generator identity — registry key +
|
|
62
|
+
* Generator identity — registry key + declared model.
|
|
26
63
|
*
|
|
27
|
-
* The tier
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* `ui-gen-default
|
|
64
|
+
* The tier alone determines the {@link UiGenerator.slug} the factory
|
|
65
|
+
* bakes onto the returned generator (`ui-gen-<tier>`); `model` is the
|
|
66
|
+
* generator's declared model field and is never part of the slug
|
|
67
|
+
* (ggui#923). Defaults to tier `'default'` → slug `ui-gen-default`,
|
|
68
|
+
* the OSS seed, with the factory's default model.
|
|
31
69
|
*
|
|
32
70
|
* The actual model used per request still comes from
|
|
33
71
|
* `UiGenerateInput.llm.model` (operators may override via BYOK).
|
|
34
72
|
* The identity here is the registry-level handle, not a runtime
|
|
35
73
|
* model constraint.
|
|
36
74
|
*
|
|
37
|
-
* Mutually-exclusive shortcut: pass `slug` instead and the
|
|
38
|
-
* parses
|
|
39
|
-
* factory throws if
|
|
75
|
+
* Mutually-exclusive shortcut: pass `slug` instead of `tier` and the
|
|
76
|
+
* factory parses the tier from it; `model` may accompany either form.
|
|
77
|
+
* The factory throws if `slug` and `tier` are both supplied.
|
|
40
78
|
*/
|
|
41
79
|
readonly tier?: GeneratorTier;
|
|
42
|
-
readonly model?:
|
|
80
|
+
readonly model?: ModelRef;
|
|
43
81
|
readonly slug?: string;
|
|
44
82
|
/**
|
|
45
83
|
* Per-deployment gadget descriptor source. Wired once at factory
|
|
@@ -99,6 +137,35 @@ interface CreateUiGeneratorOptions {
|
|
|
99
137
|
* still log via `console.warn`, just without a caller-side hook.
|
|
100
138
|
*/
|
|
101
139
|
readonly onRetry?: AgentConfig['onRetry'];
|
|
140
|
+
/**
|
|
141
|
+
* Generation observer. Invoked once per successful `generate()` with
|
|
142
|
+
* the FULL harness result — source, compiled code, token counters,
|
|
143
|
+
* timing breakdown, evaluation rounds and (when configured) the
|
|
144
|
+
* per-canvas visual scores — before it is projected onto the
|
|
145
|
+
* `UiGenerateResult` envelope, which carries only what the protocol
|
|
146
|
+
* needs. Lets a host record or forward the complete run without
|
|
147
|
+
* re-deriving it from the envelope. Bound ONCE at construction
|
|
148
|
+
* (mirrors `onRetry`); not invoked when generation fails. An
|
|
149
|
+
* exception thrown by the observer is the caller's own and fails
|
|
150
|
+
* that generation like any other error on the path — keep it
|
|
151
|
+
* non-throwing.
|
|
152
|
+
*/
|
|
153
|
+
readonly onGenerated?: (result: GenerationResult) => void;
|
|
154
|
+
/**
|
|
155
|
+
* Which generation triad to run. `constrained` (default) is the
|
|
156
|
+
* design-system triad — byte-identical to the generator's behaviour
|
|
157
|
+
* before this option existed. `free` relaxes only the design
|
|
158
|
+
* vocabulary (raw HTML, inline CSS, literal spacing / typography /
|
|
159
|
+
* radius; the design package importable but optional) while keeping
|
|
160
|
+
* every hard contract: the boilerplate-typed wire hooks, the import
|
|
161
|
+
* allowlist + security bans, the host envelope, the budgets, the
|
|
162
|
+
* blueprint-reuse shape, and brand-bearing color on the closed
|
|
163
|
+
* `--ggui-color-*` token manifest. Reaches the prompt, boilerplate,
|
|
164
|
+
* tier-0 gate, axis checks and evaluator criteria through the harness.
|
|
165
|
+
* The rendering canvas the `free` prompt states is derived from
|
|
166
|
+
* `input.rendering` (device × shell, refined by viewport width).
|
|
167
|
+
*/
|
|
168
|
+
readonly designMode?: DesignMode;
|
|
102
169
|
}
|
|
103
170
|
declare function createUiGenerator(options?: CreateUiGeneratorOptions): UiGenerator;
|
|
104
171
|
declare function extractComponentCode(raw: string): string;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
declare const DESIGN_MODES: readonly ["constrained", "free"];
|
|
2
|
+
type DesignMode = (typeof DESIGN_MODES)[number];
|
|
3
|
+
declare const DEFAULT_DESIGN_MODE: DesignMode;
|
|
4
|
+
declare const CANVAS_CLASSES: readonly ["xs-chat-card", "mobile-fullscreen-small", "md", "lg", "xl"];
|
|
5
|
+
type CanvasClass = (typeof CANVAS_CLASSES)[number];
|
|
6
|
+
interface CanvasViewport {
|
|
7
|
+
readonly width: number;
|
|
8
|
+
readonly height: number;
|
|
9
|
+
}
|
|
10
|
+
/** The viewport (CSS px) each class is rendered + judged at. */
|
|
11
|
+
declare const CANVAS_VIEWPORTS: Readonly<Record<CanvasClass, CanvasViewport>>;
|
|
12
|
+
/**
|
|
13
|
+
* The two display modes the canvas derivation distinguishes. `inline`
|
|
14
|
+
* is the chat card (MCP Apps `inline` display mode / the `chat` shell);
|
|
15
|
+
* `fullscreen` is every surface the component owns edge to edge or as
|
|
16
|
+
* a panel (`fullscreen`, `pip`, the `spatial` and `partial` shells) —
|
|
17
|
+
* there the width decides the class.
|
|
18
|
+
*/
|
|
19
|
+
type CanvasDisplayMode = "inline" | "fullscreen";
|
|
20
|
+
/**
|
|
21
|
+
* Map a shell name (`chat` / `fullscreen` / `spatial` / `partial`) or an
|
|
22
|
+
* MCP Apps display mode (`inline` / `fullscreen` / `pip`) onto the
|
|
23
|
+
* canvas display mode. Only `chat` and `inline` are the inline card;
|
|
24
|
+
* everything else is width-governed.
|
|
25
|
+
*/
|
|
26
|
+
declare function canvasDisplayModeForShell(shell: string | undefined): CanvasDisplayMode;
|
|
27
|
+
/** Fullscreen-class breakpoints (inclusive lower bounds), CSS px. */
|
|
28
|
+
declare const CANVAS_BREAKPOINTS: {
|
|
29
|
+
readonly md: 600;
|
|
30
|
+
readonly lg: 1024;
|
|
31
|
+
readonly xl: 1440;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Derive the canvas class from display mode + container width.
|
|
35
|
+
*
|
|
36
|
+
* inline → `xs-chat-card` at every width
|
|
37
|
+
* fullscreen → width < 600 → `mobile-fullscreen-small`
|
|
38
|
+
* 600 – 1023 → `md`
|
|
39
|
+
* 1024 – 1439 → `lg`
|
|
40
|
+
* ≥ 1440 → `xl`
|
|
41
|
+
*/
|
|
42
|
+
declare function canvasForViewportWidth(mode: CanvasDisplayMode, width: number): CanvasClass;
|
|
43
|
+
/**
|
|
44
|
+
* Map today's shell × screen descriptors onto a canvas class when no
|
|
45
|
+
* width is known. `chat` is always the inline card; `spatial` is a
|
|
46
|
+
* ~600px floating panel (`md`); `fullscreen` follows the screen. Unknown
|
|
47
|
+
* values fall back to `lg` (the widest common fullscreen), matching the
|
|
48
|
+
* skeleton's `fullscreen` / `universal` defaults.
|
|
49
|
+
*/
|
|
50
|
+
declare function canvasForRendering(shellType: string | undefined, screen: string | undefined): CanvasClass;
|
|
51
|
+
interface CanvasDescriptor {
|
|
52
|
+
/** Short human label. */
|
|
53
|
+
readonly label: string;
|
|
54
|
+
/** Inclusive width range the component must look right across, CSS px. */
|
|
55
|
+
readonly minWidthPx: number;
|
|
56
|
+
readonly maxWidthPx: number;
|
|
57
|
+
/** What the host draws around the component at this canvas. */
|
|
58
|
+
readonly host: string;
|
|
59
|
+
}
|
|
60
|
+
declare const CANVAS_DESCRIPTORS: Readonly<Record<CanvasClass, CanvasDescriptor>>;
|
|
61
|
+
/**
|
|
62
|
+
* The explicit sentence the `free` prompt renders for a canvas — the
|
|
63
|
+
* agent is TOLD the canvas, it never guesses it.
|
|
64
|
+
*/
|
|
65
|
+
declare function describeCanvas(canvas: CanvasClass): string;
|
|
66
|
+
|
|
67
|
+
export { type CanvasClass as C, type DesignMode as D, CANVAS_BREAKPOINTS as a, CANVAS_CLASSES as b, CANVAS_DESCRIPTORS as c, CANVAS_VIEWPORTS as d, type CanvasDescriptor as e, type CanvasDisplayMode as f, type CanvasViewport as g, DEFAULT_DESIGN_MODE as h, DESIGN_MODES as i, canvasDisplayModeForShell as j, canvasForRendering as k, canvasForViewportWidth as l, describeCanvas as m };
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { DataContract } from '@ggui-ai/protocol';
|
|
2
2
|
import { C as Classification } from './axes-CzLEMDeB.js';
|
|
3
|
-
import { E as EvalIssue } from './types-public-
|
|
3
|
+
import { E as EvalIssue } from './types-public-D24JLJgl.js';
|
|
4
|
+
import { D as DesignMode } from './design-mode-BHEE7flj.js';
|
|
4
5
|
|
|
5
6
|
interface RunAxisChecksInput {
|
|
6
7
|
sourceCode: string;
|
|
7
8
|
compiledCode: string | null;
|
|
8
9
|
contract?: DataContract;
|
|
9
10
|
originalPrompt: string;
|
|
11
|
+
/** Which triad produced the source — see `AxisCheckInput.designMode`. */
|
|
12
|
+
designMode?: DesignMode;
|
|
10
13
|
}
|
|
11
14
|
declare function runAxisChecks(classification: Classification, input: RunAxisChecksInput): EvalIssue[];
|
|
12
15
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export { R as RunAxisChecksInput, r as runAxisChecks } from '../../dispatch-
|
|
1
|
+
export { R as RunAxisChecksInput, r as runAxisChecks } from '../../dispatch-BA5dJcg-.js';
|
|
2
2
|
export { REGISTRY } from './registry.js';
|
|
3
|
-
import { A as AxisCheck } from '../../types-public-
|
|
4
|
-
export { a as AxisCheckInput, m as matches } from '../../types-public-
|
|
3
|
+
import { A as AxisCheck } from '../../types-public-D24JLJgl.js';
|
|
4
|
+
export { a as AxisCheckInput, m as matches } from '../../types-public-D24JLJgl.js';
|
|
5
5
|
import '@ggui-ai/protocol';
|
|
6
6
|
import '../../axes-CzLEMDeB.js';
|
|
7
|
+
import '../../design-mode-BHEE7flj.js';
|
|
7
8
|
import '../../types-BOvHNG7K.js';
|
|
8
9
|
|
|
9
10
|
declare const EXTRA_CHECKS: readonly AxisCheck[];
|
|
@@ -1152,6 +1152,7 @@ var stepperAdopted = {
|
|
|
1152
1152
|
values: ["multi-step"],
|
|
1153
1153
|
run(input) {
|
|
1154
1154
|
if (input.compiledCode === null) return [];
|
|
1155
|
+
if (input.designMode === "free") return [];
|
|
1155
1156
|
if (/<Stepper[\s/>]/.test(input.sourceCode)) return [];
|
|
1156
1157
|
return [
|
|
1157
1158
|
mkIssue2(
|
|
@@ -1223,7 +1224,8 @@ function runAxisChecks(classification, input) {
|
|
|
1223
1224
|
compiledCode: input.compiledCode,
|
|
1224
1225
|
...input.contract !== void 0 ? { contract: input.contract } : {},
|
|
1225
1226
|
originalPrompt: input.originalPrompt,
|
|
1226
|
-
classification
|
|
1227
|
+
classification,
|
|
1228
|
+
...input.designMode !== void 0 ? { designMode: input.designMode } : {}
|
|
1227
1229
|
};
|
|
1228
1230
|
const issues = [];
|
|
1229
1231
|
const firedIds = /* @__PURE__ */ new Set();
|