@maxhealth.tech/prefab 0.3.18 → 0.3.20
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 +30 -0
- 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/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 +38 -64
- 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/charts/props.d.ts.map +1 -1
- package/dist/renderer/components/charts/props.js +3 -2
- package/dist/renderer/components/charts/props.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 +20 -20
- package/dist/renderer/index.js.map +1 -1
- package/dist/renderer/rx.d.ts.map +1 -1
- package/dist/renderer/rx.js +17 -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 +1 -1
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,GAAsB,EAAE,CAAA;IACpC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,KAAK,CAAA;IAEnC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACpB,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,qCAAqC,EAAE,CAAC,CAAA;QAC1E,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,CAAA;IACjC,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,CAAA;IAChB,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAA;IAC1B,IAAI,CAAC,QAAQ,CAAC,M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C,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC,CAAA;QACrE,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,KAAc,EAAE,MAAyB;IAC9D,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACrB,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,8BAA8B,EAAE,CAAC,CAAA;QACzE,OAAM;IACR,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC;QACrC,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;YAC9B,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;gBAC3B,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,IAAI,EAAE,EAAE,OAAO,EAAE,SAAS,IAAI,yBAAyB,EAAE,CAAC,CAAA;YAC3F,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/core/version.d.ts
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 declare const VERSION = "0.3.18";
|
|
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.20";
|
|
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.18';
|
|
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.20';
|
|
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":"AAAA
|
|
1
|
+
{"version":3,"file":"a2ui.d.ts","sourceRoot":"","sources":["../../src/mcp/a2ui.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAErD,OAAO,EAAY,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAChE,OAAO,EAA0B,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACtH,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAIjB,MAAM,YAAY,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|
-
*
|
|
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,EAA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;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,EA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,CAAA;AACb,CAAC"}
|
package/dist/mcp/resource.d.ts
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP Apps resource helpers — register the prefab viewer as a `ui://` resource.
|
|
3
|
-
*
|
|
4
|
-
* Covers the three things every MCP Apps host checks and the two the
|
|
5
|
-
* 2026-07-28 protocol revision added:
|
|
6
|
-
* - the `text/html;profile=mcp-app` MIME type,
|
|
7
|
-
* - `_meta.ui` CSP / permissions on BOTH the listing and the content item,
|
|
8
|
-
* - the viewer HTML itself (CDN-pinned to this exact package version),
|
|
9
|
-
* - `ttlMs` / `cacheScope` on the read result (SEP-2549 `CacheableResult`),
|
|
10
|
-
* - the `io.modelcontextprotocol/ui` extension capability (SEP-2133).
|
|
11
|
-
*/
|
|
1
|
+
/** Register the prefab viewer as a `ui://` MCP Apps resource: MIME type, `_meta.ui` on listing and content, CDN-pinned HTML, cache fields, extension capability. */
|
|
12
2
|
import type { McpCacheHint, McpResourceReadResult, McpTextResourceContents } from './types.js';
|
|
13
3
|
import { type ThemeBridge } from './theme-bridge.js';
|
|
14
4
|
/** CSP configuration for MCP Apps resources. */
|
|
@@ -47,11 +37,7 @@ interface McpAppPermissionsWire {
|
|
|
47
37
|
clipboardWrite?: Record<string, never>;
|
|
48
38
|
}
|
|
49
39
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* Includes CSP and Permission Policy configuration per the MCP Apps spec.
|
|
53
|
-
* Use on both the resource listing AND the content item (VS Code reads
|
|
54
|
-
* only the content item; other hosts may read either).
|
|
40
|
+
* The `_meta` (CSP, permissions) for a `ui://` resource. Put it on the listing and the content item: VS Code reads only the latter.
|
|
55
41
|
*
|
|
56
42
|
* @example
|
|
57
43
|
* ```ts
|
|
@@ -96,33 +82,9 @@ export declare const PREFAB_CDN_META: {
|
|
|
96
82
|
export declare const PREFAB_RESOURCE_URI = "ui://prefab/viewer";
|
|
97
83
|
/** MIME type required by MCP Apps hosts. */
|
|
98
84
|
export declare const MCP_APP_MIME = "text/html;profile=mcp-app";
|
|
99
|
-
/**
|
|
100
|
-
* Capability key for the MCP Apps extension (versioned independently of core).
|
|
101
|
-
*
|
|
102
|
-
* The identifier is `…/ui`, and the trap here is that `…/apps` looks right and is
|
|
103
|
-
* wrong. The normative source is the MCP Apps spec, which states "This extension is
|
|
104
|
-
* identified as: `io.modelcontextprotocol/ui`" in both the current `2026-01-26`
|
|
105
|
-
* revision and the draft, and the reference implementation agrees:
|
|
106
|
-
* `ext-apps/src/server/index.ts` exports `EXTENSION_ID = "io.modelcontextprotocol/ui"`.
|
|
107
|
-
*
|
|
108
|
-
* `io.modelcontextprotocol/apps` appears only as illustrative "e.g." text in the Rust
|
|
109
|
-
* and C# SDKs' generic `ServerCapabilities.extensions` doc comments (and their test
|
|
110
|
-
* fixtures), showing the SHAPE of the extensions map rather than naming this extension.
|
|
111
|
-
* Copying it from there declares the capability under a key no host looks up, which
|
|
112
|
-
* fails silently: rendering still works, because hosts fall back to detecting apps via
|
|
113
|
-
* `_meta.ui` plus the MIME type, so only the SEP-2133 declaration is lost.
|
|
114
|
-
*
|
|
115
|
-
* Duplicated as a literal rather than imported, because prefab ships zero dependencies.
|
|
116
|
-
*/
|
|
85
|
+
/** The MCP Apps extension id, `…/ui` per the spec and ext-apps (`…/apps` in some SDK doc examples is only illustrative). */
|
|
117
86
|
export declare const APPS_EXTENSION = "io.modelcontextprotocol/ui";
|
|
118
|
-
/**
|
|
119
|
-
* Default cache hint for the viewer resource.
|
|
120
|
-
*
|
|
121
|
-
* The HTML is a pure function of this package's `VERSION` (the CDN base pins
|
|
122
|
-
* the exact version), so it cannot change for a given server build — it is
|
|
123
|
-
* safely shared-cacheable. Without this the SDK falls back to the conservative
|
|
124
|
-
* `{ ttlMs: 0, cacheScope: 'private' }` and the viewer is re-fetched every time.
|
|
125
|
-
*/
|
|
87
|
+
/** Viewer cache hint: the HTML is a pure function of `VERSION`, so it is shared-cacheable for a day. */
|
|
126
88
|
export declare const DEFAULT_VIEWER_CACHE: Required<McpCacheHint>;
|
|
127
89
|
export interface RendererHtmlOptions {
|
|
128
90
|
/** Page title. @default 'Prefab' */
|
|
@@ -133,21 +95,11 @@ export interface RendererHtmlOptions {
|
|
|
133
95
|
stylesheets?: string[];
|
|
134
96
|
/** Override CDN base URL (no trailing slash). @default jsdelivr CDN */
|
|
135
97
|
cdnBase?: string;
|
|
136
|
-
/**
|
|
137
|
-
* Inject a theme bridge stylesheet after `prefab.css`.
|
|
138
|
-
*
|
|
139
|
-
* `'vscode'` re-declares the tokens VS Code can supply with the
|
|
140
|
-
* `--vscode-*` variable first, dropping the MCP Apps `--color-*` layer that
|
|
141
|
-
* would otherwise shadow it, so the viewer follows the user's editor theme.
|
|
142
|
-
* Emitted before `stylesheets`, which stay the outermost override.
|
|
143
|
-
*/
|
|
98
|
+
/** Theme bridge stylesheet after `prefab.css` (before `stylesheets`); `'vscode'` follows the editor theme. */
|
|
144
99
|
themeBridge?: ThemeBridge;
|
|
145
100
|
}
|
|
146
101
|
/**
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
* Returns the minimal HTML that loads `prefab.css` and `renderer.auto.min.js`
|
|
150
|
-
* from the CDN, plus any additional scripts/stylesheets you specify.
|
|
102
|
+
* The viewer HTML: `prefab.css` and `renderer.auto.min.js` from the CDN, plus your scripts and stylesheets.
|
|
151
103
|
*
|
|
152
104
|
* @example
|
|
153
105
|
* ```ts
|
|
@@ -175,22 +127,11 @@ export interface ViewerResourceOptions {
|
|
|
175
127
|
stylesheets?: string[];
|
|
176
128
|
/** Override CDN base URL (no trailing slash). */
|
|
177
129
|
cdnBase?: string;
|
|
178
|
-
/**
|
|
179
|
-
* Inject a theme bridge stylesheet. `'vscode'` makes the viewer follow the
|
|
180
|
-
* user's editor theme. See {@link RendererHtmlOptions.themeBridge}.
|
|
181
|
-
*/
|
|
130
|
+
/** See {@link RendererHtmlOptions.themeBridge}. */
|
|
182
131
|
themeBridge?: ThemeBridge;
|
|
183
|
-
/**
|
|
184
|
-
* Cache fields for the `resources/read` result (SEP-2549).
|
|
185
|
-
* @default { ttlMs: 86_400_000, cacheScope: 'public' }
|
|
186
|
-
*/
|
|
132
|
+
/** Cache fields for the `resources/read` result (SEP-2549). @default { ttlMs: 86_400_000, cacheScope: 'public' } */
|
|
187
133
|
cache?: McpCacheHint;
|
|
188
|
-
/**
|
|
189
|
-
* Declare the `io.modelcontextprotocol/ui` extension capability on the
|
|
190
|
-
* server (SEP-2133). Must happen before the server connects; a server that
|
|
191
|
-
* is already connected keeps its existing capabilities and a warning is
|
|
192
|
-
* logged. @default true
|
|
193
|
-
*/
|
|
134
|
+
/** Declare the `io.modelcontextprotocol/ui` capability (SEP-2133); only works before the server connects. @default true */
|
|
194
135
|
declareCapability?: boolean;
|
|
195
136
|
}
|
|
196
137
|
/** Registration config accepted by both SDK generations. */
|
|
@@ -208,13 +149,7 @@ export type ResourceReadHandler = (uri: URL) => Promise<McpResourceReadResult<Mc
|
|
|
208
149
|
interface CapabilityDeclaration {
|
|
209
150
|
extensions?: Record<string, Record<string, unknown>>;
|
|
210
151
|
}
|
|
211
|
-
/**
|
|
212
|
-
* MCP server interface expected by registerViewerResource.
|
|
213
|
-
*
|
|
214
|
-
* Structural rather than an SDK import, so fastmcp and hand-rolled servers stay
|
|
215
|
-
* compatible. `registerResource` is preferred; `resource` is the v1 overload
|
|
216
|
-
* that v2 retired and is used only as a fallback.
|
|
217
|
-
*/
|
|
152
|
+
/** The server shape registerViewerResource needs, structural so any SDK fits; `resource` is the v1 fallback. */
|
|
218
153
|
export interface McpServerLike {
|
|
219
154
|
registerResource?(name: string, uri: string, config: ResourceConfig, handler: ResourceReadHandler): unknown;
|
|
220
155
|
resource?(name: string, uri: string, config: ResourceConfig, handler: ResourceReadHandler): unknown;
|
|
@@ -225,21 +160,10 @@ export interface McpServerLike {
|
|
|
225
160
|
/** Some wrappers expose capability registration directly. */
|
|
226
161
|
registerCapabilities?(capabilities: CapabilityDeclaration): void;
|
|
227
162
|
}
|
|
228
|
-
/**
|
|
229
|
-
* Fill in and validate the `CacheableResult` fields, rejecting values the SDK
|
|
230
|
-
* would silently discard in favour of `ttlMs: 0`.
|
|
231
|
-
*
|
|
232
|
-
* `defaults` differ per resource kind: the viewer HTML is a pure function of the
|
|
233
|
-
* package version and is safely shared-cacheable, while an `a2ui://` surface is
|
|
234
|
-
* rebuilt on every read and defaults to no caching. Exported so `./a2ui.ts`
|
|
235
|
-
* resolves its hints through the same guard rather than restating it.
|
|
236
|
-
*/
|
|
163
|
+
/** Fill in and validate `CacheableResult` fields, throwing on values the SDK would silently replace with `ttlMs: 0`. */
|
|
237
164
|
export declare function resolveCache(hint?: McpCacheHint, defaults?: Required<McpCacheHint>): Required<McpCacheHint>;
|
|
238
165
|
/**
|
|
239
|
-
* Register the prefab viewer as a `ui://` resource
|
|
240
|
-
*
|
|
241
|
-
* Handles the MIME type, CSP on both listing and content item, HTML generation,
|
|
242
|
-
* the `CacheableResult` fields and the Apps extension capability in one call.
|
|
166
|
+
* Register the prefab viewer as a `ui://` resource. The CSP admits jsDelivr and every origin the page loads from.
|
|
243
167
|
*
|
|
244
168
|
* @example
|
|
245
169
|
* ```ts
|