@maxhealth.tech/prefab 0.3.17 → 0.3.19
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/CHANGELOG.md +35 -0
- package/README.md +1 -1
- package/dist/a2ui/browser.js +1 -2
- package/dist/a2ui/browser.js.map +1 -1
- package/dist/a2ui/expr.d.ts +7 -54
- package/dist/a2ui/expr.d.ts.map +1 -1
- package/dist/a2ui/expr.js +13 -90
- package/dist/a2ui/expr.js.map +1 -1
- package/dist/a2ui/icons.d.ts +3 -25
- package/dist/a2ui/icons.d.ts.map +1 -1
- package/dist/a2ui/icons.js +4 -33
- package/dist/a2ui/icons.js.map +1 -1
- package/dist/a2ui/types.d.ts +7 -54
- package/dist/a2ui/types.d.ts.map +1 -1
- package/dist/a2ui/types.js +2 -21
- package/dist/a2ui/types.js.map +1 -1
- package/dist/a2ui.min.js +1 -1
- package/dist/actions/subscribe.d.ts +3 -18
- package/dist/actions/subscribe.d.ts.map +1 -1
- package/dist/actions/subscribe.js +2 -17
- package/dist/actions/subscribe.js.map +1 -1
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +3 -6
- package/dist/app.js.map +1 -1
- package/dist/auto/schema.d.ts.map +1 -1
- package/dist/auto/schema.js +2 -6
- package/dist/auto/schema.js.map +1 -1
- package/dist/components/pdf/index.d.ts +3 -9
- package/dist/components/pdf/index.d.ts.map +1 -1
- package/dist/components/pdf/index.js +2 -8
- package/dist/components/pdf/index.js.map +1 -1
- package/dist/core/escape.d.ts +1 -19
- package/dist/core/escape.d.ts.map +1 -1
- package/dist/core/escape.js +1 -19
- package/dist/core/escape.js.map +1 -1
- package/dist/core/humanize.d.ts +2 -17
- package/dist/core/humanize.d.ts.map +1 -1
- package/dist/core/humanize.js +8 -20
- package/dist/core/humanize.js.map +1 -1
- package/dist/core/logger.d.ts +1 -9
- package/dist/core/logger.d.ts.map +1 -1
- package/dist/core/logger.js +1 -9
- package/dist/core/logger.js.map +1 -1
- package/dist/core/stringify.d.ts +2 -19
- package/dist/core/stringify.d.ts.map +1 -1
- package/dist/core/stringify.js +3 -21
- package/dist/core/stringify.js.map +1 -1
- package/dist/core/validate.d.ts.map +1 -1
- package/dist/core/validate.js +23 -26
- package/dist/core/validate.js.map +1 -1
- package/dist/core/version.d.ts +3 -22
- package/dist/core/version.d.ts.map +1 -1
- package/dist/core/version.js +3 -22
- package/dist/core/version.js.map +1 -1
- package/dist/mcp/a2ui.d.ts +6 -36
- package/dist/mcp/a2ui.d.ts.map +1 -1
- package/dist/mcp/a2ui.js +6 -36
- package/dist/mcp/a2ui.js.map +1 -1
- package/dist/mcp/input-required.d.ts.map +1 -1
- package/dist/mcp/input-required.js +2 -8
- package/dist/mcp/input-required.js.map +1 -1
- package/dist/mcp/resource.d.ts +12 -88
- package/dist/mcp/resource.d.ts.map +1 -1
- package/dist/mcp/resource.js +18 -85
- package/dist/mcp/resource.js.map +1 -1
- package/dist/mcp/result.d.ts +2 -27
- package/dist/mcp/result.d.ts.map +1 -1
- package/dist/mcp/result.js +2 -27
- package/dist/mcp/result.js.map +1 -1
- package/dist/mcp/theme-bridge.d.ts +5 -36
- package/dist/mcp/theme-bridge.d.ts.map +1 -1
- package/dist/mcp/theme-bridge.js +6 -43
- package/dist/mcp/theme-bridge.js.map +1 -1
- package/dist/mcp/types.d.ts +11 -106
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/mcp/types.js +2 -22
- package/dist/mcp/types.js.map +1 -1
- package/dist/renderer/actions.d.ts +2 -2
- package/dist/renderer/actions.d.ts.map +1 -1
- package/dist/renderer/actions.js +6 -2
- package/dist/renderer/actions.js.map +1 -1
- package/dist/renderer/app.d.ts.map +1 -1
- package/dist/renderer/app.js +3 -2
- package/dist/renderer/app.js.map +1 -1
- package/dist/renderer/auto.js +9 -4
- package/dist/renderer/auto.js.map +1 -1
- package/dist/renderer/bridge.d.ts +3 -7
- package/dist/renderer/bridge.d.ts.map +1 -1
- package/dist/renderer/bridge.js +39 -65
- package/dist/renderer/bridge.js.map +1 -1
- package/dist/renderer/components/alert.d.ts.map +1 -1
- package/dist/renderer/components/alert.js +4 -2
- package/dist/renderer/components/alert.js.map +1 -1
- package/dist/renderer/components/choice.d.ts.map +1 -1
- package/dist/renderer/components/choice.js +5 -4
- package/dist/renderer/components/choice.js.map +1 -1
- package/dist/renderer/components/control.d.ts.map +1 -1
- package/dist/renderer/components/control.js +16 -9
- package/dist/renderer/components/control.js.map +1 -1
- package/dist/renderer/components/data.d.ts.map +1 -1
- package/dist/renderer/components/data.js +17 -15
- package/dist/renderer/components/data.js.map +1 -1
- package/dist/renderer/components/form.d.ts.map +1 -1
- package/dist/renderer/components/form.js +18 -17
- package/dist/renderer/components/form.js.map +1 -1
- package/dist/renderer/components/interactive.d.ts.map +1 -1
- package/dist/renderer/components/interactive.js +3 -2
- package/dist/renderer/components/interactive.js.map +1 -1
- package/dist/renderer/components/media.d.ts.map +1 -1
- package/dist/renderer/components/media.js +13 -10
- package/dist/renderer/components/media.js.map +1 -1
- package/dist/renderer/components/pdf.d.ts +1 -10
- package/dist/renderer/components/pdf.d.ts.map +1 -1
- package/dist/renderer/components/pdf.js +19 -14
- package/dist/renderer/components/pdf.js.map +1 -1
- package/dist/renderer/components/table.js +2 -2
- package/dist/renderer/components/table.js.map +1 -1
- package/dist/renderer/components/typography.d.ts.map +1 -1
- package/dist/renderer/components/typography.js +4 -2
- package/dist/renderer/components/typography.js.map +1 -1
- package/dist/renderer/engine.d.ts.map +1 -1
- package/dist/renderer/engine.js +5 -6
- package/dist/renderer/engine.js.map +1 -1
- package/dist/renderer/host-context.d.ts +8 -0
- package/dist/renderer/host-context.d.ts.map +1 -0
- package/dist/renderer/host-context.js +62 -0
- package/dist/renderer/host-context.js.map +1 -0
- package/dist/renderer/index.d.ts.map +1 -1
- package/dist/renderer/index.js +21 -28
- package/dist/renderer/index.js.map +1 -1
- package/dist/renderer/rx.d.ts +2 -0
- package/dist/renderer/rx.d.ts.map +1 -1
- package/dist/renderer/rx.js +24 -24
- package/dist/renderer/rx.js.map +1 -1
- package/dist/renderer/state.d.ts.map +1 -1
- package/dist/renderer/state.js +10 -4
- package/dist/renderer/state.js.map +1 -1
- package/dist/renderer.auto.min.js +10 -10
- package/dist/renderer.min.js +10 -10
- package/dist/rx/pipes.d.ts +3 -19
- package/dist/rx/pipes.d.ts.map +1 -1
- package/dist/rx/pipes.js +3 -19
- package/dist/rx/pipes.js.map +1 -1
- package/dist/rx/signal.d.ts +3 -13
- package/dist/rx/signal.d.ts.map +1 -1
- package/dist/rx/signal.js +2 -9
- package/dist/rx/signal.js.map +1 -1
- package/package.json +4 -4
package/dist/core/logger.d.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Zero-dependency by design (prefab's renderer bundle ships no runtime deps),
|
|
5
|
-
* but API-compatible with the org-wide `@maxhealth.tech/utils` `createLogger`
|
|
6
|
-
* so call sites read the same everywhere and could later swap to the shared
|
|
7
|
-
* package without churn.
|
|
8
|
-
*
|
|
9
|
-
* Adds a runtime level (the utils logger gates on NODE_ENV, which is unreliable
|
|
10
|
-
* in a browser bundle) so an embedding host can raise or mute prefab's output:
|
|
2
|
+
* The one sink for prefab's console output, with a runtime level a host can raise or mute:
|
|
11
3
|
*
|
|
12
4
|
* ```ts
|
|
13
5
|
* import { setLogLevel } from '@maxhealth.tech/prefab'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAQrE,wBAAgB,WAAW,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAEjD;AAED,wBAAgB,WAAW,IAAI,QAAQ,CAEtC;AAID,MAAM,WAAW,MAAM;IACrB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAChD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAC/C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAC/C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;CACjD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAanD;AAED,8CAA8C;AAC9C,eAAO,MAAM,GAAG,EAAE,MAAuB,CAAA"}
|
package/dist/core/logger.js
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Zero-dependency by design (prefab's renderer bundle ships no runtime deps),
|
|
5
|
-
* but API-compatible with the org-wide `@maxhealth.tech/utils` `createLogger`
|
|
6
|
-
* so call sites read the same everywhere and could later swap to the shared
|
|
7
|
-
* package without churn.
|
|
8
|
-
*
|
|
9
|
-
* Adds a runtime level (the utils logger gates on NODE_ENV, which is unreliable
|
|
10
|
-
* in a browser bundle) so an embedding host can raise or mute prefab's output:
|
|
2
|
+
* The one sink for prefab's console output, with a runtime level a host can raise or mute:
|
|
11
3
|
*
|
|
12
4
|
* ```ts
|
|
13
5
|
* import { setLogLevel } from '@maxhealth.tech/prefab'
|
package/dist/core/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file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CAAC,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC;KAC1D,CAAA;AACH,CAAC;AAED,8CAA8C;AAC9C,MAAM,CAAC,MAAM,GAAG,GAAW,YAAY,EAAE,CAAA"}
|
package/dist/core/stringify.d.ts
CHANGED
|
@@ -1,23 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Component props, state entries and row cells are all typed `unknown` because
|
|
5
|
-
* they arrive from JSON. Passing those straight to `String()` renders every
|
|
6
|
-
* object as `[object Object]`, which blanks out table cells and chart labels
|
|
7
|
-
* and — worse — makes every distinct object collide when the result is used as
|
|
8
|
-
* a lookup key. Route those coercions through {@link stringifyValue} instead.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Coerce an arbitrary value to a string for display or identity comparison.
|
|
12
|
-
*
|
|
13
|
-
* - `null` / `undefined` → `''`
|
|
14
|
-
* - strings pass through verbatim, other primitives use `String()`
|
|
15
|
-
* - `Date` → ISO string (invalid dates → `''`)
|
|
16
|
-
* - arrays → members stringified and joined with `', '`
|
|
17
|
-
* - any other object → compact JSON (honouring `toJSON()`), never `[object Object]`
|
|
18
|
-
*
|
|
19
|
-
* The result is stable for a given value, so it is also safe to use as a map
|
|
20
|
-
* key or for equality checks between two loosely-typed values.
|
|
2
|
+
* A value as display text, never `[object Object]`: nullish → `''`, Date → ISO, arrays joined with `', '`,
|
|
3
|
+
* other objects as compact JSON. Loose by design, so `1` and `'1'` give the same string.
|
|
21
4
|
*/
|
|
22
5
|
export declare function stringifyValue(value: unknown): string;
|
|
23
6
|
//# sourceMappingURL=stringify.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stringify.d.ts","sourceRoot":"","sources":["../../src/core/stringify.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"stringify.d.ts","sourceRoot":"","sources":["../../src/core/stringify.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAgBrD"}
|
package/dist/core/stringify.js
CHANGED
|
@@ -1,23 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Component props, state entries and row cells are all typed `unknown` because
|
|
5
|
-
* they arrive from JSON. Passing those straight to `String()` renders every
|
|
6
|
-
* object as `[object Object]`, which blanks out table cells and chart labels
|
|
7
|
-
* and — worse — makes every distinct object collide when the result is used as
|
|
8
|
-
* a lookup key. Route those coercions through {@link stringifyValue} instead.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Coerce an arbitrary value to a string for display or identity comparison.
|
|
12
|
-
*
|
|
13
|
-
* - `null` / `undefined` → `''`
|
|
14
|
-
* - strings pass through verbatim, other primitives use `String()`
|
|
15
|
-
* - `Date` → ISO string (invalid dates → `''`)
|
|
16
|
-
* - arrays → members stringified and joined with `', '`
|
|
17
|
-
* - any other object → compact JSON (honouring `toJSON()`), never `[object Object]`
|
|
18
|
-
*
|
|
19
|
-
* The result is stable for a given value, so it is also safe to use as a map
|
|
20
|
-
* key or for equality checks between two loosely-typed values.
|
|
2
|
+
* A value as display text, never `[object Object]`: nullish → `''`, Date → ISO, arrays joined with `', '`,
|
|
3
|
+
* other objects as compact JSON. Loose by design, so `1` and `'1'` give the same string.
|
|
21
4
|
*/
|
|
22
5
|
export function stringifyValue(value) {
|
|
23
6
|
if (value == null)
|
|
@@ -35,8 +18,7 @@ export function stringifyValue(value) {
|
|
|
35
18
|
if (Array.isArray(value))
|
|
36
19
|
return value.map(stringifyValue).join(', ');
|
|
37
20
|
try {
|
|
38
|
-
//
|
|
39
|
-
// undefined makes JSON.stringify return undefined too — hence the guard.
|
|
21
|
+
// JSON.stringify returns undefined when toJSON() does, despite its declared type.
|
|
40
22
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
41
23
|
return JSON.stringify(value) ?? '';
|
|
42
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stringify.js","sourceRoot":"","sources":["../../src/core/stringify.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"stringify.js","sourceRoot":"","sources":["../../src/core/stringify.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,EAAE,CAAA;IAC5B,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC3C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;IAC9G,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,WAAW,IAAI,EAAE,CAAA;IAC7D,IAAI,OAAO,KAAK,KAAK,UAAU;QAAE,OAAO,KAAK,CAAC,IAAI,CAAA;IAClD,IAAI,KAAK,YAAY,IAAI;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAA;IAC1F,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACrE,IAAI,CAAC;QACH,kFAAkF;QAClF,uEAAuE;QACvE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,mEAAmE;QACnE,OAAO,EAAE,CAAA;IACX,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/core/validate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/core/validate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAMjD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,eAAe,EAAE,CAAA;CAC1B;AAWD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,OAAO,EACb,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAC9B,gBAAgB,CA8ElB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,gBAAgB,CAEzE"}
|
package/dist/core/validate.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* and returns structured error information.
|
|
6
6
|
*/
|
|
7
7
|
import { COMPONENT_TYPES } from './component-types.js';
|
|
8
|
+
import { isRecord } from './guards.js';
|
|
8
9
|
// ── Known component types ────────────────────────────────────────────────────
|
|
9
10
|
// Derived from the renderer's registry (see scripts/gen-component-types.ts), not
|
|
10
11
|
// restated here. A hand-maintained copy drifted and rejected four renderable
|
|
@@ -21,17 +22,16 @@ const KNOWN_TYPES = new Set(COMPONENT_TYPES);
|
|
|
21
22
|
export function validateWireFormat(data, opts = {}) {
|
|
22
23
|
const errors = [];
|
|
23
24
|
const strict = opts.strict ?? false;
|
|
24
|
-
if (data
|
|
25
|
+
if (!isRecord(data)) {
|
|
25
26
|
errors.push({ path: '$', message: 'Wire data must be a non-null object' });
|
|
26
27
|
return { valid: false, errors };
|
|
27
28
|
}
|
|
28
29
|
const obj = data;
|
|
29
|
-
|
|
30
|
-
if (
|
|
30
|
+
const header = obj.$prefab;
|
|
31
|
+
if (!isRecord(header)) {
|
|
31
32
|
errors.push({ path: '$.$prefab', message: 'Missing or invalid $prefab header' });
|
|
32
33
|
}
|
|
33
34
|
else {
|
|
34
|
-
const header = obj.$prefab;
|
|
35
35
|
if (typeof header.version !== 'string') {
|
|
36
36
|
errors.push({ path: '$.$prefab.version', message: 'version must be a string' });
|
|
37
37
|
}
|
|
@@ -66,23 +66,25 @@ export function validateWireFormat(data, opts = {}) {
|
|
|
66
66
|
errors.push({ path: '$.mode', message: 'mode must be "light" or "dark"' });
|
|
67
67
|
}
|
|
68
68
|
// defs (optional)
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
const defs = obj.defs;
|
|
70
|
+
if (defs !== undefined) {
|
|
71
|
+
if (!isRecord(defs)) {
|
|
71
72
|
errors.push({ path: '$.defs', message: 'defs must be a plain object' });
|
|
72
73
|
}
|
|
73
74
|
else {
|
|
74
|
-
for (const [name, def] of Object.entries(
|
|
75
|
+
for (const [name, def] of Object.entries(defs)) {
|
|
75
76
|
validateComponent(def, `$.defs.${name}`, errors, strict);
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
80
|
// keyBindings (optional)
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
const keyBindings = obj.keyBindings;
|
|
82
|
+
if (keyBindings !== undefined) {
|
|
83
|
+
if (!isRecord(keyBindings)) {
|
|
82
84
|
errors.push({ path: '$.keyBindings', message: 'keyBindings must be a plain object' });
|
|
83
85
|
}
|
|
84
86
|
else {
|
|
85
|
-
for (const [key, action] of Object.entries(
|
|
87
|
+
for (const [key, action] of Object.entries(keyBindings)) {
|
|
86
88
|
validateAction(action, `$.keyBindings.${key}`, errors);
|
|
87
89
|
}
|
|
88
90
|
}
|
|
@@ -97,7 +99,7 @@ export function isValidWireFormat(data) {
|
|
|
97
99
|
}
|
|
98
100
|
// ── Internal helpers ─────────────────────────────────────────────────────────
|
|
99
101
|
function validateComponent(node, path, errors, strict) {
|
|
100
|
-
if (
|
|
102
|
+
if (!isRecord(node)) {
|
|
101
103
|
errors.push({ path, message: 'Component must be a plain object' });
|
|
102
104
|
return;
|
|
103
105
|
}
|
|
@@ -158,10 +160,7 @@ function validateComponent(node, path, errors, strict) {
|
|
|
158
160
|
const COMPONENT_SLOT_KEYS = new Set(['children', 'fallback', 'trigger', 'empty', 'else', 'summary']);
|
|
159
161
|
/** Is the value a component node of a recognized type? */
|
|
160
162
|
function isComponentLike(value) {
|
|
161
|
-
|
|
162
|
-
return false;
|
|
163
|
-
const t = value.type;
|
|
164
|
-
return typeof t === 'string' && KNOWN_TYPES.has(t);
|
|
163
|
+
return isRecord(value) && typeof value.type === 'string' && KNOWN_TYPES.has(value.type);
|
|
165
164
|
}
|
|
166
165
|
function validateAction(action, path, errors) {
|
|
167
166
|
if (Array.isArray(action)) {
|
|
@@ -170,20 +169,19 @@ function validateAction(action, path, errors) {
|
|
|
170
169
|
}
|
|
171
170
|
return;
|
|
172
171
|
}
|
|
173
|
-
if (action
|
|
172
|
+
if (!isRecord(action)) {
|
|
174
173
|
errors.push({ path, message: 'Action must be an object or array of objects' });
|
|
175
174
|
return;
|
|
176
175
|
}
|
|
177
176
|
const act = action;
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
177
|
+
const name = typeof act.action === 'string' && act.action.length > 0 ? act.action
|
|
178
|
+
: typeof act.type === 'string' && act.type.length > 0 ? act.type
|
|
179
|
+
: undefined;
|
|
180
|
+
if (name === undefined) {
|
|
181
181
|
errors.push({ path: `${path}.type`, message: 'Action must have a non-empty "type" or "action" string' });
|
|
182
182
|
return;
|
|
183
183
|
}
|
|
184
|
-
//
|
|
185
|
-
// empty heading (a real bug when authors reach for `title` instead).
|
|
186
|
-
const name = (hasAction ? act.action : act.type);
|
|
184
|
+
// showToast without `message` renders an empty toast (authors reach for `title`).
|
|
187
185
|
if (name.toLowerCase() === 'showtoast') {
|
|
188
186
|
if (typeof act.message !== 'string' || act.message.length === 0) {
|
|
189
187
|
errors.push({ path: `${path}.message`, message: 'showToast requires a non-empty "message" string' });
|
|
@@ -202,14 +200,13 @@ function validateStringArray(value, path, errors) {
|
|
|
202
200
|
}
|
|
203
201
|
}
|
|
204
202
|
function validateTheme(theme, errors) {
|
|
205
|
-
if (
|
|
203
|
+
if (!isRecord(theme)) {
|
|
206
204
|
errors.push({ path: '$.theme', message: 'theme must be a plain object' });
|
|
207
205
|
return;
|
|
208
206
|
}
|
|
209
|
-
const t = theme;
|
|
210
207
|
for (const mode of ['light', 'dark']) {
|
|
211
|
-
if (
|
|
212
|
-
if (
|
|
208
|
+
if (theme[mode] !== undefined) {
|
|
209
|
+
if (!isRecord(theme[mode])) {
|
|
213
210
|
errors.push({ path: `$.theme.${mode}`, message: `theme.${mode} must be a plain object` });
|
|
214
211
|
}
|
|
215
212
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/core/validate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/core/validate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AActC,gFAAgF;AAEhF,iFAAiF;AACjF,6EAA6E;AAC7E,gFAAgF;AAChF,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,CAAA;AAE5C,gFAAgF;AAEhF;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAAa,EACb,OAA6B,EAAE;IAE/B,MAAM,MAAM,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1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Zero imports on purpose: the lean renderer bundle (bridge, transport) can pull
|
|
5
|
-
* these in without dragging the builder module graph along.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Package version of `@maxhealth.tech/prefab`. Bumped at release time by
|
|
9
|
-
* `release.yml` (see `scripts/changelog-release.ts` companion step). Identifies
|
|
10
|
-
* the app to an MCP Apps host (`appInfo.version`) and pins the CDN URL.
|
|
11
|
-
*/
|
|
12
|
-
export declare const VERSION = "0.3.17";
|
|
13
|
-
/**
|
|
14
|
-
* Wire protocol version emitted in `$prefab.version`.
|
|
15
|
-
*
|
|
16
|
-
* `0.3` matches upstream PrefectHQ/prefab: the theme is folded into the `css`
|
|
17
|
-
* array, `stylesheets` carries external URLs, and `mode` forces a color scheme
|
|
18
|
-
* (PR #431, "Wire Transfer"). The renderer still accepts `0.2` payloads.
|
|
19
|
-
*
|
|
20
|
-
* NOTE: distinct from `VERSION` (the npm package version) and from the MCP Apps
|
|
21
|
-
* dated protocol version (`2026-01-26`, negotiated in the bridge handshake).
|
|
22
|
-
*/
|
|
1
|
+
/** Package version, stamped by `release.yml`. Identifies the app to MCP Apps hosts and pins the CDN URL. */
|
|
2
|
+
export declare const VERSION = "0.3.19";
|
|
3
|
+
/** `$prefab.version` of the wire format, matching upstream PrefectHQ/prefab 0.3; the renderer still reads 0.2. */
|
|
23
4
|
export declare const PROTOCOL_VERSION = "0.3";
|
|
24
5
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/core/version.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/core/version.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,eAAO,MAAM,OAAO,WAAW,CAAA;AAE/B,kHAAkH;AAClH,eAAO,MAAM,gBAAgB,QAAQ,CAAA"}
|
package/dist/core/version.js
CHANGED
|
@@ -1,24 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Zero imports on purpose: the lean renderer bundle (bridge, transport) can pull
|
|
5
|
-
* these in without dragging the builder module graph along.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Package version of `@maxhealth.tech/prefab`. Bumped at release time by
|
|
9
|
-
* `release.yml` (see `scripts/changelog-release.ts` companion step). Identifies
|
|
10
|
-
* the app to an MCP Apps host (`appInfo.version`) and pins the CDN URL.
|
|
11
|
-
*/
|
|
12
|
-
export const VERSION = '0.3.17';
|
|
13
|
-
/**
|
|
14
|
-
* Wire protocol version emitted in `$prefab.version`.
|
|
15
|
-
*
|
|
16
|
-
* `0.3` matches upstream PrefectHQ/prefab: the theme is folded into the `css`
|
|
17
|
-
* array, `stylesheets` carries external URLs, and `mode` forces a color scheme
|
|
18
|
-
* (PR #431, "Wire Transfer"). The renderer still accepts `0.2` payloads.
|
|
19
|
-
*
|
|
20
|
-
* NOTE: distinct from `VERSION` (the npm package version) and from the MCP Apps
|
|
21
|
-
* dated protocol version (`2026-01-26`, negotiated in the bridge handshake).
|
|
22
|
-
*/
|
|
1
|
+
/** Package version, stamped by `release.yml`. Identifies the app to MCP Apps hosts and pins the CDN URL. */
|
|
2
|
+
export const VERSION = '0.3.19';
|
|
3
|
+
/** `$prefab.version` of the wire format, matching upstream PrefectHQ/prefab 0.3; the renderer still reads 0.2. */
|
|
23
4
|
export const PROTOCOL_VERSION = '0.3';
|
|
24
5
|
//# sourceMappingURL=version.js.map
|
package/dist/core/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/core/version.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/core/version.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAA;AAE/B,kHAAkH;AAClH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAA"}
|
package/dist/mcp/a2ui.d.ts
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* The two delivery models are not variations on one theme:
|
|
5
|
-
*
|
|
6
|
-
* - **MCP Apps (`ui://`)** ships an HTML document that the host renders in a
|
|
7
|
-
* sandboxed iframe. prefab's renderer runs inside it and draws the
|
|
8
|
-
* `$prefab` payload. `registerViewerResource` in `./resource.ts` sets that up.
|
|
9
|
-
* - **A2UI (`a2ui://`)** ships the UI *description*. No iframe and no
|
|
10
|
-
* renderer of prefab's: the host's own A2UI renderer draws native widgets
|
|
11
|
-
* from the component list.
|
|
12
|
-
*
|
|
13
|
-
* A server can offer both from the same tool. The A2UI payload is identified by
|
|
14
|
-
* the `application/a2ui+json` MIME type, either as a standalone resource or as
|
|
15
|
-
* an `EmbeddedResource` inside a tool result, which is what
|
|
16
|
-
* [A2UI over MCP](https://a2ui.org/guides/a2ui_over_mcp/) specifies.
|
|
17
|
-
*
|
|
18
|
-
* The payload itself is the list-wrapper envelope `{ messages: [...] }` rather
|
|
19
|
-
* than a bare array, because a resource body has to be a JSON object.
|
|
2
|
+
* A2UI over MCP (`a2ui://`): the UI description as `application/a2ui+json`, drawn by the host's own A2UI renderer,
|
|
3
|
+
* where `ui://` ships prefab's renderer in an iframe. See https://a2ui.org/guides/a2ui_over_mcp/.
|
|
20
4
|
*/
|
|
21
5
|
import { PrefabApp } from '../app.js';
|
|
22
6
|
import type { Component } from '../core/component.js';
|
|
@@ -31,19 +15,11 @@ export declare function a2uiPayload(messages: A2uiMessage[]): A2uiMessageList;
|
|
|
31
15
|
export interface DisplayA2uiOptions extends A2uiEmitOptions {
|
|
32
16
|
/** URI stamped on the embedded resource. @default 'a2ui://prefab/surface' */
|
|
33
17
|
uri?: string;
|
|
34
|
-
/**
|
|
35
|
-
* Called with anything lost in translation. Without it, a `degraded` or
|
|
36
|
-
* `unsupported` diagnostic is logged at warn level, because silently shipping
|
|
37
|
-
* a lesser UI is the failure mode worth making noisy.
|
|
38
|
-
*/
|
|
18
|
+
/** Called with anything lost in translation; without it, `degraded` and `unsupported` diagnostics are logged as warnings. */
|
|
39
19
|
onDiagnostics?: (diagnostics: A2uiDiagnostic[]) => void;
|
|
40
20
|
}
|
|
41
21
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* The messages travel as an `EmbeddedResource` in `content`, which is where a
|
|
45
|
-
* host looks for a payload it should route to its A2UI renderer, and as
|
|
46
|
-
* `structuredContent` for hosts that read results structurally.
|
|
22
|
+
* A view as an A2UI tool result: an `EmbeddedResource` in `content`, and the same payload as `structuredContent`.
|
|
47
23
|
*
|
|
48
24
|
* @example
|
|
49
25
|
* ```ts
|
|
@@ -68,14 +44,8 @@ export interface A2uiResourceOptions extends A2uiEmitOptions {
|
|
|
68
44
|
onDiagnostics?: (diagnostics: A2uiDiagnostic[]) => void;
|
|
69
45
|
}
|
|
70
46
|
/**
|
|
71
|
-
* Register
|
|
72
|
-
*
|
|
73
|
-
* Static is the point: a surface that does not depend on the conversation is
|
|
74
|
-
* cheaper as a resource than as a tool, because the host can read it once and
|
|
75
|
-
* cache it. Anything that varies per call belongs in {@link display_a2ui}.
|
|
76
|
-
*
|
|
77
|
-
* `builder` runs on every read rather than once at registration, so a surface
|
|
78
|
-
* that closes over data refreshes without re-registering.
|
|
47
|
+
* Register an A2UI surface that does not depend on the conversation as an `a2ui://` resource; `builder` runs on every read.
|
|
48
|
+
* Per-call views belong in {@link display_a2ui}.
|
|
79
49
|
*
|
|
80
50
|
* @example
|
|
81
51
|
* ```ts
|
package/dist/mcp/a2ui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a2ui.d.ts","sourceRoot":"","sources":["../../src/mcp/a2ui.ts"],"names":[],"mappings":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Aa,CAAC,EAAE,CAAC,WAAW,EAAE,cAAc,EAAE,KAAK,IAAI,CAAA;CACxD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,MAAM,SAAS,GAAG,SAAS,EACpC,OAAO,CAAC,EAAE,mBAAmB,GAC5B,IAAI,CAuCN;AAED,2DAA2D;AAC3D,eAAO,MAAM,WAAW,qBAAe,CAAA"}
|
package/dist/mcp/a2ui.js
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* The two delivery models are not variations on one theme:
|
|
5
|
-
*
|
|
6
|
-
* - **MCP Apps (`ui://`)** ships an HTML document that the host renders in a
|
|
7
|
-
* sandboxed iframe. prefab's renderer runs inside it and draws the
|
|
8
|
-
* `$prefab` payload. `registerViewerResource` in `./resource.ts` sets that up.
|
|
9
|
-
* - **A2UI (`a2ui://`)** ships the UI *description*. No iframe and no
|
|
10
|
-
* renderer of prefab's: the host's own A2UI renderer draws native widgets
|
|
11
|
-
* from the component list.
|
|
12
|
-
*
|
|
13
|
-
* A server can offer both from the same tool. The A2UI payload is identified by
|
|
14
|
-
* the `application/a2ui+json` MIME type, either as a standalone resource or as
|
|
15
|
-
* an `EmbeddedResource` inside a tool result, which is what
|
|
16
|
-
* [A2UI over MCP](https://a2ui.org/guides/a2ui_over_mcp/) specifies.
|
|
17
|
-
*
|
|
18
|
-
* The payload itself is the list-wrapper envelope `{ messages: [...] }` rather
|
|
19
|
-
* than a bare array, because a resource body has to be a JSON object.
|
|
2
|
+
* A2UI over MCP (`a2ui://`): the UI description as `application/a2ui+json`, drawn by the host's own A2UI renderer,
|
|
3
|
+
* where `ui://` ships prefab's renderer in an iframe. See https://a2ui.org/guides/a2ui_over_mcp/.
|
|
20
4
|
*/
|
|
21
5
|
import { PrefabApp } from '../app.js';
|
|
22
6
|
import { createLogger } from '../core/logger.js';
|
|
@@ -24,11 +8,7 @@ import { emitA2UI } from '../a2ui/emit.js';
|
|
|
24
8
|
import { A2UI_MIME, A2UI_SCHEME } from '../a2ui/types.js';
|
|
25
9
|
import { resolveCache } from './resource.js';
|
|
26
10
|
const log = createLogger('a2ui');
|
|
27
|
-
/**
|
|
28
|
-
* An A2UI surface is rebuilt on every read, so it defaults to no caching. That
|
|
29
|
-
* is the opposite of the viewer HTML in `./resource.ts`, which is pinned to the
|
|
30
|
-
* package version and safely shared-cacheable.
|
|
31
|
-
*/
|
|
11
|
+
/** A surface is rebuilt on every read, so it is not cached unless the caller says so. */
|
|
32
12
|
const DEFAULT_SURFACE_CACHE = { ttlMs: 0, cacheScope: 'private' };
|
|
33
13
|
/** Default URI for a server that serves a single A2UI surface. */
|
|
34
14
|
export const A2UI_RESOURCE_URI = `${A2UI_SCHEME}prefab/surface`;
|
|
@@ -49,11 +29,7 @@ function reportDiagnostics(diagnostics, options) {
|
|
|
49
29
|
}
|
|
50
30
|
}
|
|
51
31
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* The messages travel as an `EmbeddedResource` in `content`, which is where a
|
|
55
|
-
* host looks for a payload it should route to its A2UI renderer, and as
|
|
56
|
-
* `structuredContent` for hosts that read results structurally.
|
|
32
|
+
* A view as an A2UI tool result: an `EmbeddedResource` in `content`, and the same payload as `structuredContent`.
|
|
57
33
|
*
|
|
58
34
|
* @example
|
|
59
35
|
* ```ts
|
|
@@ -77,14 +53,8 @@ export function display_a2ui(viewOrApp, options) {
|
|
|
77
53
|
return { content: [embedded], structuredContent: payload };
|
|
78
54
|
}
|
|
79
55
|
/**
|
|
80
|
-
* Register
|
|
81
|
-
*
|
|
82
|
-
* Static is the point: a surface that does not depend on the conversation is
|
|
83
|
-
* cheaper as a resource than as a tool, because the host can read it once and
|
|
84
|
-
* cache it. Anything that varies per call belongs in {@link display_a2ui}.
|
|
85
|
-
*
|
|
86
|
-
* `builder` runs on every read rather than once at registration, so a surface
|
|
87
|
-
* that closes over data refreshes without re-registering.
|
|
56
|
+
* Register an A2UI surface that does not depend on the conversation as an `a2ui://` resource; `builder` runs on every read.
|
|
57
|
+
* Per-call views belong in {@link display_a2ui}.
|
|
88
58
|
*
|
|
89
59
|
* @example
|
|
90
60
|
* ```ts
|
package/dist/mcp/a2ui.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a2ui.js","sourceRoot":"","sources":["../../src/mcp/a2ui.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"a2ui.js","sourceRoot":"","sources":["../../src/mcp/a2ui.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAwB,MAAM,iBAAiB,CAAA;AAChE,OAAO,EAAE,SAAS,EAAE,WAAW,EAA+D,MAAM,kBAAkB,CAAA;AAQtH,OAAO,EAAE,YAAY,EAA2C,MAAM,eAAe,CAAA;AAErF,MAAM,GAAG,GAAG,YAAY,CAAC,MAAM,CAAC,CAAA;AAEhC,yFAAyF;AACzF,MAAM,qBAAqB,GAA2B,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,CAAA;AAEzF,kEAAkE;AAClE,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,WAAW,gBAAgB,CAAA;AAE/D,oFAAoF;AACpF,MAAM,UAAU,WAAW,CAAC,QAAuB;IACjD,OAAO,EAAE,QAAQ,EAAE,CAAA;AACrB,CAAC;AAWD,SAAS,iBAAiB,CAAC,WAA6B,EAAE,OAA4B;IACpF,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAM;IACpC,IAAI,OAAO,EAAE,aAAa,IAAI,IAAI,EAAE,CAAC;QACnC,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,CAAA;QAClC,OAAM;I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K,EAAE,KAAK,CAAC,KAAK;YAClB,UAAU,EAAE,KAAK,CAAC,UAAU;SAC7B,CAAC,CAAA;IACJ,CAAC,CAAA;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IACvF,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,SAAS,CAAC,gFAAgF,CAAC,CAAA;IACvG,CAAC;IACD,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;AACtC,CAAC;AAED,2DAA2D;AAC3D,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-required.d.ts","sourceRoot":"","sources":["../../src/mcp/input-required.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"input-required.d.ts","sourceRoot":"","sources":["../../src/mcp/input-required.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAGpD,OAAO,KAAK,EAEV,eAAe,EACf,sBAAsB,EAEtB,iBAAiB,EAEjB,mBAAmB,EACpB,MAAM,YAAY,CAAA;AAgFnB;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,mBAAmB,CAUvE;AAID,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,sFAAsF;IACtF,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,yFAAyF;IACzF,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,aAAa,EAAE,EACvB,OAAO,CAAC,EAAE,uBAAuB,GAChC,sBAAsB,CAqBxB;AAID,iFAAiF;AACjF,wBAAgB,aAAa,CAC3B,SAAS,EAAE,iBAAiB,GAAG,SAAS,EACxC,GAAG,EAAE,MAAM,GACV,eAAe,GAAG,SAAS,CAE7B;AAED,gDAAgD;AAChD,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,CAAA;AAE5D;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,iBAAiB,GAAG,SAAS,EACxC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,aAAa,EAAE,GACtB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,SAAS,CAyBvC"}
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
37
|
import { createLogger } from '../core/logger.js';
|
|
38
|
+
import { humanizeKey } from '../core/humanize.js';
|
|
38
39
|
const log = createLogger('mcp');
|
|
39
40
|
/** Field `type` values that map onto a wire string format. */
|
|
40
41
|
const STRING_FORMAT = {
|
|
@@ -51,13 +52,6 @@ const NUMERIC = {
|
|
|
51
52
|
range: 'number',
|
|
52
53
|
integer: 'integer',
|
|
53
54
|
};
|
|
54
|
-
/** Humanize a field name the same way `autoForm` does, for schema titles. */
|
|
55
|
-
function humanize(name) {
|
|
56
|
-
return name
|
|
57
|
-
.replace(/[_-]+/g, ' ')
|
|
58
|
-
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
59
|
-
.replace(/\b\w/g, c => c.toUpperCase());
|
|
60
|
-
}
|
|
61
55
|
/**
|
|
62
56
|
* Derive the restricted schema for one field.
|
|
63
57
|
*
|
|
@@ -66,7 +60,7 @@ function humanize(name) {
|
|
|
66
60
|
* render it; the type is dropped rather than misrepresented.
|
|
67
61
|
*/
|
|
68
62
|
function fieldSchema(field) {
|
|
69
|
-
const title = field.label ??
|
|
63
|
+
const title = field.label ?? humanizeKey(field.name);
|
|
70
64
|
const common = { title, ...(field.description != null && { description: field.description }) };
|
|
71
65
|
if (field.options != null && field.options.length > 0) {
|
|
72
66
|
const values = field.options.map(o => o.value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-required.js","sourceRoot":"","sources":["../../src/mcp/input-required.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"input-required.js","sourceRoot":"","sources":["../../src/mcp/input-required.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAWjD,MAAM,GAAG,GAAG,YAAY,CAAC,KAAK,CAAC,CAAA;AAE/B,8DAA8D;AAC9D,MAAM,aAAa,GAAuE;IACxF,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,WAAW;IACrB,gBAAgB,EAAE,WAAW;CAC9B,CAAA;AAED,wDAAwD;AACxD,MAAM,OAAO,GAAqD;IAChE,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,QAAQ;IACf,OAAO,EAAE,SAAS;CACnB,CAAA;AAED;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,KAAoB;IACvC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACpD,MAAM,MAAM,GAAG,EAAE,K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