@ggui-ai/ui-gen 0.28.0 → 0.29.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/{adapter-h4_V69LI.d.ts → adapter-DLQ-5COm.d.ts} +1 -1
- package/dist/adapters/base.js +2 -27
- package/dist/adapters/base.js.map +1 -1
- package/dist/adapters/generation-dispatch.d.ts +14 -6
- package/dist/adapters/generation-dispatch.js +40 -19260
- package/dist/adapters/generation-dispatch.js.map +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.js +25 -3561
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/types.js +2 -9
- package/dist/adapters/types.js.map +1 -1
- package/dist/advanced/index.d.ts +13 -12
- package/dist/advanced/index.js +63 -21954
- package/dist/advanced/index.js.map +1 -1
- package/dist/{bank-Ctdp3FUA.d.ts → bank-LWaiAtaA.d.ts} +1 -1
- package/dist/blueprint-validator.js +6 -2301
- package/dist/blueprint-validator.js.map +1 -1
- package/dist/boilerplate.d.ts +3 -2
- package/dist/boilerplate.js +6 -1867
- package/dist/boilerplate.js.map +1 -1
- package/dist/check/index.d.ts +3 -2
- package/dist/check/index.js +6 -1923
- package/dist/check/index.js.map +1 -1
- package/dist/chunk-33B3BAWS.js +24 -0
- package/dist/chunk-33B3BAWS.js.map +1 -0
- package/dist/chunk-3HSGA6NI.js +591 -0
- package/dist/chunk-3HSGA6NI.js.map +1 -0
- package/dist/chunk-3NNNGNTO.js +1707 -0
- package/dist/chunk-3NNNGNTO.js.map +1 -0
- package/dist/chunk-3T2HMTON.js +79 -0
- package/dist/chunk-3T2HMTON.js.map +1 -0
- package/dist/chunk-3ZSSDV3L.js +123 -0
- package/dist/chunk-3ZSSDV3L.js.map +1 -0
- package/dist/chunk-4MBR5GA3.js +99 -0
- package/dist/chunk-4MBR5GA3.js.map +1 -0
- package/dist/chunk-56NJFD55.js +337 -0
- package/dist/chunk-56NJFD55.js.map +1 -0
- package/dist/chunk-5AGTY555.js +26 -0
- package/dist/chunk-5AGTY555.js.map +1 -0
- package/dist/chunk-5EJM7EGY.js +115 -0
- package/dist/chunk-5EJM7EGY.js.map +1 -0
- package/dist/chunk-5KXCQLLR.js +529 -0
- package/dist/chunk-5KXCQLLR.js.map +1 -0
- package/dist/chunk-5VBXHVEH.js +171 -0
- package/dist/chunk-5VBXHVEH.js.map +1 -0
- package/dist/chunk-6KDDEING.js +515 -0
- package/dist/chunk-6KDDEING.js.map +1 -0
- package/dist/chunk-6VDRWAP6.js +123 -0
- package/dist/chunk-6VDRWAP6.js.map +1 -0
- package/dist/chunk-732IBFEJ.js +2400 -0
- package/dist/chunk-732IBFEJ.js.map +1 -0
- package/dist/chunk-73AURS3I.js +46 -0
- package/dist/chunk-73AURS3I.js.map +1 -0
- package/dist/chunk-77H5SKLX.js +8 -0
- package/dist/chunk-77H5SKLX.js.map +1 -0
- package/dist/chunk-7QE3AHLE.js +35 -0
- package/dist/chunk-7QE3AHLE.js.map +1 -0
- package/dist/chunk-A375NNWN.js +11 -0
- package/dist/chunk-A375NNWN.js.map +1 -0
- package/dist/chunk-AOU33EFS.js +140 -0
- package/dist/chunk-AOU33EFS.js.map +1 -0
- package/dist/chunk-BA4QYA6E.js +461 -0
- package/dist/chunk-BA4QYA6E.js.map +1 -0
- package/dist/chunk-DBP764GL.js +3 -0
- package/dist/chunk-DBP764GL.js.map +1 -0
- package/dist/chunk-DUU3ZJDQ.js +41 -0
- package/dist/chunk-DUU3ZJDQ.js.map +1 -0
- package/dist/chunk-DXKRBXNU.js +30 -0
- package/dist/chunk-DXKRBXNU.js.map +1 -0
- package/dist/chunk-FB7OEEAH.js +1467 -0
- package/dist/chunk-FB7OEEAH.js.map +1 -0
- package/dist/chunk-FLRNMZV2.js +18 -0
- package/dist/chunk-FLRNMZV2.js.map +1 -0
- package/dist/chunk-FWJIMKFZ.js +2032 -0
- package/dist/chunk-FWJIMKFZ.js.map +1 -0
- package/dist/chunk-FXRHWYIQ.js +163 -0
- package/dist/chunk-FXRHWYIQ.js.map +1 -0
- package/dist/chunk-G3PMV62Z.js +33 -0
- package/dist/chunk-G3PMV62Z.js.map +1 -0
- package/dist/chunk-GAJI7Y3P.js +13 -0
- package/dist/chunk-GAJI7Y3P.js.map +1 -0
- package/dist/chunk-GYINWMPR.js +2052 -0
- package/dist/chunk-GYINWMPR.js.map +1 -0
- package/dist/chunk-HD6ABIK7.js +484 -0
- package/dist/chunk-HD6ABIK7.js.map +1 -0
- package/dist/chunk-HDQVHYO6.js +100 -0
- package/dist/chunk-HDQVHYO6.js.map +1 -0
- package/dist/chunk-IHUT3SIW.js +7 -0
- package/dist/chunk-IHUT3SIW.js.map +1 -0
- package/dist/chunk-JDH5EGNZ.js +126 -0
- package/dist/chunk-JDH5EGNZ.js.map +1 -0
- package/dist/chunk-JMD4RGSV.js +37 -0
- package/dist/chunk-JMD4RGSV.js.map +1 -0
- package/dist/chunk-KJWGZL5B.js +33 -0
- package/dist/chunk-KJWGZL5B.js.map +1 -0
- package/dist/chunk-MKMDQFZ7.js +86 -0
- package/dist/chunk-MKMDQFZ7.js.map +1 -0
- package/dist/chunk-NF6JUZWF.js +85 -0
- package/dist/chunk-NF6JUZWF.js.map +1 -0
- package/dist/chunk-O2YC6XDC.js +1933 -0
- package/dist/chunk-O2YC6XDC.js.map +1 -0
- package/dist/chunk-OVLH5ICV.js +29 -0
- package/dist/chunk-OVLH5ICV.js.map +1 -0
- package/dist/chunk-PBOYHGSD.js +106 -0
- package/dist/chunk-PBOYHGSD.js.map +1 -0
- package/dist/chunk-PJFH7QWA.js +81 -0
- package/dist/chunk-PJFH7QWA.js.map +1 -0
- package/dist/chunk-PUH4CXGZ.js +284 -0
- package/dist/chunk-PUH4CXGZ.js.map +1 -0
- package/dist/chunk-QLXXPGTV.js +18 -0
- package/dist/chunk-QLXXPGTV.js.map +1 -0
- package/dist/chunk-R5GIGPW2.js +2845 -0
- package/dist/chunk-R5GIGPW2.js.map +1 -0
- package/dist/chunk-RH4IUSTO.js +83 -0
- package/dist/chunk-RH4IUSTO.js.map +1 -0
- package/dist/chunk-S2GVXKKY.js +153 -0
- package/dist/chunk-S2GVXKKY.js.map +1 -0
- package/dist/chunk-TVHGKFJS.js +58 -0
- package/dist/chunk-TVHGKFJS.js.map +1 -0
- package/dist/chunk-U7GALWLG.js +66 -0
- package/dist/chunk-U7GALWLG.js.map +1 -0
- package/dist/chunk-VTC263LT.js +256 -0
- package/dist/chunk-VTC263LT.js.map +1 -0
- package/dist/chunk-WEOXFEVE.js +739 -0
- package/dist/chunk-WEOXFEVE.js.map +1 -0
- package/dist/chunk-WYHP46LT.js +28 -0
- package/dist/chunk-WYHP46LT.js.map +1 -0
- package/dist/chunk-XGLO5LGG.js +274 -0
- package/dist/chunk-XGLO5LGG.js.map +1 -0
- package/dist/chunk-XRBCRKA2.js +29 -0
- package/dist/chunk-XRBCRKA2.js.map +1 -0
- package/dist/chunk-XW7ADFFV.js +340 -0
- package/dist/chunk-XW7ADFFV.js.map +1 -0
- package/dist/chunk-YIQ42IUX.js +34 -0
- package/dist/chunk-YIQ42IUX.js.map +1 -0
- package/dist/chunk-YJZTUY7B.js +101 -0
- package/dist/chunk-YJZTUY7B.js.map +1 -0
- package/dist/chunk-Z3CXME3K.js +107 -0
- package/dist/chunk-Z3CXME3K.js.map +1 -0
- package/dist/classifier/index.js +2 -527
- package/dist/classifier/index.js.map +1 -1
- package/dist/client-JBPCXU7W.js +4 -0
- package/dist/client-JBPCXU7W.js.map +1 -0
- package/dist/compose.js +3 -367
- package/dist/compose.js.map +1 -1
- package/dist/cost-tracker-HHGQ4FTW.js +67 -0
- package/dist/cost-tracker-HHGQ4FTW.js.map +1 -0
- package/dist/{create-ui-generator-BrZHF0cf.d.ts → create-ui-generator-BY-WeaPi.d.ts} +3 -3
- package/dist/{design-mode-DGWN_Gkm.d.ts → design-mode-XyOQmzE0.d.ts} +4 -3
- package/dist/{dispatch-B07TI30d.d.ts → dispatch-8LzTddKw.d.ts} +3 -2
- package/dist/dist-UALN6ZVB.js +543 -0
- package/dist/dist-UALN6ZVB.js.map +1 -0
- package/dist/dupe-break-X6K7QFIS.js +4 -0
- package/dist/dupe-break-X6K7QFIS.js.map +1 -0
- package/dist/evaluation/axis-checks/index.d.ts +5 -4
- package/dist/evaluation/axis-checks/index.js +6 -1914
- package/dist/evaluation/axis-checks/index.js.map +1 -1
- package/dist/evaluation/axis-checks/registry.d.ts +3 -2
- package/dist/evaluation/axis-checks/registry.js +3 -1844
- package/dist/evaluation/axis-checks/registry.js.map +1 -1
- package/dist/evaluation/index.d.ts +49 -132
- package/dist/evaluation/index.js +302 -6466
- package/dist/evaluation/index.js.map +1 -1
- package/dist/evaluation/types.d.ts +3 -2
- package/dist/evaluation/types.js +2 -5
- package/dist/evaluation/types.js.map +1 -1
- package/dist/fragments/index.js +2 -338
- package/dist/fragments/index.js.map +1 -1
- package/dist/{generate-tSO_shQ0.d.ts → generate-DQ4ci90s.d.ts} +1 -1
- package/dist/harness/check/runtime-render/index.d.ts +35 -15
- package/dist/harness/check/runtime-render/index.js +6 -2390
- package/dist/harness/check/runtime-render/index.js.map +1 -1
- package/dist/harness/check/runtime-render/render-check-worker.js +4 -1739
- package/dist/harness/check/runtime-render/render-check-worker.js.map +1 -1
- package/dist/harness/index.d.ts +3 -2
- package/dist/harness/index.js +23 -5126
- package/dist/harness/index.js.map +1 -1
- package/dist/harness/llm-trace-sink.js +2 -24
- package/dist/harness/llm-trace-sink.js.map +1 -1
- package/dist/harness/prompts.d.ts +2 -2
- package/dist/harness/prompts.js +8 -324
- package/dist/harness/prompts.js.map +1 -1
- package/dist/harness/result-types.d.ts +6 -5
- package/dist/harness/result-types.js +2 -0
- package/dist/harness/result-types.js.map +1 -1
- package/dist/harness/runtime.d.ts +22 -5
- package/dist/harness/runtime.js +10 -2313
- package/dist/harness/runtime.js.map +1 -1
- package/dist/harness/types-public.d.ts +3 -2
- package/dist/harness/types-public.js +16 -2954
- package/dist/harness/types-public.js.map +1 -1
- package/dist/harness/validator-trace-sink.d.ts +3 -2
- package/dist/harness/validator-trace-sink.js +2 -26
- package/dist/harness/validator-trace-sink.js.map +1 -1
- package/dist/hash.js +2 -39
- package/dist/hash.js.map +1 -1
- package/dist/hashline-5OKREIRM.js +4 -0
- package/dist/hashline-5OKREIRM.js.map +1 -0
- package/dist/index.d.ts +50 -11
- package/dist/index.js +57 -22015
- package/dist/index.js.map +1 -1
- package/dist/llm-evaluator-PN3WFCS4.js +653 -0
- package/dist/llm-evaluator-PN3WFCS4.js.map +1 -0
- package/dist/magic-string.es-2NZTC4GZ.js +1307 -0
- package/dist/magic-string.es-2NZTC4GZ.js.map +1 -0
- package/dist/patch.d.ts +3 -2
- package/dist/patch.js +2 -56
- package/dist/patch.js.map +1 -1
- package/dist/policy-VCYKGSAC.js +5 -0
- package/dist/policy-VCYKGSAC.js.map +1 -0
- package/dist/policy.js +2 -35
- package/dist/policy.js.map +1 -1
- package/dist/primitive-index-2OF6F4TZ.js +131 -0
- package/dist/primitive-index-2OF6F4TZ.js.map +1 -0
- package/dist/primitive-slice-WTMBLYFJ.js +235 -0
- package/dist/primitive-slice-WTMBLYFJ.js.map +1 -0
- package/dist/{prompts-BhNUuRoZ.d.ts → prompts-CLZGywMP.d.ts} +1 -1
- package/dist/provider-adapter-contract.js +10407 -14204
- package/dist/provider-adapter-contract.js.map +1 -1
- package/dist/provider-adapter.js +2 -44
- package/dist/provider-adapter.js.map +1 -1
- package/dist/providers/index.d.ts +89 -1
- package/dist/providers/index.js +115 -44
- package/dist/providers/index.js.map +1 -1
- package/dist/raw-C6KBH5I3.js +141 -0
- package/dist/raw-C6KBH5I3.js.map +1 -0
- package/dist/raw-FXSBXQTZ.js +7 -0
- package/dist/raw-FXSBXQTZ.js.map +1 -0
- package/dist/raw-MURDUPGK.js +8 -0
- package/dist/raw-MURDUPGK.js.map +1 -0
- package/dist/raw-T3GW3UVX.js +8 -0
- package/dist/raw-T3GW3UVX.js.map +1 -0
- package/dist/render-check-host-ZNIS6BJ5.js +5 -0
- package/dist/render-check-host-ZNIS6BJ5.js.map +1 -0
- package/dist/sdk-4JNSDNSR.js +6 -0
- package/dist/sdk-4JNSDNSR.js.map +1 -0
- package/dist/sdk-DIVJMHCX.js +7 -0
- package/dist/sdk-DIVJMHCX.js.map +1 -0
- package/dist/sdk-QRJOCRTS.js +7 -0
- package/dist/sdk-QRJOCRTS.js.map +1 -0
- package/dist/tag-balance-CTHCTRJ7.js +123 -0
- package/dist/tag-balance-CTHCTRJ7.js.map +1 -0
- package/dist/tools/get-primitives-ts.d.ts +1 -1
- package/dist/tools/get-primitives-ts.js +3 -1
- package/dist/tools/get-primitives-ts.js.map +1 -1
- package/dist/tools/render-check-worker.js +3 -40
- package/dist/tools/render-check-worker.js.map +1 -1
- package/dist/{types-public-h8IMnYuh.d.ts → types-public-hYlrerZh.d.ts} +35 -2
- package/dist/validation/index.d.ts +2 -2
- package/dist/validation/index.js +3 -498
- package/dist/validation/index.js.map +1 -1
- package/dist/{visual-evaluator-C2strxqD.d.ts → visual-evaluator-KskajxD5.d.ts} +14 -4
- package/dist/visual-evaluator-TGEXYQTP.js +12 -0
- package/dist/visual-evaluator-TGEXYQTP.js.map +1 -0
- package/dist/workflows.d.ts +3 -2
- package/dist/workflows.js +2 -151
- package/dist/workflows.js.map +1 -1
- package/package.json +20 -16
- package/src/adapters/claude/sdk.ts +4 -2
- package/src/adapters/claude/tool-bridge.ts +2 -1
- package/src/adapters/generation-dispatch.ts +9 -0
- package/src/adapters/openai/raw.ts +4 -0
- package/src/adapters/openai/sdk.ts +6 -1
- package/src/adapters/openai/tokens.ts +21 -7
- package/src/adapters/tool-bridge.ts +1 -1
- package/src/adapters/tools.ts +1 -1
- package/src/advanced/feedback.ts +1 -2
- package/src/advanced/generator.ts +4 -3
- package/src/boilerplate/free-design-prompt.ts +7 -0
- package/src/boilerplate/generate.ts +18 -5
- package/src/boilerplate/hard-sections.ts +8 -3
- package/src/boilerplate/react-hooks.ts +56 -0
- package/src/boilerplate/system-prompt.ts +12 -3
- package/src/check/run-tier0.ts +233 -8
- package/src/check/type-checker.ts +128 -16
- package/src/coding-agent/tools.ts +26 -3
- package/src/design-mode.ts +4 -9
- package/src/evaluation/axis-checks/checks/state-merge.ts +2 -4
- package/src/evaluation/axis-checks/checks/state-payload.ts +1 -28
- package/src/evaluation/axis-checks/checks/tint.ts +197 -0
- package/src/evaluation/axis-checks/helpers.ts +121 -0
- package/src/evaluation/axis-checks/registry.ts +2 -0
- package/src/evaluation/criteria/__fixtures__/edge-v2-draw2.json +4629 -0
- package/src/evaluation/criteria/bank.ts +1 -1
- package/src/evaluation/criteria/edge-instruments.ts +14 -0
- package/src/evaluation/criteria/edge-probe-v2.ts +352 -0
- package/src/evaluation/criteria/edge-v2.ts +242 -0
- package/src/evaluation/criteria/resolve.ts +24 -5
- package/src/evaluation/index.ts +3 -5
- package/src/evaluation/mcp-server.ts +0 -50
- package/src/evaluation/types-public.ts +6 -1
- package/src/evaluation/visual-evaluator.ts +161 -30
- package/src/harness/check/runtime-render/index.ts +28 -4
- package/src/harness/check/runtime-render/render-check.ts +20 -21
- package/src/harness/claude-agent-sdk-loader.ts +93 -0
- package/src/harness/claude-code-login-query.ts +1 -1
- package/src/harness/coding/generate-task-runner.ts +1 -0
- package/src/harness/coding/run-coding-turn.ts +3 -0
- package/src/harness/coding/run-eval-round.ts +9 -0
- package/src/harness/llm-router.ts +50 -2
- package/src/harness/runtime.ts +17 -0
- package/src/index.ts +9 -0
- package/src/providers/anthropic-tool-call.ts +263 -0
- package/src/providers/index.ts +13 -0
- package/src/tools/get-primitives-ts.ts +1 -1
- package/src/tools/render-check.ts +4 -4
- package/src/validation/primitives.ts +2 -1
- package/src/evaluation/loop.ts +0 -218
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { parseVerdictLine } from './chunk-FLRNMZV2.js';
|
|
2
|
+
import { existsSync } from 'fs';
|
|
3
|
+
import { createRequire } from 'module';
|
|
4
|
+
import { loadavg, availableParallelism } from 'os';
|
|
5
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
6
|
+
import { runSandboxed } from '@ggui-ai/sandbox';
|
|
7
|
+
|
|
8
|
+
var DEFAULT_RENDER_CHECK_HOST_BOUNDS = {
|
|
9
|
+
timeoutMs: 3e4,
|
|
10
|
+
heapMb: 512,
|
|
11
|
+
gracePeriodMs: 2e3
|
|
12
|
+
};
|
|
13
|
+
function resolveRenderCheckHostBounds(bounds = {}) {
|
|
14
|
+
const timeoutMs = bounds.timeoutMs ?? DEFAULT_RENDER_CHECK_HOST_BOUNDS.timeoutMs;
|
|
15
|
+
const heapMb = bounds.heapMb ?? DEFAULT_RENDER_CHECK_HOST_BOUNDS.heapMb;
|
|
16
|
+
if (!Number.isInteger(timeoutMs) || timeoutMs < 2) {
|
|
17
|
+
throw new RangeError(`render-check: timeoutMs must be an integer \u2265 2, got ${timeoutMs}`);
|
|
18
|
+
}
|
|
19
|
+
if (!Number.isInteger(heapMb) || heapMb < 1) {
|
|
20
|
+
throw new RangeError(`render-check: heapMb must be a positive integer, got ${heapMb}`);
|
|
21
|
+
}
|
|
22
|
+
const requestedGrace = bounds.gracePeriodMs ?? DEFAULT_RENDER_CHECK_HOST_BOUNDS.gracePeriodMs;
|
|
23
|
+
const gracePeriodMs = Math.max(1, Math.min(requestedGrace, Math.floor(timeoutMs / 2)));
|
|
24
|
+
return { timeoutMs, heapMb, gracePeriodMs };
|
|
25
|
+
}
|
|
26
|
+
var CHECK_STDOUT_CAP = 2 * 1024 * 1024;
|
|
27
|
+
var WORKER_BASENAME = "render-check-worker";
|
|
28
|
+
function resolveWorkerSpawn() {
|
|
29
|
+
const jsCandidates = [
|
|
30
|
+
// Sibling — when import.meta.url is already .../harness/check/runtime-render/.
|
|
31
|
+
new URL(`./${WORKER_BASENAME}.js`, import.meta.url),
|
|
32
|
+
// From dist/index.js.
|
|
33
|
+
new URL(`./harness/check/runtime-render/${WORKER_BASENAME}.js`, import.meta.url),
|
|
34
|
+
// From dist/harness/index.js.
|
|
35
|
+
new URL(`./check/runtime-render/${WORKER_BASENAME}.js`, import.meta.url),
|
|
36
|
+
// From dist/check/index.js, dist/advanced/index.js, dist/<flat>.js.
|
|
37
|
+
new URL(`../harness/check/runtime-render/${WORKER_BASENAME}.js`, import.meta.url)
|
|
38
|
+
];
|
|
39
|
+
for (const jsUrl of jsCandidates) {
|
|
40
|
+
const jsPath = fileURLToPath(jsUrl);
|
|
41
|
+
if (existsSync(jsPath)) {
|
|
42
|
+
return { command: process.execPath, args: [jsPath] };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const tsCandidates = [
|
|
46
|
+
new URL(`./${WORKER_BASENAME}.ts`, import.meta.url),
|
|
47
|
+
new URL(`../harness/check/runtime-render/${WORKER_BASENAME}.ts`, import.meta.url)
|
|
48
|
+
];
|
|
49
|
+
for (const tsUrl of tsCandidates) {
|
|
50
|
+
const tsPath = fileURLToPath(tsUrl);
|
|
51
|
+
if (existsSync(tsPath)) {
|
|
52
|
+
const require_ = createRequire(import.meta.url);
|
|
53
|
+
const tsxLoader = pathToFileURL(require_.resolve("tsx")).href;
|
|
54
|
+
return { command: process.execPath, args: ["--import", tsxLoader, tsPath] };
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const tried = [...jsCandidates, ...tsCandidates].map((u) => fileURLToPath(u)).join(", ");
|
|
58
|
+
throw new Error(
|
|
59
|
+
`render-check: isolated worker not found at any of: ${tried}. Did \`pnpm build\` run?`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
function failed(reason, t0) {
|
|
63
|
+
return {
|
|
64
|
+
ok: false,
|
|
65
|
+
issues: [{ check: "render-no-throw", outcome: "failed", reason }],
|
|
66
|
+
stats: { actionsChecked: 0, streamsChecked: 0, renderMs: Date.now() - t0 }
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function unverified(reason, t0) {
|
|
70
|
+
return {
|
|
71
|
+
ok: false,
|
|
72
|
+
issues: [{ check: "render-no-throw", outcome: "unverified", reason }],
|
|
73
|
+
stats: { actionsChecked: 0, streamsChecked: 0, renderMs: Date.now() - t0 }
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function mapSandboxResultToCheckResult(result, t0, boundMs = DEFAULT_RENDER_CHECK_HOST_BOUNDS.timeoutMs) {
|
|
77
|
+
if (result.outcome === "timeout") {
|
|
78
|
+
return {
|
|
79
|
+
ok: false,
|
|
80
|
+
issues: [],
|
|
81
|
+
incomplete: { kind: "timeout", elapsedMs: result.durationMs, boundMs },
|
|
82
|
+
stats: { actionsChecked: 0, streamsChecked: 0, renderMs: Date.now() - t0 }
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
if (result.outcome === "overflow-stdout" || result.outcome === "overflow-stderr") {
|
|
86
|
+
return failed(
|
|
87
|
+
`render check worker produced excessive output (${result.outcome}) \u2014 the component is likely in a pathological logging or error loop.`,
|
|
88
|
+
t0
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
if (result.outcome === "spawn-error") {
|
|
92
|
+
return unverified(
|
|
93
|
+
`render check worker failed to start \u2014 ${result.errorMessage}`,
|
|
94
|
+
t0
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
if (result.outcome === "canceled") {
|
|
98
|
+
return unverified("render check worker was canceled before completing.", t0);
|
|
99
|
+
}
|
|
100
|
+
if (result.outcome !== "exit") {
|
|
101
|
+
return unverified(
|
|
102
|
+
`render check worker ended with unexpected sandbox outcome '${result.outcome}'.`,
|
|
103
|
+
t0
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
if (result.exitCode !== 0) {
|
|
107
|
+
const tail = result.stderr.trim() || result.stdout.trim();
|
|
108
|
+
return unverified(
|
|
109
|
+
`render check worker exited ${result.exitCode}${tail ? ` \u2014 ${tail.slice(0, 600)}` : ""}`,
|
|
110
|
+
t0
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
let verdict;
|
|
114
|
+
try {
|
|
115
|
+
verdict = parseVerdictLine(result.stdout);
|
|
116
|
+
} catch (err) {
|
|
117
|
+
return unverified(
|
|
118
|
+
`render check worker verdict was not valid JSON \u2014 ${err instanceof Error ? err.message : String(err)}`,
|
|
119
|
+
t0
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
if (verdict === void 0) {
|
|
123
|
+
return unverified("render check worker exited without producing a verdict.", t0);
|
|
124
|
+
}
|
|
125
|
+
return verdict;
|
|
126
|
+
}
|
|
127
|
+
async function runRenderCheckViaWorker(input, options = {}) {
|
|
128
|
+
const t0 = Date.now();
|
|
129
|
+
const bounds = resolveRenderCheckHostBounds(options.bounds);
|
|
130
|
+
let spawn;
|
|
131
|
+
try {
|
|
132
|
+
spawn = resolveWorkerSpawn();
|
|
133
|
+
} catch (err) {
|
|
134
|
+
return unverified(err instanceof Error ? err.message : String(err), t0);
|
|
135
|
+
}
|
|
136
|
+
const loadAtStart = loadavg()[0] ?? 0;
|
|
137
|
+
const result = await runSandboxed({
|
|
138
|
+
command: spawn.command,
|
|
139
|
+
args: spawn.args,
|
|
140
|
+
timeoutMs: bounds.timeoutMs,
|
|
141
|
+
gracePeriodMs: bounds.gracePeriodMs,
|
|
142
|
+
maxStdoutBytes: CHECK_STDOUT_CAP,
|
|
143
|
+
nodeHeapMb: bounds.heapMb,
|
|
144
|
+
// ggui#1398: the check learns its own deadline, so its report-only
|
|
145
|
+
// pending phase can step aside instead of pushing it past the bound.
|
|
146
|
+
stdin: JSON.stringify({ ...input, deadlineAt: t0 + bounds.timeoutMs }),
|
|
147
|
+
// NODE_ENV steers React's production vs development build — keep
|
|
148
|
+
// parity with the caller; everything else stays on the sandbox's
|
|
149
|
+
// default allowlist.
|
|
150
|
+
env: { NODE_ENV: process.env.NODE_ENV ?? "production" }
|
|
151
|
+
});
|
|
152
|
+
const hostLoad = {
|
|
153
|
+
start: loadAtStart,
|
|
154
|
+
end: loadavg()[0] ?? 0,
|
|
155
|
+
cores: availableParallelism()
|
|
156
|
+
};
|
|
157
|
+
const mapped = mapSandboxResultToCheckResult(result, t0, bounds.timeoutMs);
|
|
158
|
+
return { ...mapped, stats: { ...mapped.stats, hostLoad } };
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export { DEFAULT_RENDER_CHECK_HOST_BOUNDS, mapSandboxResultToCheckResult, resolveRenderCheckHostBounds, resolveWorkerSpawn, runRenderCheckViaWorker };
|
|
162
|
+
//# sourceMappingURL=chunk-FXRHWYIQ.js.map
|
|
163
|
+
//# sourceMappingURL=chunk-FXRHWYIQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/harness/check/runtime-render/render-check-host.ts"],"names":[],"mappings":";;;;;;;AAgFO,IAAM,gCAAA,GAA0D;AAAA,EACrE,SAAA,EAAW,GAAA;AAAA,EACX,MAAA,EAAQ,GAAA;AAAA,EACR,aAAA,EAAe;AACjB;AAOO,SAAS,4BAAA,CACd,MAAA,GAAyC,EAAC,EACnB;AACvB,EAAA,MAAM,SAAA,GAAY,MAAA,CAAO,SAAA,IAAa,gCAAA,CAAiC,SAAA;AACvE,EAAA,MAAM,MAAA,GAAS,MAAA,CAAO,MAAA,IAAU,gCAAA,CAAiC,MAAA;AAIjE,EAAA,IAAI,CAAC,MAAA,CAAO,SAAA,CAAU,SAAS,CAAA,IAAK,YAAY,CAAA,EAAG;AACjD,IAAA,MAAM,IAAI,UAAA,CAAW,CAAA,yDAAA,EAAuD,SAAS,CAAA,CAAE,CAAA;AAAA,EACzF;AACA,EAAA,IAAI,CAAC,MAAA,CAAO,SAAA,CAAU,MAAM,CAAA,IAAK,SAAS,CAAA,EAAG;AAC3C,IAAA,MAAM,IAAI,UAAA,CAAW,CAAA,qDAAA,EAAwD,MAAM,CAAA,CAAE,CAAA;AAAA,EACvF;AACA,EAAA,MAAM,cAAA,GAAiB,MAAA,CAAO,aAAA,IAAiB,gCAAA,CAAiC,aAAA;AAChF,EAAA,MAAM,aAAA,GAAgB,IAAA,CAAK,GAAA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A,MAAM,MAAA,GAAS,MAAM,YAAA,CAAa;AAAA,IAChC,SAAS,KAAA,CAAM,OAAA;AAAA,IACf,MAAM,KAAA,CAAM,IAAA;AAAA,IACZ,WAAW,MAAA,CAAO,SAAA;AAAA,IAClB,eAAe,MAAA,CAAO,aAAA;AAAA,IACtB,cAAA,EAAgB,gBAAA;AAAA,IAChB,YAAY,MAAA,CAAO,MAAA;AAAA;AAAA;AAAA,IAGnB,KAAA,EAAO,IAAA,CAAK,SAAA,CAAU,EAAE,GAAG,OAAO,UAAA,EAAY,EAAA,GAAK,MAAA,CAAO,SAAA,EAAW,CAAA;AAAA;AAAA;AAAA;AAAA,IAIrE,KAAK,EAAE,QAAA,EAAU,OAAA,CAAQ,GAAA,CAAI,YAAY,YAAA;AAAa,GACvD,CAAA;AAED,EAAA,MAAM,QAAA,GAA0B;AAAA,IAC9B,KAAA,EAAO,WAAA;AAAA,IACP,GAAA,EAAK,OAAA,EAAQ,CAAE,CAAC,CAAA,IAAK,CAAA;AAAA,IACrB,OAAO,oBAAA;AAAqB,GAC9B;AACA,EAAA,MAAM,MAAA,GAAS,6BAAA,CAA8B,MAAA,EAAQ,EAAA,EAAI,OAAO,SAAS,CAAA;AACzE,EAAA,OAAO,EAAE,GAAG,MAAA,EAAQ,KAAA,EAAO,EAAE,GAAG,MAAA,CAAO,KAAA,EAAO,QAAA,EAAS,EAAE;AAC3D","file":"chunk-FXRHWYIQ.js","sourcesContent":["/**\n * Host side of the isolated runtime render check (#592).\n *\n * Spawns `render-check-worker.ts` in a sandboxed subprocess and maps\n * every sandbox outcome onto the check's own `RenderCheckResult`\n * vocabulary, so callers see one result shape whether the check ran\n * in-process (DOM-owning environments) or isolated (plain Node).\n *\n * Outcome mapping policy (mirrors the adapter's escaped-error\n * doctrine — component faults are `failed`, harness faults are\n * `unverified`, and nothing throws):\n *\n * - worker exit 0 + parseable verdict → the verdict, verbatim.\n * - timeout → `incomplete` (ggui#1299): the check\n * did not finish, which is NOT a verdict on the component. The bound\n * is wall-clock, and on a contended host an ordinary component\n * crosses it; mapping it to `failed` reported crashes that never\n * happened. It carries its elapsed ms, and the host load (below)\n * says how busy the host was. React's own runaway guards (\"Too many\n * re-renders\", \"Maximum update depth exceeded\") throw, so they still\n * reach `render-no-throw` as `failed`; what now reads `incomplete`\n * is a check that ran out of wall-clock time, whatever the cause.\n * - overflow → `failed` (a pathological logging or\n * error loop; output volume does not depend on host load).\n * - spawn-error / non-zero exit / unparseable stdout\n * → `unverified` (the harness could not\n * run the check; never blame the component for our plumbing).\n *\n * Every isolated check records the host's 1-minute load average at its\n * start and end, and the CPUs available, on `stats.hostLoad`.\n *\n * Spawn resolution copies the proven `src/tools/render-check.ts`\n * pattern: prefer the built `dist/.../render-check-worker.js`; in\n * dev/test (vitest imports `src/`), fall back to `node --import tsx`\n * on the `.ts` source. tsup inlines THIS module into several dist\n * entries (`dist/index.js`, `dist/harness/index.js`,\n * `dist/check/index.js`, `dist/advanced/index.js`, …), so the\n * candidate list walks from each of those locations to the one real\n * `dist/harness/check/runtime-render/render-check-worker.js`.\n */\nimport { existsSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { availableParallelism, loadavg } from 'node:os';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\nimport { runSandboxed } from '@ggui-ai/sandbox';\nimport type { SandboxResult } from '@ggui-ai/sandbox';\nimport type { ProbeHostLoad } from '../../../evaluation/types-public.js';\nimport type { RenderCheckResult, RunRenderCheckInput } from './render-check.js';\nimport { parseVerdictLine } from '../../../internal/verdict-line.js';\n\n/**\n * The subprocess bounds of one isolated check (ggui#1380). They are\n * INPUTS of the host, not constants: a serving deployment runs the probe\n * under its own memory and latency budget and sets them per check\n * instance (`createRuntimeRenderCheck`); the evaluation lane runs on the\n * defaults below, which are the values the host always used.\n */\nexport interface RenderCheckHostBounds {\n /**\n * Wall-clock bound for one isolated check. The rich probe renders,\n * clicks every declared action, and re-renders streams — slower than\n * the smoke worker's 12s budget; 30s bounds runaway components while\n * staying far under any generation-turn budget.\n */\n readonly timeoutMs: number;\n /**\n * V8 heap cap. The worker realm loads react-dom, happy-dom and\n * testing-library on top of the component itself; 512 MB leaves\n * headroom while still bounding pathological allocation.\n */\n readonly heapMb: number;\n /**\n * Grace between SIGTERM and SIGKILL once the bound is crossed. The\n * effective value is `min(gracePeriodMs, floor(timeoutMs / 2))` —\n * `runSandboxed` requires the grace to be strictly below the bound, so\n * a short bound never trips its RangeError.\n */\n readonly gracePeriodMs: number;\n}\n\nexport const DEFAULT_RENDER_CHECK_HOST_BOUNDS: RenderCheckHostBounds = {\n timeoutMs: 30_000,\n heapMb: 512,\n gracePeriodMs: 2_000,\n};\n\n/**\n * Fill the caller's partial bounds from the defaults and clamp the grace\n * below the bound. Exported so the kill-path pin can run a fixture under\n * exactly the numbers the host would pass for the same input.\n */\nexport function resolveRenderCheckHostBounds(\n bounds: Partial<RenderCheckHostBounds> = {},\n): RenderCheckHostBounds {\n const timeoutMs = bounds.timeoutMs ?? DEFAULT_RENDER_CHECK_HOST_BOUNDS.timeoutMs;\n const heapMb = bounds.heapMb ?? DEFAULT_RENDER_CHECK_HOST_BOUNDS.heapMb;\n // Refused at construction, like `maxConcurrent`: a 0 / NaN / fractional\n // bound would otherwise flow into the sandbox's flags as a nonsense number.\n // `timeoutMs` needs room for a grace of at least 1 ms below it.\n if (!Number.isInteger(timeoutMs) || timeoutMs < 2) {\n throw new RangeError(`render-check: timeoutMs must be an integer ≥ 2, got ${timeoutMs}`);\n }\n if (!Number.isInteger(heapMb) || heapMb < 1) {\n throw new RangeError(`render-check: heapMb must be a positive integer, got ${heapMb}`);\n }\n const requestedGrace = bounds.gracePeriodMs ?? DEFAULT_RENDER_CHECK_HOST_BOUNDS.gracePeriodMs;\n const gracePeriodMs = Math.max(1, Math.min(requestedGrace, Math.floor(timeoutMs / 2)));\n return { timeoutMs, heapMb, gracePeriodMs };\n}\n\n/** Options of {@link runRenderCheckViaWorker}. */\nexport interface RenderCheckHostOptions {\n /** Subprocess bounds; every field omitted falls to {@link DEFAULT_RENDER_CHECK_HOST_BOUNDS}. */\n readonly bounds?: Partial<RenderCheckHostBounds>;\n}\n\n/**\n * stdout cap. The verdict JSON carries issue lists with diagnostics\n * arrays — bigger than the smoke worker's one-liner, still tiny in\n * absolute terms. 2 MiB is far above any legitimate verdict.\n */\nconst CHECK_STDOUT_CAP = 2 * 1024 * 1024;\n\nconst WORKER_BASENAME = 'render-check-worker';\n\n/**\n * How the host spawns the worker from THIS location: the built dist sibling\n * when one exists, else the source `.ts` through tsx. Exported so the entry\n * guard can be pinned with the same spawn the host makes (no build needed).\n */\nexport function resolveWorkerSpawn(): { command: string; args: string[] } {\n const jsCandidates = [\n // Sibling — when import.meta.url is already .../harness/check/runtime-render/.\n new URL(`./${WORKER_BASENAME}.js`, import.meta.url),\n // From dist/index.js.\n new URL(`./harness/check/runtime-render/${WORKER_BASENAME}.js`, import.meta.url),\n // From dist/harness/index.js.\n new URL(`./check/runtime-render/${WORKER_BASENAME}.js`, import.meta.url),\n // From dist/check/index.js, dist/advanced/index.js, dist/<flat>.js.\n new URL(`../harness/check/runtime-render/${WORKER_BASENAME}.js`, import.meta.url),\n ];\n for (const jsUrl of jsCandidates) {\n const jsPath = fileURLToPath(jsUrl);\n if (existsSync(jsPath)) {\n return { command: process.execPath, args: [jsPath] };\n }\n }\n // Dev / vitest: only the .ts source exists — run it through tsx.\n const tsCandidates = [\n new URL(`./${WORKER_BASENAME}.ts`, import.meta.url),\n new URL(`../harness/check/runtime-render/${WORKER_BASENAME}.ts`, import.meta.url),\n ];\n for (const tsUrl of tsCandidates) {\n const tsPath = fileURLToPath(tsUrl);\n if (existsSync(tsPath)) {\n const require_ = createRequire(import.meta.url);\n const tsxLoader = pathToFileURL(require_.resolve('tsx')).href;\n return { command: process.execPath, args: ['--import', tsxLoader, tsPath] };\n }\n }\n const tried = [...jsCandidates, ...tsCandidates]\n .map((u) => fileURLToPath(u))\n .join(', ');\n throw new Error(\n `render-check: isolated worker not found at any of: ${tried}. Did \\`pnpm build\\` run?`,\n );\n}\n\nfunction failed(reason: string, t0: number): RenderCheckResult {\n return {\n ok: false,\n issues: [{ check: 'render-no-throw', outcome: 'failed', reason }],\n stats: { actionsChecked: 0, streamsChecked: 0, renderMs: Date.now() - t0 },\n };\n}\n\nfunction unverified(reason: string, t0: number): RenderCheckResult {\n return {\n ok: false,\n issues: [{ check: 'render-no-throw', outcome: 'unverified', reason }],\n stats: { actionsChecked: 0, streamsChecked: 0, renderMs: Date.now() - t0 },\n };\n}\n\n/**\n * Map one sandbox result onto a `RenderCheckResult`. `boundMs` is the\n * wall-clock bound the run was given, reported on a timeout. Exported for\n * the unit pins — the spawn itself is exercised by the integration test.\n */\nexport function mapSandboxResultToCheckResult(\n result: SandboxResult,\n t0: number,\n boundMs: number = DEFAULT_RENDER_CHECK_HOST_BOUNDS.timeoutMs,\n): RenderCheckResult {\n if (result.outcome === 'timeout') {\n return {\n ok: false,\n issues: [],\n incomplete: { kind: 'timeout', elapsedMs: result.durationMs, boundMs },\n stats: { actionsChecked: 0, streamsChecked: 0, renderMs: Date.now() - t0 },\n };\n }\n if (result.outcome === 'overflow-stdout' || result.outcome === 'overflow-stderr') {\n return failed(\n `render check worker produced excessive output (${result.outcome}) — the component is likely in a pathological logging or error loop.`,\n t0,\n );\n }\n if (result.outcome === 'spawn-error') {\n return unverified(\n `render check worker failed to start — ${result.errorMessage}`,\n t0,\n );\n }\n if (result.outcome === 'canceled') {\n return unverified('render check worker was canceled before completing.', t0);\n }\n if (result.outcome !== 'exit') {\n return unverified(\n `render check worker ended with unexpected sandbox outcome '${result.outcome}'.`,\n t0,\n );\n }\n if (result.exitCode !== 0) {\n const tail = result.stderr.trim() || result.stdout.trim();\n return unverified(\n `render check worker exited ${result.exitCode}${tail ? ` — ${tail.slice(0, 600)}` : ''}`,\n t0,\n );\n }\n let verdict: RenderCheckResult | undefined;\n try {\n verdict = parseVerdictLine<RenderCheckResult>(result.stdout);\n } catch (err) {\n return unverified(\n `render check worker verdict was not valid JSON — ${\n err instanceof Error ? err.message : String(err)\n }`,\n t0,\n );\n }\n if (verdict === undefined) {\n return unverified('render check worker exited without producing a verdict.', t0);\n }\n return verdict;\n}\n\n/**\n * Run the render check in an isolated subprocess. See module doc.\n * `options.bounds` sets the subprocess bounds for this run; omitted\n * fields are the evaluation lane's defaults.\n */\nexport async function runRenderCheckViaWorker(\n input: RunRenderCheckInput,\n options: RenderCheckHostOptions = {},\n): Promise<RenderCheckResult> {\n const t0 = Date.now();\n const bounds = resolveRenderCheckHostBounds(options.bounds);\n let spawn: { command: string; args: string[] };\n try {\n spawn = resolveWorkerSpawn();\n } catch (err) {\n return unverified(err instanceof Error ? err.message : String(err), t0);\n }\n\n const loadAtStart = loadavg()[0] ?? 0;\n const result = await runSandboxed({\n command: spawn.command,\n args: spawn.args,\n timeoutMs: bounds.timeoutMs,\n gracePeriodMs: bounds.gracePeriodMs,\n maxStdoutBytes: CHECK_STDOUT_CAP,\n nodeHeapMb: bounds.heapMb,\n // ggui#1398: the check learns its own deadline, so its report-only\n // pending phase can step aside instead of pushing it past the bound.\n stdin: JSON.stringify({ ...input, deadlineAt: t0 + bounds.timeoutMs }),\n // NODE_ENV steers React's production vs development build — keep\n // parity with the caller; everything else stays on the sandbox's\n // default allowlist.\n env: { NODE_ENV: process.env.NODE_ENV ?? 'production' },\n });\n\n const hostLoad: ProbeHostLoad = {\n start: loadAtStart,\n end: loadavg()[0] ?? 0,\n cores: availableParallelism(),\n };\n const mapped = mapSandboxResultToCheckResult(result, t0, bounds.timeoutMs);\n return { ...mapped, stats: { ...mapped.stats, hostLoad } };\n}\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all)
|
|
12
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
+
mod
|
|
29
|
+
));
|
|
30
|
+
|
|
31
|
+
export { __commonJS, __export, __toESM };
|
|
32
|
+
//# sourceMappingURL=chunk-G3PMV62Z.js.map
|
|
33
|
+
//# sourceMappingURL=chunk-G3PMV62Z.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-G3PMV62Z.js"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/adapters/claude/source-capture.ts
|
|
2
|
+
var COMPILE_TOOL_SUFFIX = "__compile_component";
|
|
3
|
+
function sourceCodeFromToolUse(name, input) {
|
|
4
|
+
if (typeof name !== "string") return void 0;
|
|
5
|
+
const field = name === "Write" ? "content" : name.endsWith(COMPILE_TOOL_SUFFIX) ? "code" : void 0;
|
|
6
|
+
if (field === void 0 || typeof input !== "object" || input === null) return void 0;
|
|
7
|
+
const value = Reflect.get(input, field);
|
|
8
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { sourceCodeFromToolUse };
|
|
12
|
+
//# sourceMappingURL=chunk-GAJI7Y3P.js.map
|
|
13
|
+
//# sourceMappingURL=chunk-GAJI7Y3P.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adapters/claude/source-capture.ts"],"names":[],"mappings":";AAUA,IAAM,mBAAA,GAAsB,qBAAA;AAGrB,SAAS,qBAAA,CAAsB,MAAe,KAAA,EAAoC;AACvF,EAAA,IAAI,OAAO,IAAA,KAAS,QAAA,EAAU,OAAO,MAAA;AACrC,EAAA,MAAM,KAAA,GAAQ,SAAS,OAAA,GAAU,SAAA,GAAY,KAAK,QAAA,CAAS,mBAAmB,IAAI,MAAA,GAAS,MAAA;AAC3F,EAAA,IAAI,UAAU,MAAA,IAAa,OAAO,UAAU,QAAA,IAAY,KAAA,KAAU,MAAM,OAAO,MAAA;AAC/E,EAAA,MAAM,KAAA,GAAiB,OAAA,CAAQ,GAAA,CAAI,KAAA,EAAO,KAAK,CAAA;AAC/C,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,CAAM,MAAA,GAAS,IAAI,KAAA,GAAQ,MAAA;AACjE","file":"chunk-GAJI7Y3P.js","sourcesContent":["// packages/ui-gen/src/adapters/claude/source-capture.ts\n//\n// ggui#1714 — which tool call carries a component's source, decided once.\n// Both Agent SDK paths (ClaudeSdkAdapter's message parser and the evaluation\n// loop's extractor) read source through this function, so the rule cannot be\n// fixed on one path and left stale on the other.\n//\n// `*__compile_component` → `input.code` (the bridged compile tool)\n// `Write` → `input.content` (a CLI built-in, offered only by opt-in)\n\nconst COMPILE_TOOL_SUFFIX = '__compile_component';\n\n/** The source a tool_use block carries, or undefined when it carries none. */\nexport function sourceCodeFromToolUse(name: unknown, input: unknown): string | undefined {\n if (typeof name !== 'string') return undefined;\n const field = name === 'Write' ? 'content' : name.endsWith(COMPILE_TOOL_SUFFIX) ? 'code' : undefined;\n if (field === undefined || typeof input !== 'object' || input === null) return undefined;\n const value: unknown = Reflect.get(input, field);\n return typeof value === 'string' && value.length > 0 ? value : undefined;\n}\n"]}
|