@ggui-ai/ui-gen 0.9.0 → 0.11.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.
Files changed (92) hide show
  1. package/dist/adapters/generation-dispatch.d.ts +9 -2
  2. package/dist/adapters/generation-dispatch.js +693 -89
  3. package/dist/adapters/generation-dispatch.js.map +1 -1
  4. package/dist/adapters/index.js +28 -11
  5. package/dist/adapters/index.js.map +1 -1
  6. package/dist/advanced/index.d.ts +5 -3
  7. package/dist/advanced/index.js +714 -101
  8. package/dist/advanced/index.js.map +1 -1
  9. package/dist/blueprint-validator.js +267 -3
  10. package/dist/blueprint-validator.js.map +1 -1
  11. package/dist/boilerplate.js +14 -2
  12. package/dist/boilerplate.js.map +1 -1
  13. package/dist/check/index.d.ts +1 -1
  14. package/dist/check/index.js +11 -1
  15. package/dist/check/index.js.map +1 -1
  16. package/dist/{create-ui-generator-B9kV4U9h.d.ts → create-ui-generator-CF0EL0Li.d.ts} +13 -1
  17. package/dist/{dispatch-Deo9qzrG.d.ts → dispatch-D75M-OfZ.d.ts} +1 -1
  18. package/dist/evaluation/axis-checks/index.d.ts +3 -3
  19. package/dist/evaluation/axis-checks/index.js +101 -0
  20. package/dist/evaluation/axis-checks/index.js.map +1 -1
  21. package/dist/evaluation/axis-checks/registry.d.ts +1 -1
  22. package/dist/evaluation/axis-checks/registry.js +101 -0
  23. package/dist/evaluation/axis-checks/registry.js.map +1 -1
  24. package/dist/evaluation/index.d.ts +46 -3
  25. package/dist/evaluation/index.js +358 -17
  26. package/dist/evaluation/index.js.map +1 -1
  27. package/dist/harness/check/runtime-render/index.d.ts +2 -2
  28. package/dist/harness/check/runtime-render/index.js +268 -3
  29. package/dist/harness/check/runtime-render/index.js.map +1 -1
  30. package/dist/harness/check/runtime-render/render-check-worker.d.ts +2 -0
  31. package/dist/harness/check/runtime-render/render-check-worker.js +1332 -0
  32. package/dist/harness/check/runtime-render/render-check-worker.js.map +1 -0
  33. package/dist/harness/index.d.ts +2 -2
  34. package/dist/harness/index.js +263 -18
  35. package/dist/harness/index.js.map +1 -1
  36. package/dist/harness/llm-trace-sink.d.ts +1 -1
  37. package/dist/harness/llm-trace-sink.js.map +1 -1
  38. package/dist/harness/prompts.js +17 -3
  39. package/dist/harness/prompts.js.map +1 -1
  40. package/dist/harness/result-types.d.ts +1 -1
  41. package/dist/harness/runtime.d.ts +9 -2
  42. package/dist/harness/runtime.js +20 -6
  43. package/dist/harness/runtime.js.map +1 -1
  44. package/dist/harness/types-public.d.ts +1 -1
  45. package/dist/harness/types-public.js +14 -2
  46. package/dist/harness/types-public.js.map +1 -1
  47. package/dist/harness/validator-trace-sink.d.ts +1 -1
  48. package/dist/index.d.ts +5 -3
  49. package/dist/index.js +708 -95
  50. package/dist/index.js.map +1 -1
  51. package/dist/{llm-router-1TyI0_TV.d.ts → llm-router-BEVtbAb9.d.ts} +61 -4
  52. package/dist/patch.d.ts +1 -1
  53. package/dist/provider-adapter.d.ts +16 -6
  54. package/dist/provider-adapter.js.map +1 -1
  55. package/dist/providers/index.d.ts +19 -6
  56. package/dist/providers/index.js.map +1 -1
  57. package/dist/{render-check-CNZjHD5g.d.ts → render-check-BZoIE8-u.d.ts} +21 -1
  58. package/dist/{types-public-C36k1q6s.d.ts → types-public-DIpjC-OA.d.ts} +1 -1
  59. package/dist/workflows.d.ts +1 -1
  60. package/package.json +12 -12
  61. package/src/adapters/generation-dispatch.ts +9 -0
  62. package/src/adapters/openrouter/client.ts +2 -2
  63. package/src/adapters/openrouter/types.ts +10 -0
  64. package/src/boilerplate/generate.ts +10 -2
  65. package/src/boilerplate/json-schema-ts.ts +22 -2
  66. package/src/boilerplate/system-prompt.ts +1 -0
  67. package/src/compile.ts +1 -1
  68. package/src/contract-context.ts +10 -2
  69. package/src/create-ui-generator.ts +14 -0
  70. package/src/design-system-docs.ts +6 -4
  71. package/src/evaluation/axis-checks/checks/state-ui-affordance.ts +162 -0
  72. package/src/evaluation/axis-checks/registry.ts +2 -0
  73. package/src/evaluation/index.ts +11 -0
  74. package/src/evaluation/llm-evaluator.ts +14 -1
  75. package/src/evaluation/visual-evaluator.ts +44 -65
  76. package/src/harness/check/runtime-render/adapter.ts +18 -0
  77. package/src/harness/check/runtime-render/index.ts +8 -0
  78. package/src/harness/check/runtime-render/prepare-mockup.ts +14 -0
  79. package/src/harness/check/runtime-render/production-act-shim.ts +158 -0
  80. package/src/harness/check/runtime-render/render-check-host.ts +201 -0
  81. package/src/harness/check/runtime-render/render-check-worker.ts +80 -0
  82. package/src/harness/check/runtime-render/render-check.ts +112 -1
  83. package/src/harness/coding/run-eval-round.ts +61 -5
  84. package/src/harness/index.ts +1 -1
  85. package/src/harness/llm-router.ts +397 -18
  86. package/src/harness/llm-trace-sink.ts +2 -1
  87. package/src/harness/runtime.ts +7 -0
  88. package/src/index.ts +5 -5
  89. package/src/provider-adapter.ts +16 -6
  90. package/src/providers/bedrock.ts +5 -4
  91. package/src/providers/index.ts +16 -4
  92. package/src/tools/render-check.ts +19 -7
@@ -1,7 +1,7 @@
1
1
  import * as _ggui_ai_protocol from '@ggui-ai/protocol';
2
2
  import { JsonValue, DataContract, JsonObject, GadgetDescriptor } from '@ggui-ai/protocol';
3
3
  import { C as Classification } from '../axes-CzLEMDeB.js';
4
- import { E as EvalIssue, R as RuntimeProbeStatus, A as AxisCheck, f as EvalTier } from '../types-public-C36k1q6s.js';
4
+ import { E as EvalIssue, R as RuntimeProbeStatus, A as AxisCheck, c as EvalTier } from '../types-public-DIpjC-OA.js';
5
5
  import { LLMToolDef } from '../llm.js';
6
6
  import { H as HarnessFragment, a as CacheTier } from '../types-BOvHNG7K.js';
7
7
  import { ProcessMode, HarnessPolicy } from '../policy.js';
@@ -711,6 +711,15 @@ function jsonSchemaTypeToTs(schema) {
711
711
  if (schema.enum?.length) {
712
712
  return schema.enum.map((v) => typeof v === "string" ? `'${v}'` : String(v)).join(" | ");
713
713
  }
714
+ if (Array.isArray(schema.type)) {
715
+ const { nullable: _nullable, ...rest } = schema;
716
+ const members = [...new Set(schema.type)].map(
717
+ (member) => jsonSchemaTypeToTs({ ...rest, type: member })
718
+ );
719
+ const unique = [...new Set(members)];
720
+ if (schema.nullable && !unique.includes("null")) unique.push("null");
721
+ return unique.join(" | ");
722
+ }
714
723
  let result;
715
724
  switch (schema.type) {
716
725
  case "string":
@@ -728,7 +737,8 @@ function jsonSchemaTypeToTs(schema) {
728
737
  case "array": {
729
738
  if (schema.items) {
730
739
  const itemType = jsonSchemaTypeToTs(schema.items);
731
- result = schema.items.type === "object" && schema.items.properties ? `Array<${itemType}>` : itemType.includes("|") ? `(${itemType})[]` : `${itemType}[]`;
740
+ const itemsDeclareObject = Array.isArray(schema.items.type) ? schema.items.type.includes("object") : schema.items.type === "object";
741
+ result = itemsDeclareObject && schema.items.properties ? `Array<${itemType}>` : itemType.includes("|") ? `(${itemType})[]` : `${itemType}[]`;
732
742
  } else {
733
743
  result = "unknown[]";
734
744
  }
@@ -861,13 +871,14 @@ function generateBoilerplate(_userPrompt, contract, shellType, screen, composedS
861
871
  const propsFields = [];
862
872
  const propsProperties = contract?.propsSpec?.properties ?? {};
863
873
  for (const [key, entry] of Object.entries(propsProperties)) {
864
- const required = entry.required !== false;
874
+ const required = entry.required === true;
865
875
  const nullable = entry.schema.nullable === true;
866
876
  const tsType = jsonSchemaTypeToTs(entry.schema);
867
877
  const fullType = nullable ? `${tsType} | null` : tsType;
868
878
  const parts = [];
869
879
  if (entry.description) parts.push(entry.description);
870
880
  if (entry.default !== void 0) parts.push(`(default: ${JSON.stringify(entry.default)})`);
881
+ if (!required) parts.push("(optional \u2014 the agent may omit it; guard or fall back)");
871
882
  const desc = parts.length > 0 ? ` // ${parts.join(" ")}` : "";
872
883
  propsFields.push(` ${key}${required ? "" : "?"}: ${fullType};${desc}`);
873
884
  }
@@ -1615,6 +1626,7 @@ A \`DataContract\` declares everything a GguiSession exchanges with the outside
1615
1626
 
1616
1627
  Props arrive at mount and may be partial on first render; later prop changes reach the SAME mounted component via \`ggui_amend\` (in-place repaint) on the live channel. Stream channels start empty and fill over time. Context slots start at their declared default (often \`null\`). **Never assume a field exists before you read it.**
1617
1628
 
1629
+ - **Optional contract props**: a \`Props\` field marked \`?\` in the boilerplate may be omitted by the agent ENTIRELY \u2014 the wire gate only enforces \`required: true\` entries, and the harness verifies your component with those props stripped. Guard them (\`?? default\`, \`?.\`, or an empty-state branch) from the FIRST render.
1618
1630
  - **Array iteration**: always default to \`[]\` before \`.map\`/\`.filter\`/\`.length\`. Use \`(props.items ?? []).map(...)\` not \`props.items.map(...)\`. Same for stream.all, stream.latest, etc.
1619
1631
  - **Object access**: optional-chain through nested fields. \`props.user?.name ?? 'Anonymous'\` not \`props.user.name\`.
1620
1632
  - **Number ops**: default before arithmetic. \`(props.count ?? 0) + 1\` not \`props.count + 1\`.