@ggui-ai/ui-gen 0.10.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.
- package/dist/adapters/generation-dispatch.js +148 -6
- package/dist/adapters/generation-dispatch.js.map +1 -1
- package/dist/advanced/index.d.ts +1 -1
- package/dist/advanced/index.js +153 -11
- package/dist/advanced/index.js.map +1 -1
- package/dist/blueprint-validator.js +161 -3
- package/dist/blueprint-validator.js.map +1 -1
- package/dist/harness/check/runtime-render/index.d.ts +1 -1
- package/dist/harness/check/runtime-render/index.js +161 -3
- package/dist/harness/check/runtime-render/index.js.map +1 -1
- package/dist/harness/check/runtime-render/render-check-worker.d.ts +2 -0
- package/dist/harness/check/runtime-render/render-check-worker.js +1332 -0
- package/dist/harness/check/runtime-render/render-check-worker.js.map +1 -0
- package/dist/index.js +147 -5
- package/dist/index.js.map +1 -1
- package/dist/{render-check-BNYGVDJd.d.ts → render-check-BZoIE8-u.d.ts} +20 -0
- package/package.json +12 -12
- package/src/harness/check/runtime-render/render-check-host.ts +201 -0
- package/src/harness/check/runtime-render/render-check-worker.ts +80 -0
- package/src/harness/check/runtime-render/render-check.ts +40 -0
|
@@ -3,11 +3,13 @@ import 'zod';
|
|
|
3
3
|
import { classifyUi, MODEL_REGISTRY, DANGEROUS_PATTERNS as DANGEROUS_PATTERNS$1, listContractGadgets, HOOK_NAME_RE, STDLIB_GADGETS_PACKAGE, resolveAppGadgets } from '@ggui-ai/protocol';
|
|
4
4
|
import * as esbuild from 'esbuild';
|
|
5
5
|
import { build } from 'esbuild';
|
|
6
|
-
import fs, { mkdirSync, writeFileSync, unlinkSync,
|
|
6
|
+
import fs, { mkdirSync, writeFileSync, unlinkSync, existsSync, readFileSync, rm, createReadStream, createWriteStream } from 'fs';
|
|
7
7
|
import { contentHash } from '@ggui-ai/protocol/content-hash';
|
|
8
|
+
import { createRequire } from 'module';
|
|
9
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
10
|
+
import { runSandboxed } from '@ggui-ai/sandbox';
|
|
8
11
|
import ts2 from 'typescript';
|
|
9
12
|
import path, { dirname, resolve, join, basename } from 'path';
|
|
10
|
-
import { createRequire } from 'module';
|
|
11
13
|
import { Linter } from 'eslint';
|
|
12
14
|
import { createHash } from 'crypto';
|
|
13
15
|
import 'fs/promises';
|
|
@@ -15,8 +17,6 @@ import { tmpdir } from 'os';
|
|
|
15
17
|
import { Readable } from 'stream';
|
|
16
18
|
import { pipeline } from 'stream/promises';
|
|
17
19
|
import { createBrotliDecompress, createUnzip } from 'zlib';
|
|
18
|
-
import { fileURLToPath } from 'url';
|
|
19
|
-
import '@ggui-ai/sandbox';
|
|
20
20
|
import git from 'isomorphic-git';
|
|
21
21
|
import { Volume, createFsFromVolume } from 'memfs';
|
|
22
22
|
import { createPatch, applyPatch } from 'diff';
|
|
@@ -2555,6 +2555,140 @@ var init_validation = __esm({
|
|
|
2555
2555
|
init_ui_compiler();
|
|
2556
2556
|
}
|
|
2557
2557
|
});
|
|
2558
|
+
|
|
2559
|
+
// src/harness/check/runtime-render/render-check-host.ts
|
|
2560
|
+
var render_check_host_exports = {};
|
|
2561
|
+
__export(render_check_host_exports, {
|
|
2562
|
+
mapSandboxResultToCheckResult: () => mapSandboxResultToCheckResult,
|
|
2563
|
+
runRenderCheckViaWorker: () => runRenderCheckViaWorker
|
|
2564
|
+
});
|
|
2565
|
+
function resolveWorkerSpawn() {
|
|
2566
|
+
const jsCandidates = [
|
|
2567
|
+
// Sibling — when import.meta.url is already .../harness/check/runtime-render/.
|
|
2568
|
+
new URL(`./${WORKER_BASENAME}.js`, import.meta.url),
|
|
2569
|
+
// From dist/index.js.
|
|
2570
|
+
new URL(`./harness/check/runtime-render/${WORKER_BASENAME}.js`, import.meta.url),
|
|
2571
|
+
// From dist/harness/index.js.
|
|
2572
|
+
new URL(`./check/runtime-render/${WORKER_BASENAME}.js`, import.meta.url),
|
|
2573
|
+
// From dist/check/index.js, dist/advanced/index.js, dist/<flat>.js.
|
|
2574
|
+
new URL(`../harness/check/runtime-render/${WORKER_BASENAME}.js`, import.meta.url)
|
|
2575
|
+
];
|
|
2576
|
+
for (const jsUrl of jsCandidates) {
|
|
2577
|
+
const jsPath = fileURLToPath(jsUrl);
|
|
2578
|
+
if (existsSync(jsPath)) {
|
|
2579
|
+
return { command: process.execPath, args: [jsPath] };
|
|
2580
|
+
}
|
|
2581
|
+
}
|
|
2582
|
+
const tsCandidates = [
|
|
2583
|
+
new URL(`./${WORKER_BASENAME}.ts`, import.meta.url),
|
|
2584
|
+
new URL(`../harness/check/runtime-render/${WORKER_BASENAME}.ts`, import.meta.url)
|
|
2585
|
+
];
|
|
2586
|
+
for (const tsUrl of tsCandidates) {
|
|
2587
|
+
const tsPath = fileURLToPath(tsUrl);
|
|
2588
|
+
if (existsSync(tsPath)) {
|
|
2589
|
+
const require_ = createRequire(import.meta.url);
|
|
2590
|
+
const tsxLoader = pathToFileURL(require_.resolve("tsx")).href;
|
|
2591
|
+
return { command: process.execPath, args: ["--import", tsxLoader, tsPath] };
|
|
2592
|
+
}
|
|
2593
|
+
}
|
|
2594
|
+
const tried = [...jsCandidates, ...tsCandidates].map((u) => fileURLToPath(u)).join(", ");
|
|
2595
|
+
throw new Error(
|
|
2596
|
+
`render-check: isolated worker not found at any of: ${tried}. Did \`pnpm build\` run?`
|
|
2597
|
+
);
|
|
2598
|
+
}
|
|
2599
|
+
function failed(reason, t0) {
|
|
2600
|
+
return {
|
|
2601
|
+
ok: false,
|
|
2602
|
+
issues: [{ check: "render-no-throw", outcome: "failed", reason }],
|
|
2603
|
+
stats: { actionsChecked: 0, streamsChecked: 0, renderMs: Date.now() - t0 }
|
|
2604
|
+
};
|
|
2605
|
+
}
|
|
2606
|
+
function unverified(reason, t0) {
|
|
2607
|
+
return {
|
|
2608
|
+
ok: false,
|
|
2609
|
+
issues: [{ check: "render-no-throw", outcome: "unverified", reason }],
|
|
2610
|
+
stats: { actionsChecked: 0, streamsChecked: 0, renderMs: Date.now() - t0 }
|
|
2611
|
+
};
|
|
2612
|
+
}
|
|
2613
|
+
function mapSandboxResultToCheckResult(result, t0) {
|
|
2614
|
+
if (result.outcome === "timeout") {
|
|
2615
|
+
return failed(
|
|
2616
|
+
`render check timed out after ${CHECK_TIMEOUT_MS}ms in the isolated worker (likely infinite loop or runaway effect in the component).`,
|
|
2617
|
+
t0
|
|
2618
|
+
);
|
|
2619
|
+
}
|
|
2620
|
+
if (result.outcome === "overflow-stdout" || result.outcome === "overflow-stderr") {
|
|
2621
|
+
return failed(
|
|
2622
|
+
`render check worker produced excessive output (${result.outcome}) \u2014 the component is likely in a pathological logging or error loop.`,
|
|
2623
|
+
t0
|
|
2624
|
+
);
|
|
2625
|
+
}
|
|
2626
|
+
if (result.outcome === "spawn-error") {
|
|
2627
|
+
return unverified(
|
|
2628
|
+
`render check worker failed to start \u2014 ${result.errorMessage}`,
|
|
2629
|
+
t0
|
|
2630
|
+
);
|
|
2631
|
+
}
|
|
2632
|
+
if (result.outcome === "canceled") {
|
|
2633
|
+
return unverified("render check worker was canceled before completing.", t0);
|
|
2634
|
+
}
|
|
2635
|
+
if (result.outcome !== "exit") {
|
|
2636
|
+
return unverified(
|
|
2637
|
+
`render check worker ended with unexpected sandbox outcome '${result.outcome}'.`,
|
|
2638
|
+
t0
|
|
2639
|
+
);
|
|
2640
|
+
}
|
|
2641
|
+
if (result.exitCode !== 0) {
|
|
2642
|
+
const tail = result.stderr.trim() || result.stdout.trim();
|
|
2643
|
+
return unverified(
|
|
2644
|
+
`render check worker exited ${result.exitCode}${tail ? ` \u2014 ${tail.slice(0, 600)}` : ""}`,
|
|
2645
|
+
t0
|
|
2646
|
+
);
|
|
2647
|
+
}
|
|
2648
|
+
const stdout = result.stdout.trim();
|
|
2649
|
+
if (stdout.length === 0) {
|
|
2650
|
+
return unverified("render check worker exited without producing a verdict.", t0);
|
|
2651
|
+
}
|
|
2652
|
+
try {
|
|
2653
|
+
return JSON.parse(stdout);
|
|
2654
|
+
} catch (err) {
|
|
2655
|
+
return unverified(
|
|
2656
|
+
`render check worker verdict was not valid JSON \u2014 ${err instanceof Error ? err.message : String(err)}`,
|
|
2657
|
+
t0
|
|
2658
|
+
);
|
|
2659
|
+
}
|
|
2660
|
+
}
|
|
2661
|
+
async function runRenderCheckViaWorker(input) {
|
|
2662
|
+
const t0 = Date.now();
|
|
2663
|
+
let spawn;
|
|
2664
|
+
try {
|
|
2665
|
+
spawn = resolveWorkerSpawn();
|
|
2666
|
+
} catch (err) {
|
|
2667
|
+
return unverified(err instanceof Error ? err.message : String(err), t0);
|
|
2668
|
+
}
|
|
2669
|
+
const result = await runSandboxed({
|
|
2670
|
+
command: spawn.command,
|
|
2671
|
+
args: spawn.args,
|
|
2672
|
+
timeoutMs: CHECK_TIMEOUT_MS,
|
|
2673
|
+
maxStdoutBytes: CHECK_STDOUT_CAP,
|
|
2674
|
+
nodeHeapMb: CHECK_NODE_HEAP_MB,
|
|
2675
|
+
stdin: JSON.stringify(input),
|
|
2676
|
+
// NODE_ENV steers React's production vs development build — keep
|
|
2677
|
+
// parity with the caller; everything else stays on the sandbox's
|
|
2678
|
+
// default allowlist.
|
|
2679
|
+
env: { NODE_ENV: process.env.NODE_ENV ?? "production" }
|
|
2680
|
+
});
|
|
2681
|
+
return mapSandboxResultToCheckResult(result, t0);
|
|
2682
|
+
}
|
|
2683
|
+
var CHECK_TIMEOUT_MS, CHECK_STDOUT_CAP, CHECK_NODE_HEAP_MB, WORKER_BASENAME;
|
|
2684
|
+
var init_render_check_host = __esm({
|
|
2685
|
+
"src/harness/check/runtime-render/render-check-host.ts"() {
|
|
2686
|
+
CHECK_TIMEOUT_MS = 3e4;
|
|
2687
|
+
CHECK_STDOUT_CAP = 2 * 1024 * 1024;
|
|
2688
|
+
CHECK_NODE_HEAP_MB = 512;
|
|
2689
|
+
WORKER_BASENAME = "render-check-worker";
|
|
2690
|
+
}
|
|
2691
|
+
});
|
|
2558
2692
|
function extractWireCallSites(code) {
|
|
2559
2693
|
const sf = ts2.createSourceFile(
|
|
2560
2694
|
"component.tsx",
|
|
@@ -13546,8 +13680,8 @@ ${cjsResult.code}
|
|
|
13546
13680
|
// src/harness/check/runtime-render/load-component.ts
|
|
13547
13681
|
async function loadComponent(input) {
|
|
13548
13682
|
const { sourceCode, moduleResolutions = {} } = input;
|
|
13549
|
-
const { createRequire:
|
|
13550
|
-
const require_ =
|
|
13683
|
+
const { createRequire: createRequire5 } = await import('module');
|
|
13684
|
+
const require_ = createRequire5(import.meta.url);
|
|
13551
13685
|
const sandboxRequire = (id) => {
|
|
13552
13686
|
if (id in moduleResolutions) return moduleResolutions[id];
|
|
13553
13687
|
if (id === "react/jsx-runtime" || id === "react/jsx-dev-runtime") {
|
|
@@ -13906,6 +14040,14 @@ function parentLink(node) {
|
|
|
13906
14040
|
|
|
13907
14041
|
// src/harness/check/runtime-render/render-check.ts
|
|
13908
14042
|
async function runRenderCheck(input) {
|
|
14043
|
+
const g = hostGlobals();
|
|
14044
|
+
if ("window" in g && "document" in g) {
|
|
14045
|
+
return runRenderCheckInProcess(input);
|
|
14046
|
+
}
|
|
14047
|
+
const { runRenderCheckViaWorker: runRenderCheckViaWorker2 } = await Promise.resolve().then(() => (init_render_check_host(), render_check_host_exports));
|
|
14048
|
+
return runRenderCheckViaWorker2(input);
|
|
14049
|
+
}
|
|
14050
|
+
async function runRenderCheckInProcess(input) {
|
|
13909
14051
|
const t0 = Date.now();
|
|
13910
14052
|
const issues = [];
|
|
13911
14053
|
const teardown = await setupHappyDom();
|