@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,107 @@
|
|
|
1
|
+
import { consumedTokenManifest } from '@ggui-ai/design/themes';
|
|
2
|
+
|
|
3
|
+
// src/boilerplate/json-schema-ts.ts
|
|
4
|
+
function jsonSchemaTypeToTs(schema) {
|
|
5
|
+
const unionMembers = schema.oneOf ?? schema.anyOf;
|
|
6
|
+
if (unionMembers?.length) {
|
|
7
|
+
const types = [...new Set(unionMembers.map((s) => jsonSchemaTypeToTs(s)))];
|
|
8
|
+
return types.length === 1 ? types[0] : types.join(" | ");
|
|
9
|
+
}
|
|
10
|
+
if (schema.const !== void 0) {
|
|
11
|
+
return typeof schema.const === "string" ? `'${schema.const}'` : String(schema.const);
|
|
12
|
+
}
|
|
13
|
+
if (schema.enum?.length) {
|
|
14
|
+
return schema.enum.map((v) => typeof v === "string" ? `'${v}'` : String(v)).join(" | ");
|
|
15
|
+
}
|
|
16
|
+
if (Array.isArray(schema.type)) {
|
|
17
|
+
const { nullable: _nullable, ...rest } = schema;
|
|
18
|
+
const members = [...new Set(schema.type)].map(
|
|
19
|
+
(member) => jsonSchemaTypeToTs({ ...rest, type: member })
|
|
20
|
+
);
|
|
21
|
+
const unique = [...new Set(members)];
|
|
22
|
+
if (schema.nullable && !unique.includes("null")) unique.push("null");
|
|
23
|
+
return unique.join(" | ");
|
|
24
|
+
}
|
|
25
|
+
let result;
|
|
26
|
+
switch (schema.type) {
|
|
27
|
+
case "string":
|
|
28
|
+
result = "string";
|
|
29
|
+
break;
|
|
30
|
+
case "number":
|
|
31
|
+
case "integer":
|
|
32
|
+
result = "number";
|
|
33
|
+
break;
|
|
34
|
+
case "boolean":
|
|
35
|
+
result = "boolean";
|
|
36
|
+
break;
|
|
37
|
+
case "null":
|
|
38
|
+
return "null";
|
|
39
|
+
case "array": {
|
|
40
|
+
if (schema.items) {
|
|
41
|
+
const itemType = jsonSchemaTypeToTs(schema.items);
|
|
42
|
+
const itemsDeclareObject = Array.isArray(schema.items.type) ? schema.items.type.includes("object") : schema.items.type === "object";
|
|
43
|
+
result = itemsDeclareObject && schema.items.properties ? `Array<${itemType}>` : itemType.includes("|") ? `(${itemType})[]` : `${itemType}[]`;
|
|
44
|
+
} else {
|
|
45
|
+
result = "unknown[]";
|
|
46
|
+
}
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
case "object": {
|
|
50
|
+
if (schema.properties) {
|
|
51
|
+
const required = schema.required ?? [];
|
|
52
|
+
const fields = Object.entries(schema.properties).map(([key, prop]) => {
|
|
53
|
+
const opt = !required.includes(key);
|
|
54
|
+
return `${key}${opt ? "?" : ""}: ${jsonSchemaTypeToTs(prop)}`;
|
|
55
|
+
}).join("; ");
|
|
56
|
+
result = `{ ${fields} }`;
|
|
57
|
+
} else if (schema.additionalProperties && typeof schema.additionalProperties === "object") {
|
|
58
|
+
result = `Record<string, ${jsonSchemaTypeToTs(schema.additionalProperties)}>`;
|
|
59
|
+
} else {
|
|
60
|
+
result = "Record<string, unknown>";
|
|
61
|
+
}
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
default:
|
|
65
|
+
result = "unknown";
|
|
66
|
+
}
|
|
67
|
+
if (schema.nullable && result !== "unknown") {
|
|
68
|
+
return `${result} | null`;
|
|
69
|
+
}
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/boilerplate/react-hooks.ts
|
|
74
|
+
var BOILERPLATE_REACT_HOOKS = ["useState", "useCallback", "useMemo", "useEffect", "useLayoutEffect", "useRef"];
|
|
75
|
+
var BOILERPLATE_REACT_IMPORT = `import React, { ${BOILERPLATE_REACT_HOOKS.join(", ")} } from 'react';`;
|
|
76
|
+
var REACT_IMPORT_ANY = /^[ \t]*import\b[^;]*?\bfrom\s*['"]react['"]/gm;
|
|
77
|
+
var REACT_IMPORT_LINE = /^[ \t]*import[ \t]+React(?:[ \t]*,[ \t]*\{([^}\n]*)\})?[ \t]*from[ \t]*['"]react['"];?[ \t]*$/m;
|
|
78
|
+
function restoreReactImport(source) {
|
|
79
|
+
const imports = source.match(REACT_IMPORT_ANY) ?? [];
|
|
80
|
+
if (imports.length === 0) {
|
|
81
|
+
const called = BOILERPLATE_REACT_HOOKS.some((h) => new RegExp(`\\b${h}\\s*[(<]`).test(source));
|
|
82
|
+
if (!called) return { source, added: [] };
|
|
83
|
+
return { source: `${BOILERPLATE_REACT_IMPORT}
|
|
84
|
+
${source}`, added: [...BOILERPLATE_REACT_HOOKS] };
|
|
85
|
+
}
|
|
86
|
+
if (imports.length > 1) return { source, added: [] };
|
|
87
|
+
const line = REACT_IMPORT_LINE.exec(source);
|
|
88
|
+
if (line === null) return { source, added: [] };
|
|
89
|
+
const inner = line[1] ?? "";
|
|
90
|
+
if (/\btype\b|\/\*|\/\//.test(inner)) return { source, added: [] };
|
|
91
|
+
const specs = inner.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
92
|
+
const imported = new Set(specs.map((s) => s.split(/\s+as\s+/)[0]));
|
|
93
|
+
const added = BOILERPLATE_REACT_HOOKS.filter((h) => !imported.has(h));
|
|
94
|
+
if (added.length === 0) return { source, added: [] };
|
|
95
|
+
const hooks = BOILERPLATE_REACT_HOOKS;
|
|
96
|
+
const names = [...hooks, ...specs.filter((s) => !hooks.includes(s))];
|
|
97
|
+
const restored = `import React, { ${names.join(", ")} } from 'react';`;
|
|
98
|
+
return { source: source.replace(line[0], restored), added };
|
|
99
|
+
}
|
|
100
|
+
var NOT_YET_TAUGHT_TOKENS = /* @__PURE__ */ new Set([]);
|
|
101
|
+
var taughtTokenManifest = consumedTokenManifest.filter(
|
|
102
|
+
(token) => !NOT_YET_TAUGHT_TOKENS.has(token)
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
export { BOILERPLATE_REACT_HOOKS, BOILERPLATE_REACT_IMPORT, jsonSchemaTypeToTs, restoreReactImport, taughtTokenManifest };
|
|
106
|
+
//# sourceMappingURL=chunk-Z3CXME3K.js.map
|
|
107
|
+
//# sourceMappingURL=chunk-Z3CXME3K.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/boilerplate/json-schema-ts.ts","../src/boilerplate/react-hooks.ts","../src/taught-tokens.ts"],"names":[],"mappings":";;;AAiBO,SAAS,mBAAmB,MA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GAAA,CAAI,KAAA,CAAM,GAAA,CAAI,CAAC,CAAA,KAAM,CAAA,CAAE,KAAA,CAAM,UAAU,CAAA,CAAE,CAAC,CAAC,CAAC,CAAA;AACjE,EAAA,MAAM,KAAA,GAAQ,wBAAwB,MAAA,CAAO,CAAC,MAAM,CAAC,QAAA,CAAS,GAAA,CAAI,CAAC,CAAC,CAAA;AACpE,EAAA,IAAI,KAAA,CAAM,WAAW,CAAA,EAAG,OAAO,EAAE,MAAA,EAAQ,KAAA,EAAO,EAAC,EAAE;AACnD,EAAA,MAAM,KAAA,GAA2B,uBAAA;AACjC,EAAA,MAAM,KAAA,GAAQ,CAAC,GAAG,KAAA,EAAO,GAAG,KAAA,CAAM,MAAA,CAAO,CAAC,CAAA,KAAM,CAAC,KAAA,CAAM,QAAA,CAAS,CAAC,CAAC,CAAC,CAAA;AACnE,EAAA,MAAM,QAAA,GAAW,CAAA,gBAAA,EAAmB,KAAA,CAAM,IAAA,CAAK,IAAI,CAAC,CAAA,gBAAA,CAAA;AACpD,EAAA,OAAO,EAAE,QAAQ,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAC,CAAA,EAAG,QAAQ,CAAA,EAAG,KAAA,EAAM;AAC5D;AC9BO,IAAM,qBAAA,mBAA6C,IAAI,GAAA,CAAY,EAAE,CAAA;AAGrE,IAAM,sBAAyC,qBAAA,CAAsB,MAAA;AAAA,EAC1E,CAAC,KAAA,KAAU,CAAC,qBAAA,CAAsB,IAAI,KAAK;AAC7C","file":"chunk-Z3CXME3K.js","sourcesContent":["// packages/ui-gen/src/boilerplate/json-schema-ts.ts\n//\n// JSON Schema → TypeScript type string converter.\n//\n// Pure, self-contained, no env reads, no framework deps. Exposed\n// publicly on `@ggui-ai/ui-gen/boilerplate` because it's the primitive\n// that turns a contract's JSON Schema into the `interface Props { ... }`\n// block the boilerplate generator writes.\n\nimport type { JsonSchema } from '@ggui-ai/protocol';\n\n/**\n * Convert a JsonSchema to a TypeScript type string — recursive.\n *\n * Handles: string, number, integer, boolean, null, array (+ tuples), object,\n * enum, oneOf/anyOf (unions), nullable, const, additionalProperties.\n */\nexport function jsonSchemaTypeToTs(schema: JsonSchema): string {\n // ── Union types (oneOf / anyOf) ──\n const unionMembers = schema.oneOf ?? schema.anyOf;\n if (unionMembers?.length) {\n const types = [...new Set(unionMembers.map(s => jsonSchemaTypeToTs(s)))];\n return types.length === 1 ? types[0] : types.join(' | ');\n }\n\n // ── Const (literal type) ──\n if (schema.const !== undefined) {\n return typeof schema.const === 'string' ? `'${schema.const}'` : String(schema.const);\n }\n\n // ── Enum (union of literals) ──\n if (schema.enum?.length) {\n return schema.enum\n .map(v => typeof v === 'string' ? `'${v}'` : String(v))\n .join(' | ');\n }\n\n // ── Draft-07 type array (`['string','null']` — the canonical\n // nullable form since draft-2026-08-19): members' TS union. Each\n // member re-enters with the single type so object/array members\n // keep their properties/items; `nullable` is folded in here (not in\n // the recursion) so it can't double-append. ──\n if (Array.isArray(schema.type)) {\n const { nullable: _nullable, ...rest } = schema;\n const members = [...new Set(schema.type)].map((member) =>\n jsonSchemaTypeToTs({ ...rest, type: member }),\n );\n const unique = [...new Set(members)];\n if (schema.nullable && !unique.includes('null')) unique.push('null');\n return unique.join(' | ');\n }\n\n let result: string;\n\n switch (schema.type) {\n case 'string':\n result = 'string';\n break;\n case 'number':\n case 'integer':\n result = 'number';\n break;\n case 'boolean':\n result = 'boolean';\n break;\n case 'null':\n return 'null';\n\n case 'array': {\n if (schema.items) {\n const itemType = jsonSchemaTypeToTs(schema.items);\n // Use Array<T> for complex object types, T[] for simple.\n // `items.type` may be a type SET — treat any set containing\n // 'object' like the single-string form.\n const itemsDeclareObject = Array.isArray(schema.items.type)\n ? schema.items.type.includes('object')\n : schema.items.type === 'object';\n result = (itemsDeclareObject && schema.items.properties)\n ? `Array<${itemType}>`\n : (itemType.includes('|') ? `(${itemType})[]` : `${itemType}[]`);\n } else {\n result = 'unknown[]';\n }\n break;\n }\n\n case 'object': {\n if (schema.properties) {\n const required = schema.required ?? [];\n const fields = Object.entries(schema.properties)\n .map(([key, prop]) => {\n const opt = !required.includes(key);\n return `${key}${opt ? '?' : ''}: ${jsonSchemaTypeToTs(prop)}`;\n })\n .join('; ');\n result = `{ ${fields} }`;\n } else if (schema.additionalProperties && typeof schema.additionalProperties === 'object') {\n result = `Record<string, ${jsonSchemaTypeToTs(schema.additionalProperties)}>`;\n } else {\n result = 'Record<string, unknown>';\n }\n break;\n }\n\n default:\n result = 'unknown';\n }\n\n // Apply nullable (OpenAPI 3.0 shorthand)\n if (schema.nullable && result !== 'unknown') {\n return `${result} | null`;\n }\n\n return result;\n}\n","/**\n * The React hooks the boilerplate's DO NOT EDIT React import always lists, so generated code may use\n * any of them without editing that line. One list: the boilerplate emits its import from it, and\n * tier-0's fix text names the import when one of these names goes missing.\n */\nexport const BOILERPLATE_REACT_HOOKS = ['useState', 'useCallback', 'useMemo', 'useEffect', 'useLayoutEffect', 'useRef'] as const;\n\n/** The React import line the boilerplate writes, verbatim. */\nexport const BOILERPLATE_REACT_IMPORT = `import React, { ${BOILERPLATE_REACT_HOOKS.join(', ')} } from 'react';`;\n\n/** What {@link restoreReactImport} did: the source to build, and the boilerplate hooks it put back (empty: untouched). */\nexport interface ReactImportRestore {\n readonly source: string;\n readonly added: readonly string[];\n}\n\nconst REACT_IMPORT_ANY = /^[ \\t]*import\\b[^;]*?\\bfrom\\s*['\"]react['\"]/gm;\nconst REACT_IMPORT_LINE = /^[ \\t]*import[ \\t]+React(?:[ \\t]*,[ \\t]*\\{([^}\\n]*)\\})?[ \\t]*from[ \\t]*['\"]react['\"];?[ \\t]*$/m;\n\n/**\n * ggui#1932 — keep the boilerplate's DO NOT EDIT React import, in code, before tier-0 reads the source.\n *\n * - The line exists (`import React …from 'react'`) but lacks a boilerplate hook: it becomes the boilerplate\n * hooks in order, then every other name the model listed, in its order. The result is a superset of the\n * model's line, so nothing it uses is dropped; with no extra names it is byte-for-byte\n * {@link BOILERPLATE_REACT_IMPORT}.\n * - No import from 'react' at all, and the source calls a boilerplate hook: the boilerplate line is inserted\n * at the top, where the boilerplate has it. A source that calls none is left alone: inserting would shift\n * every line for nothing, and the model patches by line number.\n * - Any other 'react' import form (named-only, namespace, more than one, spanning lines, or carrying `type`\n * specifiers or comments): untouched. Rewriting it could declare a name twice or drop what the model meant;\n * tier-0 and its fix text handle it.\n * Every boilerplate hook already imported (plain or aliased): untouched.\n */\nexport function restoreReactImport(source: string): ReactImportRestore {\n const imports = source.match(REACT_IMPORT_ANY) ?? [];\n if (imports.length === 0) {\n const called = BOILERPLATE_REACT_HOOKS.some((h) => new RegExp(`\\\\b${h}\\\\s*[(<]`).test(source));\n if (!called) return { source, added: [] };\n return { source: `${BOILERPLATE_REACT_IMPORT}\\n${source}`, added: [...BOILERPLATE_REACT_HOOKS] };\n }\n if (imports.length > 1) return { source, added: [] };\n const line = REACT_IMPORT_LINE.exec(source);\n if (line === null) return { source, added: [] };\n const inner = line[1] ?? '';\n if (/\\btype\\b|\\/\\*|\\/\\//.test(inner)) return { source, added: [] };\n const specs = inner.split(',').map((s) => s.trim()).filter((s) => s.length > 0);\n // The IMPORTED name (left of `as`): `useMemo as memo` is `useMemo` present.\n const imported = new Set(specs.map((s) => s.split(/\\s+as\\s+/)[0]));\n const added = BOILERPLATE_REACT_HOOKS.filter((h) => !imported.has(h));\n if (added.length === 0) return { source, added: [] };\n const hooks: readonly string[] = BOILERPLATE_REACT_HOOKS;\n const names = [...hooks, ...specs.filter((s) => !hooks.includes(s))];\n const restored = `import React, { ${names.join(', ')} } from 'react';`;\n return { source: source.replace(line[0], restored), added };\n}\n","// The consumed-token names the generator may TEACH — the manifest minus the names a card may not\n// reference yet.\n//\n// A card is minted by one release and rendered by whichever runtime serves it: during a rolling\n// deploy, or after a rollback, that runtime can be the previous release, which neither declares\n// nor completes a key derived for the first time in this one. A bare `var(--new-key)` then\n// resolves to nothing — a `border` shorthand drops whole — and the no-fallback rule leaves the\n// card nothing to fall back on. So a new derived key ships in two steps: the renderers that\n// declare and complete it serve first (the design package's own primitives read it behind a\n// fallback), and the release AFTER takes it out of this set, in the same change as the prompt\n// guidance that teaches it.\n\nimport { consumedTokenManifest } from \"@ggui-ai/design/themes\";\n\n/**\n * Manifest names held back from every surface that teaches the model a name — the free prompt's\n * colour vocabulary and token reference, and the self-check's nearest-name suggestions. The\n * closed-set check still admits them: a card that references one is valid wherever this release\n * renders it.\n *\n * Empty today. The control edges (`controlOutline`, `controlAccentOutline`, ggui#1494) were held here\n * until every serving and rollback runtime declared them; the derivation (`10a0c00f2`) is in every\n * release from tag 17 on, so they are taught from ggui#1697, in the same change as the prompt rule that\n * teaches a control's edge.\n */\nexport const NOT_YET_TAUGHT_TOKENS: ReadonlySet<string> = new Set<string>([]);\n\n/** The manifest as the model is taught it. */\nexport const taughtTokenManifest: readonly string[] = consumedTokenManifest.filter(\n (token) => !NOT_YET_TAUGHT_TOKENS.has(token),\n);\n"]}
|
package/dist/classifier/index.js
CHANGED
|
@@ -1,529 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (!node || typeof node !== "object") return void 0;
|
|
4
|
-
const n = node;
|
|
5
|
-
return n.schema ?? n;
|
|
6
|
-
}
|
|
7
|
-
function propType(p) {
|
|
8
|
-
const s = resolveSchema(p);
|
|
9
|
-
return s?.type;
|
|
10
|
-
}
|
|
11
|
-
function itemShape(p) {
|
|
12
|
-
const s = resolveSchema(p);
|
|
13
|
-
return s?.items;
|
|
14
|
-
}
|
|
15
|
-
function propertiesOf(p) {
|
|
16
|
-
const s = resolveSchema(p);
|
|
17
|
-
return s?.properties;
|
|
18
|
-
}
|
|
19
|
-
var ID_FIELD_CANDIDATES = ["id", "uuid", "symbol", "key", "slug", "code"];
|
|
20
|
-
function inferIdField(itemProps) {
|
|
21
|
-
if (!itemProps) return "id";
|
|
22
|
-
for (const cand of ID_FIELD_CANDIDATES) {
|
|
23
|
-
if (cand in itemProps) return cand;
|
|
24
|
-
}
|
|
25
|
-
return "id";
|
|
26
|
-
}
|
|
27
|
-
function singularize(name) {
|
|
28
|
-
if (name.endsWith("ies")) return name.slice(0, -3) + "y";
|
|
29
|
-
if (name.endsWith("ses")) return name.slice(0, -2);
|
|
30
|
-
if (name.endsWith("s") && !name.endsWith("ss")) return name.slice(0, -1);
|
|
31
|
-
return name;
|
|
32
|
-
}
|
|
33
|
-
function walkForArrObj(node, depth = 0) {
|
|
34
|
-
if (depth > 8 || !node || typeof node !== "object") return false;
|
|
35
|
-
const s = resolveSchema(node);
|
|
36
|
-
if (!s) return false;
|
|
37
|
-
const t = s.type;
|
|
38
|
-
const items = s.items;
|
|
39
|
-
if (t === "array" && items?.type === "object") return true;
|
|
40
|
-
const props = s.properties;
|
|
41
|
-
if (props) {
|
|
42
|
-
for (const v of Object.values(props)) {
|
|
43
|
-
if (walkForArrObj(v, depth + 1)) return true;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
if (items && typeof items === "object") {
|
|
47
|
-
const itemProps = items.properties;
|
|
48
|
-
if (itemProps) {
|
|
49
|
-
for (const v of Object.values(itemProps)) {
|
|
50
|
-
if (walkForArrObj(v, depth + 1)) return true;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
function hasGeoCoordsRecursive(node, depth = 0) {
|
|
57
|
-
if (depth > 8 || !node || typeof node !== "object") return false;
|
|
58
|
-
const s = resolveSchema(node);
|
|
59
|
-
if (!s) return false;
|
|
60
|
-
const props = s.properties;
|
|
61
|
-
if (props) {
|
|
62
|
-
const keys = Object.keys(props);
|
|
63
|
-
const lowered = keys.map((k) => k.toLowerCase());
|
|
64
|
-
const hasLat = lowered.includes("lat") || lowered.includes("latitude");
|
|
65
|
-
const hasLng = lowered.includes("lng") || lowered.includes("lon") || lowered.includes("longitude");
|
|
66
|
-
if (hasLat && hasLng) return true;
|
|
67
|
-
for (const v of Object.values(props)) {
|
|
68
|
-
if (hasGeoCoordsRecursive(v, depth + 1)) return true;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
if (s.items) {
|
|
72
|
-
if (hasGeoCoordsRecursive(s.items, depth + 1)) return true;
|
|
73
|
-
}
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
function scalarKeyCount(obj) {
|
|
77
|
-
if (!obj || typeof obj !== "object" || Array.isArray(obj)) return [];
|
|
78
|
-
const keys = [];
|
|
79
|
-
for (const [k, v] of Object.entries(obj)) {
|
|
80
|
-
const t = typeof v;
|
|
81
|
-
if (t === "string" || t === "number" || t === "boolean") keys.push(k);
|
|
82
|
-
}
|
|
83
|
-
return keys;
|
|
84
|
-
}
|
|
85
|
-
function allTopLevelKeys(obj) {
|
|
86
|
-
if (!obj || typeof obj !== "object" || Array.isArray(obj)) return [];
|
|
87
|
-
return Object.keys(obj);
|
|
88
|
-
}
|
|
89
|
-
function referencedEntitiesForPayload(keys, entityLists, singletons) {
|
|
90
|
-
const hits = /* @__PURE__ */ new Set();
|
|
91
|
-
for (const key of keys) {
|
|
92
|
-
if (/Id$/.test(key) && key.length > 2) {
|
|
93
|
-
const stem = key.slice(0, -2).toLowerCase();
|
|
94
|
-
for (const e of entityLists) {
|
|
95
|
-
if (e.singular.toLowerCase() === stem) hits.add(e.name);
|
|
96
|
-
}
|
|
97
|
-
for (const s of singletons) {
|
|
98
|
-
if (s.name.toLowerCase() === stem) hits.add(`__singleton:${s.name}`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return [...hits];
|
|
103
|
-
}
|
|
104
|
-
function isFullEntity(eventKeys, entity) {
|
|
105
|
-
return entity.itemKeys.every((k) => eventKeys.includes(k));
|
|
106
|
-
}
|
|
107
|
-
function inferStreamKindFromSchema(eventSchema, entityLists, singletons) {
|
|
108
|
-
const eventProps = eventSchema?.properties ?? {};
|
|
109
|
-
const eventKeys = Object.keys(eventProps);
|
|
110
|
-
const hasBool = Object.values(eventProps).some(
|
|
111
|
-
(v) => propType(v) === "boolean"
|
|
112
|
-
);
|
|
113
|
-
const hasUserKey = eventKeys.some(
|
|
114
|
-
(k) => /sender|user|author|actor|from/i.test(k)
|
|
115
|
-
);
|
|
116
|
-
if (hasBool && hasUserKey && eventKeys.length <= 3) return "presence";
|
|
117
|
-
for (const v of Object.values(eventProps)) {
|
|
118
|
-
const s = resolveSchema(v);
|
|
119
|
-
if (s?.type === "object" && s.properties && "id" in s.properties) {
|
|
120
|
-
return "merge";
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
for (const entity of entityLists) {
|
|
124
|
-
if (isFullEntity(eventKeys, entity)) return "append";
|
|
125
|
-
}
|
|
126
|
-
for (const entity of entityLists) {
|
|
127
|
-
const directMatch = eventKeys.includes(entity.idField);
|
|
128
|
-
const suffixMatch = eventKeys.some((k) => {
|
|
129
|
-
if (!/Id$/.test(k) || k.length <= 2) return false;
|
|
130
|
-
return k.slice(0, -2).toLowerCase() === entity.singular.toLowerCase();
|
|
131
|
-
});
|
|
132
|
-
if (directMatch || suffixMatch) return "merge";
|
|
133
|
-
}
|
|
134
|
-
for (const singleton of singletons) {
|
|
135
|
-
const suffixMatch = eventKeys.some((k) => {
|
|
136
|
-
if (!/Id$/.test(k) || k.length <= 2) return false;
|
|
137
|
-
return k.slice(0, -2).toLowerCase() === singleton.name.toLowerCase();
|
|
138
|
-
});
|
|
139
|
-
if (suffixMatch) return "merge";
|
|
140
|
-
const overlapCount = eventKeys.filter((k) => singleton.keys.includes(k)).length;
|
|
141
|
-
if (overlapCount >= 2) return "merge";
|
|
142
|
-
}
|
|
143
|
-
for (const v of Object.values(eventProps)) {
|
|
144
|
-
const s = resolveSchema(v);
|
|
145
|
-
if (Array.isArray(s?.enum) && s.enum.length > 0) return "status";
|
|
146
|
-
}
|
|
147
|
-
return "other";
|
|
148
|
-
}
|
|
149
|
-
function inspect(contract) {
|
|
150
|
-
const empty = {
|
|
151
|
-
actions: [],
|
|
152
|
-
streams: [],
|
|
153
|
-
agentTools: [],
|
|
154
|
-
clientCapabilities: [],
|
|
155
|
-
entityLists: [],
|
|
156
|
-
singletons: [],
|
|
157
|
-
hasArrObjAnywhere: false,
|
|
158
|
-
hasGeoCoords: false,
|
|
159
|
-
entityListIdInPayload: false,
|
|
160
|
-
singletonIdInPayload: false,
|
|
161
|
-
crossEntityAction: false,
|
|
162
|
-
multiFieldSubmit: false,
|
|
163
|
-
topLevelScalarCount: 0,
|
|
164
|
-
entitiesHaveGridPositions: false
|
|
165
|
-
};
|
|
166
|
-
if (!contract) return empty;
|
|
167
|
-
const propsField = contract.propsSpec;
|
|
168
|
-
const propsProps = propsField?.properties ?? {};
|
|
169
|
-
const entityLists = [];
|
|
170
|
-
for (const [name, p] of Object.entries(propsProps)) {
|
|
171
|
-
const t = propType(p);
|
|
172
|
-
const items = itemShape(p);
|
|
173
|
-
if (t === "array" && items?.type === "object") {
|
|
174
|
-
const itemProps = items.properties ?? {};
|
|
175
|
-
entityLists.push({
|
|
176
|
-
name,
|
|
177
|
-
singular: singularize(name),
|
|
178
|
-
idField: inferIdField(itemProps),
|
|
179
|
-
itemKeys: Object.keys(itemProps)
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
const singletons = [];
|
|
184
|
-
for (const [name, p] of Object.entries(propsProps)) {
|
|
185
|
-
const t = propType(p);
|
|
186
|
-
if (t === "object") {
|
|
187
|
-
const childProps = propertiesOf(p) ?? {};
|
|
188
|
-
const keys = Object.keys(childProps);
|
|
189
|
-
if (keys.length > 0) {
|
|
190
|
-
singletons.push({ name, keys });
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
const actionsMap = contract.actionSpec ?? {};
|
|
195
|
-
const actions = [];
|
|
196
|
-
for (const [name, action] of Object.entries(actionsMap)) {
|
|
197
|
-
const a = action;
|
|
198
|
-
const scalarKeys = scalarKeyCount(a?.example);
|
|
199
|
-
const allKeys = allTopLevelKeys(a?.example);
|
|
200
|
-
const referencedEntities = referencedEntitiesForPayload(
|
|
201
|
-
allKeys,
|
|
202
|
-
entityLists,
|
|
203
|
-
singletons
|
|
204
|
-
);
|
|
205
|
-
actions.push({
|
|
206
|
-
name,
|
|
207
|
-
nextStep: a?.nextStep,
|
|
208
|
-
example: a?.example,
|
|
209
|
-
scalarKeys,
|
|
210
|
-
allKeys,
|
|
211
|
-
referencedEntities
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
const channelsMap = contract.streamSpec ?? {};
|
|
215
|
-
const streams = [];
|
|
216
|
-
for (const [name, channel] of Object.entries(channelsMap)) {
|
|
217
|
-
streams.push({ name, schema: channel.schema });
|
|
218
|
-
}
|
|
219
|
-
const agentToolsMap = contract.agentCapabilities?.tools ?? {};
|
|
220
|
-
const agentTools = [];
|
|
221
|
-
for (const [name, tool] of Object.entries(agentToolsMap)) {
|
|
222
|
-
const t = tool;
|
|
223
|
-
const req = t?.toolInfo?.inputSchema?.properties ?? {};
|
|
224
|
-
agentTools.push({ name, requestKeys: Object.keys(req) });
|
|
225
|
-
}
|
|
226
|
-
const gadgetsMap = contract.clientCapabilities?.gadgets ?? {};
|
|
227
|
-
const clientCapabilities = [];
|
|
228
|
-
for (const name of Object.keys(gadgetsMap)) {
|
|
229
|
-
clientCapabilities.push({ name, requestKeys: [] });
|
|
230
|
-
}
|
|
231
|
-
const hasArrObjAnywhere = walkForArrObj({ properties: propsProps });
|
|
232
|
-
const hasGeoCoords = hasGeoCoordsRecursive({ properties: propsProps });
|
|
233
|
-
const entityListNames = new Set(entityLists.map((e) => e.name));
|
|
234
|
-
const entityListIdInPayload = actions.some(
|
|
235
|
-
(a) => a.referencedEntities.some((r) => entityListNames.has(r))
|
|
236
|
-
);
|
|
237
|
-
const singletonIdInPayload = actions.some(
|
|
238
|
-
(a) => a.referencedEntities.some((r) => r.startsWith("__singleton:"))
|
|
239
|
-
);
|
|
240
|
-
const crossEntityAction = actions.some((a) => {
|
|
241
|
-
const entityRefs = a.referencedEntities.filter(
|
|
242
|
-
(r) => entityListNames.has(r)
|
|
243
|
-
);
|
|
244
|
-
return new Set(entityRefs).size >= 2;
|
|
245
|
-
});
|
|
246
|
-
const multiFieldSubmit = actions.some((a) => a.scalarKeys.length >= 3);
|
|
247
|
-
let topLevelScalarCount = 0;
|
|
248
|
-
for (const v of Object.values(propsProps)) {
|
|
249
|
-
const t = propType(v);
|
|
250
|
-
if (t === "string" || t === "number" || t === "boolean") topLevelScalarCount++;
|
|
251
|
-
}
|
|
252
|
-
const entitiesHaveGridPositions = entityLists.some((e) => {
|
|
253
|
-
const keys = e.itemKeys;
|
|
254
|
-
return keys.includes("row") && keys.includes("col") || keys.includes("x") && keys.includes("y") && keys.length > 2 || keys.includes("gridRow") && keys.includes("gridColumn");
|
|
255
|
-
});
|
|
256
|
-
return {
|
|
257
|
-
actions,
|
|
258
|
-
streams,
|
|
259
|
-
agentTools,
|
|
260
|
-
clientCapabilities,
|
|
261
|
-
entityLists,
|
|
262
|
-
singletons,
|
|
263
|
-
hasArrObjAnywhere,
|
|
264
|
-
hasGeoCoords,
|
|
265
|
-
entityListIdInPayload,
|
|
266
|
-
singletonIdInPayload,
|
|
267
|
-
crossEntityAction,
|
|
268
|
-
multiFieldSubmit,
|
|
269
|
-
topLevelScalarCount,
|
|
270
|
-
entitiesHaveGridPositions
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
// src/classifier/infer-state.ts
|
|
275
|
-
var AFFORDANCE_KEYWORDS = /\b(search\b|filter\b|sort\b|select\b|tabs?\b|quantity\b|paginat|expand(ed|able)?|collaps|click(?:s|ing|ed)?\s+(an|a|the)\s+\w+\s*→?\s*detail|click\s+to\s+(select|open|view))/i;
|
|
276
|
-
function inferState(s, prompt) {
|
|
277
|
-
if (s.actions.length === 1 && s.multiFieldSubmit && !s.entityListIdInPayload && !s.singletonIdInPayload) {
|
|
278
|
-
return { value: "payload", source: "contract" };
|
|
279
|
-
}
|
|
280
|
-
if (s.streams.length > 0) {
|
|
281
|
-
return { value: "merge", source: "contract" };
|
|
282
|
-
}
|
|
283
|
-
if (s.entityLists.length > 0 && s.entityListIdInPayload) {
|
|
284
|
-
return { value: "merge", source: "contract" };
|
|
285
|
-
}
|
|
286
|
-
if (AFFORDANCE_KEYWORDS.test(prompt)) {
|
|
287
|
-
return { value: "ui-affordance", source: "prompt" };
|
|
288
|
-
}
|
|
289
|
-
if (s.actions.length >= 1) {
|
|
290
|
-
return { value: "ui-affordance", source: "heuristic" };
|
|
291
|
-
}
|
|
292
|
-
return { value: "none", source: "contract" };
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
// src/classifier/infer-writes.ts
|
|
296
|
-
function inferWrites(s) {
|
|
297
|
-
if (s.actions.length === 0) {
|
|
298
|
-
return { value: "none", source: "contract" };
|
|
299
|
-
}
|
|
300
|
-
if (s.crossEntityAction) {
|
|
301
|
-
return { value: "compose", source: "contract" };
|
|
302
|
-
}
|
|
303
|
-
if (s.entityListIdInPayload) {
|
|
304
|
-
return { value: "per-item", source: "contract" };
|
|
305
|
-
}
|
|
306
|
-
if (s.actions.length === 1 && s.multiFieldSubmit) {
|
|
307
|
-
return { value: "submit", source: "contract" };
|
|
308
|
-
}
|
|
309
|
-
if (s.actions.length >= 2) {
|
|
310
|
-
return { value: "multi-commit", source: "contract" };
|
|
311
|
-
}
|
|
312
|
-
return { value: "commit", source: "contract" };
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
// src/classifier/infer-realtime.ts
|
|
316
|
-
function inferRealtime(s) {
|
|
317
|
-
if (s.streams.length === 0) {
|
|
318
|
-
return { value: "none", source: "contract" };
|
|
319
|
-
}
|
|
320
|
-
const kinds = {};
|
|
321
|
-
for (const stream of s.streams) {
|
|
322
|
-
kinds[stream.name] = inferStreamKindFromSchema(
|
|
323
|
-
stream.schema,
|
|
324
|
-
s.entityLists,
|
|
325
|
-
s.singletons
|
|
326
|
-
);
|
|
327
|
-
}
|
|
328
|
-
const distinct = new Set(Object.values(kinds));
|
|
329
|
-
if (distinct.size === 1) {
|
|
330
|
-
const only = [...distinct][0];
|
|
331
|
-
if (only === "other") {
|
|
332
|
-
return { value: "mixed", streamKinds: kinds, source: "contract" };
|
|
333
|
-
}
|
|
334
|
-
return { value: only, source: "contract" };
|
|
335
|
-
}
|
|
336
|
-
return { value: "mixed", streamKinds: kinds, source: "contract" };
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
// src/classifier/infer-fetch.ts
|
|
340
|
-
var PAGINATION_KEYS = /* @__PURE__ */ new Set([
|
|
341
|
-
"cursor",
|
|
342
|
-
"offset",
|
|
343
|
-
"page",
|
|
344
|
-
"before",
|
|
345
|
-
"after",
|
|
346
|
-
"limit",
|
|
347
|
-
"pageSize"
|
|
348
|
-
]);
|
|
349
|
-
var SEARCH_KEYS = /* @__PURE__ */ new Set(["query", "q", "search", "keyword"]);
|
|
350
|
-
function inferFetch(s) {
|
|
351
|
-
if (s.agentTools.length === 0) {
|
|
352
|
-
return { value: "none", source: "contract" };
|
|
353
|
-
}
|
|
354
|
-
const tools = s.agentTools;
|
|
355
|
-
for (const tool of tools) {
|
|
356
|
-
for (const key of tool.requestKeys) {
|
|
357
|
-
if (PAGINATION_KEYS.has(key)) return { value: "pagination", source: "contract" };
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
for (const tool of tools) {
|
|
361
|
-
for (const key of tool.requestKeys) {
|
|
362
|
-
if (SEARCH_KEYS.has(key)) return { value: "search", source: "contract" };
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
const entityIdFields = new Set(s.entityLists.map((e) => e.idField));
|
|
366
|
-
for (const tool of tools) {
|
|
367
|
-
for (const key of tool.requestKeys) {
|
|
368
|
-
if (key === "id") return { value: "drill-down", source: "contract" };
|
|
369
|
-
if (/Id$/.test(key) && key.length > 2) {
|
|
370
|
-
return { value: "drill-down", source: "contract" };
|
|
371
|
-
}
|
|
372
|
-
if (entityIdFields.has(key)) {
|
|
373
|
-
return { value: "drill-down", source: "contract" };
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
return { value: "refresh", source: "contract" };
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
// src/classifier/infer-render.ts
|
|
381
|
-
var CHART_RX = /\b(chart|graph|trend|bar\s*graph|line\s*graph|pie)\b/i;
|
|
382
|
-
var TIMELINE_RX = /\b(timeline|chronolog|activity\s*feed|event\s*feed)\b/i;
|
|
383
|
-
var GRID_RX = /\bgrid\b|\btile\s*layout\b|\b\d+\s*columns\b|\bkanban\b|\bcolumns?\s*:/i;
|
|
384
|
-
var MAP_RX = /\b(on\s*a\s*map|on\s*the\s*map|geo|gps|lat\/lng)\b/i;
|
|
385
|
-
var MASTER_DETAIL_RX = /\b(left\s*pane|right\s*pane|sidebar|master[- ]detail|split\s*view|two[- ]pane)\b/i;
|
|
386
|
-
var STATIC_RX = /\b(card\s*stack|card\s*deck|one\s*(card|email|message|item)\s*at\s*a\s*time|full[- ]screen\s*card)\b/i;
|
|
387
|
-
function inferRender(s, prompt, blueprint) {
|
|
388
|
-
if (blueprint?.layoutHint) {
|
|
389
|
-
const hint = blueprint.layoutHint.toLowerCase();
|
|
390
|
-
if (hint.includes("master-detail") || hint.includes("split"))
|
|
391
|
-
return { value: "master-detail", source: "blueprint" };
|
|
392
|
-
if (hint.includes("card-stack") || hint.includes("deck") || hint.includes("modal"))
|
|
393
|
-
return { value: "static", source: "blueprint" };
|
|
394
|
-
if (hint.includes("spatial") || hint.includes("map"))
|
|
395
|
-
return { value: "spatial", source: "blueprint" };
|
|
396
|
-
if (hint.includes("timeline")) return { value: "timeline", source: "blueprint" };
|
|
397
|
-
if (hint.includes("chart")) return { value: "chart", source: "blueprint" };
|
|
398
|
-
if (hint.includes("grid")) return { value: "grid", source: "blueprint" };
|
|
399
|
-
}
|
|
400
|
-
if (s.hasGeoCoords) {
|
|
401
|
-
return { value: "spatial", source: "contract" };
|
|
402
|
-
}
|
|
403
|
-
if (s.entitiesHaveGridPositions) {
|
|
404
|
-
return { value: "grid", source: "contract" };
|
|
405
|
-
}
|
|
406
|
-
if (CHART_RX.test(prompt)) return { value: "chart", source: "prompt" };
|
|
407
|
-
if (TIMELINE_RX.test(prompt)) return { value: "timeline", source: "prompt" };
|
|
408
|
-
if (MASTER_DETAIL_RX.test(prompt))
|
|
409
|
-
return { value: "master-detail", source: "prompt" };
|
|
410
|
-
if (GRID_RX.test(prompt)) return { value: "grid", source: "prompt" };
|
|
411
|
-
if (MAP_RX.test(prompt) && !s.hasGeoCoords)
|
|
412
|
-
return { value: "spatial", source: "prompt" };
|
|
413
|
-
if (STATIC_RX.test(prompt)) return { value: "static", source: "prompt" };
|
|
414
|
-
if (s.entityLists.length === 0) {
|
|
415
|
-
return { value: "static", source: "contract" };
|
|
416
|
-
}
|
|
417
|
-
if (s.entityLists.length === 1 && s.topLevelScalarCount >= 4) {
|
|
418
|
-
return { value: "static", source: "contract" };
|
|
419
|
-
}
|
|
420
|
-
if (s.entityLists.length >= 2) {
|
|
421
|
-
return { value: "master-detail", source: "contract" };
|
|
422
|
-
}
|
|
423
|
-
return { value: "list", source: "contract" };
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
// src/classifier/infer-layout.ts
|
|
427
|
-
var OVERLAY_RX = /\b(overlay|overlaid|on\s*top|positioned\s*over|floating\s*action)\b/i;
|
|
428
|
-
var MODAL_RX = /\b(modal|dialog|sheet|drawer|card\s*stack)\b/i;
|
|
429
|
-
var MULTI_STEP_RX = /\b(multi[- ]step|wizard|step\s*\d+|step\s*\d+\s*:)/i;
|
|
430
|
-
var MASTER_DETAIL_RX2 = /\b(left\s*pane|right\s*pane|left\s*sidebar|right\s*main|split\s*view|two[- ]pane|master[- ]detail)\b/i;
|
|
431
|
-
function inferLayout(s, prompt, blueprint) {
|
|
432
|
-
if (blueprint?.layoutHint) {
|
|
433
|
-
const hint = blueprint.layoutHint.toLowerCase();
|
|
434
|
-
if (hint.includes("master-detail") || hint.includes("split"))
|
|
435
|
-
return { value: "master-detail", source: "blueprint" };
|
|
436
|
-
if (hint.includes("modal") || hint.includes("card-stack") || hint.includes("deck"))
|
|
437
|
-
return { value: "modal", source: "blueprint" };
|
|
438
|
-
if (hint.includes("overlay")) return { value: "overlay", source: "blueprint" };
|
|
439
|
-
if (hint.includes("multi-step") || hint.includes("wizard"))
|
|
440
|
-
return { value: "multi-step", source: "blueprint" };
|
|
441
|
-
}
|
|
442
|
-
if (MULTI_STEP_RX.test(prompt)) return { value: "multi-step", source: "prompt" };
|
|
443
|
-
if (OVERLAY_RX.test(prompt)) return { value: "overlay", source: "prompt" };
|
|
444
|
-
if (MODAL_RX.test(prompt)) return { value: "modal", source: "prompt" };
|
|
445
|
-
if (MASTER_DETAIL_RX2.test(prompt))
|
|
446
|
-
return { value: "master-detail", source: "prompt" };
|
|
447
|
-
return { value: "single", source: "default" };
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
// src/classifier/infer-trigger.ts
|
|
451
|
-
var DRAG_RX = /\b(drag|drop|dragging|draggable)\b/i;
|
|
452
|
-
var SWIPE_RX = /\b(swipe|swipes|gesture\s*stack)\b/i;
|
|
453
|
-
var KEYBOARD_RX = /\b(keyboard\s*shortcut|hotkey|keystroke|kbd)\b/i;
|
|
454
|
-
function inferWriteTrigger(s, prompt) {
|
|
455
|
-
if (s.actions.length === 0) {
|
|
456
|
-
return { value: "click", source: "default" };
|
|
457
|
-
}
|
|
458
|
-
if (DRAG_RX.test(prompt)) return { value: "drag", source: "prompt" };
|
|
459
|
-
if (SWIPE_RX.test(prompt)) return { value: "swipe", source: "prompt" };
|
|
460
|
-
if (KEYBOARD_RX.test(prompt)) return { value: "keystroke", source: "prompt" };
|
|
461
|
-
return { value: "click", source: "default" };
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
// src/classifier/infer-tooling.ts
|
|
465
|
-
function inferTooling(s) {
|
|
466
|
-
const hasAgent = s.agentTools.length > 0;
|
|
467
|
-
const hasClient = s.clientCapabilities.length > 0;
|
|
468
|
-
if (hasAgent && hasClient) return { value: "both", source: "contract" };
|
|
469
|
-
if (hasAgent) return { value: "wired", source: "contract" };
|
|
470
|
-
if (hasClient) return { value: "client", source: "contract" };
|
|
471
|
-
return { value: "none", source: "default" };
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
// src/classifier/risk-tier.ts
|
|
475
|
-
function deriveRiskTier(v) {
|
|
476
|
-
if (v.writes === "compose") return "high";
|
|
477
|
-
if (v.writeTrigger === "drag" || v.writeTrigger === "swipe") return "high";
|
|
478
|
-
if (v.realtime === "mixed") return "high";
|
|
479
|
-
if (v.render === "spatial" && v.realtime !== "none") return "high";
|
|
480
|
-
if (v.state === "merge" && v.writes === "per-item") return "high";
|
|
481
|
-
if ((v.state === "none" || v.state === "ui-affordance") && v.writes === "none" && v.realtime === "none" && v.fetch === "none") {
|
|
482
|
-
return "low";
|
|
483
|
-
}
|
|
484
|
-
return "medium";
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
// src/classifier/classifier.ts
|
|
488
|
-
function classifyAxes(input) {
|
|
489
|
-
const s = inspect(input.contract);
|
|
490
|
-
const prompt = input.prompt ?? "";
|
|
491
|
-
const blueprint = input.blueprint;
|
|
492
|
-
const state = inferState(s, prompt);
|
|
493
|
-
const writes = inferWrites(s);
|
|
494
|
-
const realtime = inferRealtime(s);
|
|
495
|
-
const fetch = inferFetch(s);
|
|
496
|
-
const render = inferRender(s, prompt, blueprint);
|
|
497
|
-
const layout = inferLayout(s, prompt, blueprint);
|
|
498
|
-
const writeTrigger = inferWriteTrigger(s, prompt);
|
|
499
|
-
const tooling = inferTooling(s);
|
|
500
|
-
const vector = {
|
|
501
|
-
render: render.value,
|
|
502
|
-
state: state.value,
|
|
503
|
-
writes: writes.value,
|
|
504
|
-
writeTrigger: writeTrigger.value,
|
|
505
|
-
realtime: realtime.value,
|
|
506
|
-
fetch: fetch.value,
|
|
507
|
-
layout: layout.value,
|
|
508
|
-
tooling: tooling.value
|
|
509
|
-
};
|
|
510
|
-
if (realtime.streamKinds) {
|
|
511
|
-
vector.streamKinds = realtime.streamKinds;
|
|
512
|
-
}
|
|
513
|
-
const provenance = {
|
|
514
|
-
render: render.source,
|
|
515
|
-
state: state.source,
|
|
516
|
-
writes: writes.source,
|
|
517
|
-
writeTrigger: writeTrigger.source,
|
|
518
|
-
realtime: realtime.source,
|
|
519
|
-
fetch: fetch.source,
|
|
520
|
-
layout: layout.source,
|
|
521
|
-
tooling: tooling.source
|
|
522
|
-
};
|
|
523
|
-
const riskTier = deriveRiskTier(vector);
|
|
524
|
-
return { vector, provenance, riskTier };
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
export { classifyAxes, deriveRiskTier, inferFetch, inferLayout, inferRealtime, inferRender, inferState, inferStreamKindFromSchema, inferTooling, inferWriteTrigger, inferWrites, inspect };
|
|
1
|
+
export { classifyAxes, deriveRiskTier, inferFetch, inferLayout, inferRealtime, inferRender, inferState, inferStreamKindFromSchema, inferTooling, inferWriteTrigger, inferWrites, inspect } from '../chunk-5KXCQLLR.js';
|
|
2
|
+
import '../chunk-G3PMV62Z.js';
|
|
528
3
|
//# sourceMappingURL=index.js.map
|
|
529
4
|
//# sourceMappingURL=index.js.map
|