@ggui-ai/ui-gen 0.9.0 → 0.10.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 +9 -2
- package/dist/adapters/generation-dispatch.js +547 -85
- package/dist/adapters/generation-dispatch.js.map +1 -1
- package/dist/adapters/index.js +28 -11
- package/dist/adapters/index.js.map +1 -1
- package/dist/advanced/index.d.ts +5 -3
- package/dist/advanced/index.js +563 -92
- package/dist/advanced/index.js.map +1 -1
- package/dist/blueprint-validator.js +109 -3
- package/dist/blueprint-validator.js.map +1 -1
- package/dist/boilerplate.js +14 -2
- package/dist/boilerplate.js.map +1 -1
- package/dist/check/index.d.ts +1 -1
- package/dist/check/index.js +11 -1
- package/dist/check/index.js.map +1 -1
- package/dist/{create-ui-generator-B9kV4U9h.d.ts → create-ui-generator-CF0EL0Li.d.ts} +13 -1
- package/dist/{dispatch-Deo9qzrG.d.ts → dispatch-D75M-OfZ.d.ts} +1 -1
- package/dist/evaluation/axis-checks/index.d.ts +3 -3
- package/dist/evaluation/axis-checks/index.js +101 -0
- package/dist/evaluation/axis-checks/index.js.map +1 -1
- package/dist/evaluation/axis-checks/registry.d.ts +1 -1
- package/dist/evaluation/axis-checks/registry.js +101 -0
- package/dist/evaluation/axis-checks/registry.js.map +1 -1
- package/dist/evaluation/index.d.ts +46 -3
- package/dist/evaluation/index.js +358 -17
- package/dist/evaluation/index.js.map +1 -1
- package/dist/harness/check/runtime-render/index.d.ts +2 -2
- package/dist/harness/check/runtime-render/index.js +110 -3
- package/dist/harness/check/runtime-render/index.js.map +1 -1
- package/dist/harness/index.d.ts +2 -2
- package/dist/harness/index.js +263 -18
- package/dist/harness/index.js.map +1 -1
- package/dist/harness/llm-trace-sink.d.ts +1 -1
- package/dist/harness/llm-trace-sink.js.map +1 -1
- package/dist/harness/prompts.js +17 -3
- package/dist/harness/prompts.js.map +1 -1
- package/dist/harness/result-types.d.ts +1 -1
- package/dist/harness/runtime.d.ts +9 -2
- package/dist/harness/runtime.js +20 -6
- package/dist/harness/runtime.js.map +1 -1
- package/dist/harness/types-public.d.ts +1 -1
- package/dist/harness/types-public.js +14 -2
- package/dist/harness/types-public.js.map +1 -1
- package/dist/harness/validator-trace-sink.d.ts +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js +563 -92
- package/dist/index.js.map +1 -1
- package/dist/{llm-router-1TyI0_TV.d.ts → llm-router-BEVtbAb9.d.ts} +61 -4
- package/dist/patch.d.ts +1 -1
- package/dist/provider-adapter.d.ts +16 -6
- package/dist/provider-adapter.js.map +1 -1
- package/dist/providers/index.d.ts +19 -6
- package/dist/providers/index.js.map +1 -1
- package/dist/{render-check-CNZjHD5g.d.ts → render-check-BNYGVDJd.d.ts} +1 -1
- package/dist/{types-public-C36k1q6s.d.ts → types-public-DIpjC-OA.d.ts} +1 -1
- package/dist/workflows.d.ts +1 -1
- package/package.json +12 -12
- package/src/adapters/generation-dispatch.ts +9 -0
- package/src/adapters/openrouter/client.ts +2 -2
- package/src/adapters/openrouter/types.ts +10 -0
- package/src/boilerplate/generate.ts +10 -2
- package/src/boilerplate/json-schema-ts.ts +22 -2
- package/src/boilerplate/system-prompt.ts +1 -0
- package/src/compile.ts +1 -1
- package/src/contract-context.ts +10 -2
- package/src/create-ui-generator.ts +14 -0
- package/src/design-system-docs.ts +6 -4
- package/src/evaluation/axis-checks/checks/state-ui-affordance.ts +162 -0
- package/src/evaluation/axis-checks/registry.ts +2 -0
- package/src/evaluation/index.ts +11 -0
- package/src/evaluation/llm-evaluator.ts +14 -1
- package/src/evaluation/visual-evaluator.ts +44 -65
- package/src/harness/check/runtime-render/adapter.ts +18 -0
- package/src/harness/check/runtime-render/index.ts +8 -0
- package/src/harness/check/runtime-render/prepare-mockup.ts +14 -0
- package/src/harness/check/runtime-render/production-act-shim.ts +158 -0
- package/src/harness/check/runtime-render/render-check.ts +72 -1
- package/src/harness/coding/run-eval-round.ts +61 -5
- package/src/harness/index.ts +1 -1
- package/src/harness/llm-router.ts +397 -18
- package/src/harness/llm-trace-sink.ts +2 -1
- package/src/harness/runtime.ts +7 -0
- package/src/index.ts +5 -5
- package/src/provider-adapter.ts +16 -6
- package/src/providers/bedrock.ts +5 -4
- package/src/providers/index.ts +16 -4
- package/src/tools/render-check.ts +19 -7
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { GadgetCatalogAdapter } from '@ggui-ai/gadgets';
|
|
2
2
|
import { GeneratorTier, UiGenerator } from '@ggui-ai/mcp-server-core';
|
|
3
|
-
import { Q as QualityConfig } from './types-public-
|
|
3
|
+
import { Q as QualityConfig } from './types-public-DIpjC-OA.js';
|
|
4
|
+
import { A as AgentConfig } from './llm-router-BEVtbAb9.js';
|
|
4
5
|
|
|
5
6
|
interface CreateUiGeneratorOptions {
|
|
6
7
|
/**
|
|
@@ -87,6 +88,17 @@ interface CreateUiGeneratorOptions {
|
|
|
87
88
|
* for callers that don't need concurrent generations in-process.
|
|
88
89
|
*/
|
|
89
90
|
readonly disableEnvMutation?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Retry observer (#489) — see `AgentConfig.onRetry`. Bound ONCE at
|
|
93
|
+
* factory construction time (mirrors `disableEnvMutation`), not
|
|
94
|
+
* per-call: `generate()` is invoked once per request, but the
|
|
95
|
+
* generator instance itself is typically long-lived and cached by
|
|
96
|
+
* the caller, so a single observer covers every generation it runs.
|
|
97
|
+
* Fires whenever any agent's `apiCall()` retries a rate-limited
|
|
98
|
+
* request. Absent (default) is a no-op — retries still happen and
|
|
99
|
+
* still log via `console.warn`, just without a caller-side hook.
|
|
100
|
+
*/
|
|
101
|
+
readonly onRetry?: AgentConfig['onRetry'];
|
|
90
102
|
}
|
|
91
103
|
declare function createUiGenerator(options?: CreateUiGeneratorOptions): UiGenerator;
|
|
92
104
|
declare function extractComponentCode(raw: string): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
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-DIpjC-OA.js';
|
|
4
4
|
|
|
5
5
|
interface RunAxisChecksInput {
|
|
6
6
|
sourceCode: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { R as RunAxisChecksInput, r as runAxisChecks } from '../../dispatch-
|
|
1
|
+
export { R as RunAxisChecksInput, r as runAxisChecks } from '../../dispatch-D75M-OfZ.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-DIpjC-OA.js';
|
|
4
|
+
export { a as AxisCheckInput, m as matches } from '../../types-public-DIpjC-OA.js';
|
|
5
5
|
import '@ggui-ai/protocol';
|
|
6
6
|
import '../../axes-CzLEMDeB.js';
|
|
7
7
|
import '../../types-BOvHNG7K.js';
|
|
@@ -407,6 +407,106 @@ var STATE_MERGE_CHECKS = [
|
|
|
407
407
|
}
|
|
408
408
|
];
|
|
409
409
|
|
|
410
|
+
// src/evaluation/axis-checks/checks/state-ui-affordance.ts
|
|
411
|
+
var STATE_ARIA_OR_ROLE = /aria-(checked|pressed|selected|expanded|current)\s*=|role\s*=/;
|
|
412
|
+
var STATE_PRIMITIVE_IN_SUBTREE = /<(Checkbox|Toggle|Tabs|Accordion)[\s/>]/;
|
|
413
|
+
var SEMANTIC_PRIMITIVES = /* @__PURE__ */ new Set(["Button", "Checkbox", "Toggle", "Link", "MenuItem"]);
|
|
414
|
+
function collectSetters(src) {
|
|
415
|
+
const setters = /* @__PURE__ */ new Set();
|
|
416
|
+
for (const m of src.matchAll(/const\s*\[\s*\w+\s*,\s*(set\w+)\s*\]\s*=\s*useState/g)) {
|
|
417
|
+
setters.add(m[1]);
|
|
418
|
+
}
|
|
419
|
+
return setters;
|
|
420
|
+
}
|
|
421
|
+
function collectHandlers(src, setters) {
|
|
422
|
+
const handlers = /* @__PURE__ */ new Set();
|
|
423
|
+
for (const m of src.matchAll(/const\s+(\w+)\s*=\s*(?:\([^)]*\)|\w+)\s*=>\s*\{?/g)) {
|
|
424
|
+
const body = src.slice(m.index + m[0].length, m.index + m[0].length + 400);
|
|
425
|
+
for (const s of setters) {
|
|
426
|
+
if (body.includes(s)) {
|
|
427
|
+
handlers.add(m[1]);
|
|
428
|
+
break;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return handlers;
|
|
433
|
+
}
|
|
434
|
+
function attrBlock(src, start) {
|
|
435
|
+
let depth = 0;
|
|
436
|
+
for (let i = start; i < src.length; i++) {
|
|
437
|
+
const c = src[i];
|
|
438
|
+
if (c === "{") depth++;
|
|
439
|
+
else if (c === "}") depth--;
|
|
440
|
+
else if (c === ">" && depth === 0) return { block: src.slice(start, i), end: i };
|
|
441
|
+
}
|
|
442
|
+
return { block: src.slice(start, start + 900), end: start + 900 };
|
|
443
|
+
}
|
|
444
|
+
function onClickValue(block) {
|
|
445
|
+
const m = block.match(/onClick\s*=\s*\{/);
|
|
446
|
+
if (!m || m.index === void 0) return null;
|
|
447
|
+
const open = m.index + m[0].length - 1;
|
|
448
|
+
let depth = 0;
|
|
449
|
+
for (let i = open; i < block.length; i++) {
|
|
450
|
+
if (block[i] === "{") depth++;
|
|
451
|
+
else if (block[i] === "}") {
|
|
452
|
+
depth--;
|
|
453
|
+
if (depth === 0) return block.slice(open + 1, i);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
return block.slice(open + 1);
|
|
457
|
+
}
|
|
458
|
+
function subtree(src, pos, tag) {
|
|
459
|
+
const close = src.indexOf(`</${tag}>`, pos);
|
|
460
|
+
return src.slice(pos, close === -1 ? pos + 700 : close);
|
|
461
|
+
}
|
|
462
|
+
function runStateAriaPresent(input) {
|
|
463
|
+
if (input.compiledCode === null) return [];
|
|
464
|
+
const src = input.sourceCode;
|
|
465
|
+
const setters = collectSetters(src);
|
|
466
|
+
const handlers = collectHandlers(src, setters);
|
|
467
|
+
const issues = [];
|
|
468
|
+
const flaggedLines = /* @__PURE__ */ new Set();
|
|
469
|
+
const localComponents = /* @__PURE__ */ new Set();
|
|
470
|
+
for (const m of src.matchAll(/(?:function\s+([A-Z]\w*)\s*\(|const\s+([A-Z]\w*)\s*=)/g)) {
|
|
471
|
+
localComponents.add(m[1] ?? m[2]);
|
|
472
|
+
}
|
|
473
|
+
for (const m of src.matchAll(/<([A-Za-z][A-Za-z0-9]*)\b/g)) {
|
|
474
|
+
const tag = m[1];
|
|
475
|
+
if (m.index === void 0) continue;
|
|
476
|
+
if (localComponents.has(tag)) continue;
|
|
477
|
+
const { block, end } = attrBlock(src, m.index + m[0].length);
|
|
478
|
+
const clickValue = onClickValue(block);
|
|
479
|
+
if (clickValue === null) continue;
|
|
480
|
+
const mutatesAffordance = [...setters].some((s) => clickValue.includes(s)) || [...handlers].some((h) => new RegExp(`\\b${h}\\b`).test(clickValue)) || // Extracted-subcomponent shape: the toggle handler arrives as an
|
|
481
|
+
// `on[A-Z]…` callback prop and is invoked from onClick — inside a
|
|
482
|
+
// ui-affordance component that IS the affordance mutation.
|
|
483
|
+
/\bon[A-Z]\w*\b/.test(clickValue);
|
|
484
|
+
if (!mutatesAffordance) continue;
|
|
485
|
+
if (SEMANTIC_PRIMITIVES.has(tag)) continue;
|
|
486
|
+
if (STATE_ARIA_OR_ROLE.test(block)) continue;
|
|
487
|
+
if (STATE_PRIMITIVE_IN_SUBTREE.test(subtree(src, end, tag))) continue;
|
|
488
|
+
const line = src.slice(0, m.index).split("\n").length;
|
|
489
|
+
if (flaggedLines.has(line)) continue;
|
|
490
|
+
flaggedLines.add(line);
|
|
491
|
+
issues.push(
|
|
492
|
+
mkIssue(
|
|
493
|
+
"state.ui_affordance.state_aria_present",
|
|
494
|
+
`Line ${line}: <${tag}> toggles the UI affordance from its onClick but exposes no state ARIA \u2014 its checked/selected/expanded state is invisible to assistive technology (styling is the only carrier).`,
|
|
495
|
+
`Add the matching state attribute to the SAME element that carries the onClick: \`role="checkbox"\` + \`aria-checked={\u2026}\` for a toggle row, \`aria-pressed\` for a toggle button, \`aria-selected\` for a selection, \`aria-expanded\` for an open/close affordance \u2014 or replace the hand-rolled control with the state-carrying primitive (Checkbox / Toggle / Tabs / Accordion). \`as={Clickable}\` adds button + keyboard semantics but NOT state.`
|
|
496
|
+
)
|
|
497
|
+
);
|
|
498
|
+
}
|
|
499
|
+
return issues;
|
|
500
|
+
}
|
|
501
|
+
var STATE_UI_AFFORDANCE_CHECKS = [
|
|
502
|
+
{
|
|
503
|
+
id: "state.ui_affordance.state_aria_present",
|
|
504
|
+
axis: "state",
|
|
505
|
+
values: ["ui-affordance"],
|
|
506
|
+
run: runStateAriaPresent
|
|
507
|
+
}
|
|
508
|
+
];
|
|
509
|
+
|
|
410
510
|
// src/evaluation/axis-checks/checks/realtime.ts
|
|
411
511
|
var REALTIME_ACTIVE = ["merge", "append", "status", "presence", "mixed"];
|
|
412
512
|
function runStreamHandlerPerEvent(input) {
|
|
@@ -1096,6 +1196,7 @@ var EXTRA_CHECKS = [
|
|
|
1096
1196
|
var REGISTRY = [
|
|
1097
1197
|
...UNIVERSAL_CHECKS,
|
|
1098
1198
|
...STATE_MERGE_CHECKS,
|
|
1199
|
+
...STATE_UI_AFFORDANCE_CHECKS,
|
|
1099
1200
|
...REALTIME_CHECKS,
|
|
1100
1201
|
...WRITES_CHECKS,
|
|
1101
1202
|
...STATE_PAYLOAD_CHECKS,
|