@ggui-ai/ui-gen 0.23.0 → 0.24.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 (67) hide show
  1. package/dist/adapter-Du7P_5Fx.d.ts +201 -0
  2. package/dist/adapters/generation-dispatch.d.ts +33 -12
  3. package/dist/adapters/generation-dispatch.js +510 -128
  4. package/dist/adapters/generation-dispatch.js.map +1 -1
  5. package/dist/adapters/index.js.map +1 -1
  6. package/dist/advanced/index.d.ts +5 -3
  7. package/dist/advanced/index.js +551 -142
  8. package/dist/advanced/index.js.map +1 -1
  9. package/dist/blueprint-validator.js +153 -59
  10. package/dist/blueprint-validator.js.map +1 -1
  11. package/dist/boilerplate.js.map +1 -1
  12. package/dist/check/index.d.ts +2 -1
  13. package/dist/check/index.js +47 -1
  14. package/dist/check/index.js.map +1 -1
  15. package/dist/{create-ui-generator-D0kbWwln.d.ts → create-ui-generator-GIhzx08x.d.ts} +34 -10
  16. package/dist/{dispatch-wxaIMwZt.d.ts → dispatch-BnAH56p4.d.ts} +1 -1
  17. package/dist/evaluation/axis-checks/index.d.ts +4 -3
  18. package/dist/evaluation/axis-checks/index.js.map +1 -1
  19. package/dist/evaluation/axis-checks/registry.d.ts +2 -1
  20. package/dist/evaluation/index.d.ts +4 -3
  21. package/dist/evaluation/index.js.map +1 -1
  22. package/dist/harness/check/runtime-render/index.d.ts +29 -10
  23. package/dist/harness/check/runtime-render/index.js +203 -60
  24. package/dist/harness/check/runtime-render/index.js.map +1 -1
  25. package/dist/harness/check/runtime-render/render-check-worker.d.ts +8 -1
  26. package/dist/harness/check/runtime-render/render-check-worker.js +72 -32
  27. package/dist/harness/check/runtime-render/render-check-worker.js.map +1 -1
  28. package/dist/harness/index.d.ts +2 -1
  29. package/dist/harness/index.js.map +1 -1
  30. package/dist/harness/prompts.js.map +1 -1
  31. package/dist/harness/result-types.d.ts +2 -1
  32. package/dist/harness/runtime.d.ts +2 -1
  33. package/dist/harness/runtime.js.map +1 -1
  34. package/dist/harness/types-public.d.ts +11 -2
  35. package/dist/harness/types-public.js.map +1 -1
  36. package/dist/harness/validator-trace-sink.d.ts +2 -1
  37. package/dist/index.d.ts +38 -3
  38. package/dist/index.js +553 -143
  39. package/dist/index.js.map +1 -1
  40. package/dist/patch.d.ts +2 -1
  41. package/dist/policy.d.ts +7 -4
  42. package/dist/policy.js.map +1 -1
  43. package/dist/tools/render-check-worker.d.ts +7 -1
  44. package/dist/tools/render-check-worker.js +55 -23
  45. package/dist/tools/render-check-worker.js.map +1 -1
  46. package/dist/{types-public-Ow-tNtFE.d.ts → types-public-Bk6d1WLN.d.ts} +77 -11
  47. package/dist/workflows.d.ts +2 -1
  48. package/package.json +12 -12
  49. package/src/adapters/generation-dispatch.ts +137 -96
  50. package/src/check/run-tier0.ts +80 -1
  51. package/src/create-ui-generator.ts +185 -95
  52. package/src/evaluation/types-public.ts +73 -11
  53. package/src/harness/check/runtime-render/adapter.ts +221 -75
  54. package/src/harness/check/runtime-render/index.ts +75 -2
  55. package/src/harness/check/runtime-render/render-check-host.ts +82 -19
  56. package/src/harness/check/runtime-render/render-check-worker.ts +83 -29
  57. package/src/harness/check/runtime-render/render-check.ts +154 -117
  58. package/src/harness/coding/generate-task-runner.ts +57 -4
  59. package/src/harness/coding/init-session.ts +13 -0
  60. package/src/harness/coding/run-eval-round.ts +238 -15
  61. package/src/harness/policy.ts +11 -0
  62. package/src/harness/primitive-slice.ts +104 -0
  63. package/src/harness/types-public.ts +9 -1
  64. package/src/index.ts +4 -0
  65. package/src/policy.ts +7 -4
  66. package/src/tools/render-check-worker.ts +74 -23
  67. package/dist/render-check-Blwj8gB6.d.ts +0 -105
@@ -28,7 +28,20 @@
28
28
  * (the render SMOKE worker): reached by spawn path, never by import
29
29
  * specifier; registered as a tsup entry so `dist/harness/check/
30
30
  * runtime-render/render-check-worker.js` ships.
31
+ *
32
+ * Shutdown (ggui#1380): the compile runs on esbuild's service, a child
33
+ * process esbuild keeps alive for the life of this worker. After the
34
+ * verdict is written the worker calls `esbuild.stop()` so that child is
35
+ * gone before the worker is; a worker stopped at its wall-clock bound is
36
+ * killed by the host, and the service's stdin closing with it is what
37
+ * ends the service in that case. `workerMain` is exported for the
38
+ * process-shape pins; `main()` runs only when this file is the process
39
+ * entry, so importing it never reads stdin.
31
40
  */
41
+ import { realpathSync } from 'node:fs';
42
+ import { resolve as resolvePath } from 'node:path';
43
+ import { fileURLToPath } from 'node:url';
44
+ import * as esbuild from 'esbuild';
32
45
  import { runRenderCheckInProcess } from './render-check.js';
33
46
  import type { RunRenderCheckInput } from './render-check.js';
34
47
 
@@ -44,37 +57,78 @@ function emit(value: unknown): void {
44
57
  process.stdout.write(`${JSON.stringify(value)}\n`);
45
58
  }
46
59
 
47
- async function main(): Promise<void> {
48
- const raw = await readAllStdin();
49
- let input: RunRenderCheckInput;
60
+ /**
61
+ * Parse one input document, run the check, write the verdict. Whatever
62
+ * happens after parsing, esbuild's service is stopped before this
63
+ * returns (or rejects). If the service was never started, `stop()` is a
64
+ * no-op.
65
+ */
66
+ export async function workerMain(raw: string): Promise<void> {
50
67
  try {
51
- input = JSON.parse(raw) as RunRenderCheckInput;
52
- } catch (err) {
53
- process.stderr.write(
54
- `render-check worker: malformed input JSON — ${
55
- err instanceof Error ? err.message : String(err)
56
- }\n`,
57
- );
58
- process.exitCode = 1;
59
- return;
60
- }
61
- if (typeof input.sourceCode !== 'string' || input.sourceCode.length === 0) {
62
- process.stderr.write(
63
- 'render-check worker: input.sourceCode must be a non-empty string\n',
64
- );
65
- process.exitCode = 1;
66
- return;
68
+ let input: RunRenderCheckInput;
69
+ try {
70
+ input = JSON.parse(raw) as RunRenderCheckInput;
71
+ } catch (err) {
72
+ process.stderr.write(
73
+ `render-check worker: malformed input JSON — ${
74
+ err instanceof Error ? err.message : String(err)
75
+ }\n`,
76
+ );
77
+ process.exitCode = 1;
78
+ return;
79
+ }
80
+ if (typeof input.sourceCode !== 'string' || input.sourceCode.length === 0) {
81
+ process.stderr.write(
82
+ 'render-check worker: input.sourceCode must be a non-empty string\n',
83
+ );
84
+ process.exitCode = 1;
85
+ return;
86
+ }
87
+
88
+ // The in-process check never throws for component failures (they are
89
+ // reported as issues); an escape here is a harness defect — let it
90
+ // crash the worker so the host maps it to `unverified` with the
91
+ // stderr tail as the reason.
92
+ const result = await runRenderCheckInProcess(input);
93
+ emit(result);
94
+ // The check's async-infra grace period (React scheduler drain) holds
95
+ // handlers for ~100ms; exit through the event loop naturally so that
96
+ // drain completes inside the worker instead of leaking crashes.
97
+ } finally {
98
+ // Post-verdict work must never turn a written verdict into a failure:
99
+ // a rejecting `stop()` would otherwise become an unhandled rejection,
100
+ // exit code 1, and the host discarding the verdict on stdout.
101
+ try {
102
+ await esbuild.stop();
103
+ } catch (err) {
104
+ process.stderr.write(
105
+ `render-check worker: esbuild.stop() failed — ${err instanceof Error ? err.message : String(err)}\n`,
106
+ );
107
+ }
67
108
  }
109
+ }
68
110
 
69
- // The in-process check never throws for component failures (they are
70
- // reported as issues); an escape here is a harness defect — let it
71
- // crash the worker so the host maps it to `unverified` with the
72
- // stderr tail as the reason.
73
- const result = await runRenderCheckInProcess(input);
74
- emit(result);
75
- // The check's async-infra grace period (React scheduler drain) holds
76
- // handlers for ~100ms; exit through the event loop naturally so that
77
- // drain completes inside the worker instead of leaking crashes.
111
+ async function main(): Promise<void> {
112
+ await workerMain(await readAllStdin());
113
+ }
114
+
115
+ /** True when this file is the process entry (`node <this file>`), not an import. */
116
+ function isProcessEntry(): boolean {
117
+ const entry = process.argv[1];
118
+ if (entry === undefined) return false;
119
+ // Resolve BOTH sides through the filesystem: `import.meta.url` is this
120
+ // file's realpath while argv[1] is whatever the spawner passed — a
121
+ // symlinked spawn path must still read as the entry, or the worker would
122
+ // exit with no verdict and the host would read a silent `unverified`.
123
+ let entryReal: string;
124
+ try {
125
+ entryReal = realpathSync(resolvePath(entry));
126
+ } catch {
127
+ return false;
128
+ }
129
+ return entryReal === realpathSync(fileURLToPath(import.meta.url));
78
130
  }
79
131
 
80
- void main();
132
+ if (isProcessEntry()) {
133
+ void main();
134
+ }