@maxhealth.tech/prefab 0.3.9 → 0.3.10
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 +27 -0
- package/README.md +76 -10
- package/dist/a2ui/browser.d.ts +46 -0
- package/dist/a2ui/browser.d.ts.map +1 -0
- package/dist/a2ui/browser.js +58 -0
- package/dist/a2ui/browser.js.map +1 -0
- package/dist/a2ui/catalog.d.ts +51 -0
- package/dist/a2ui/catalog.d.ts.map +1 -0
- package/dist/a2ui/catalog.js +465 -0
- package/dist/a2ui/catalog.js.map +1 -0
- package/dist/a2ui/emit.d.ts +59 -0
- package/dist/a2ui/emit.d.ts.map +1 -0
- package/dist/a2ui/emit.js +269 -0
- package/dist/a2ui/emit.js.map +1 -0
- package/dist/a2ui/expr.d.ts +58 -0
- package/dist/a2ui/expr.d.ts.map +1 -0
- package/dist/a2ui/expr.js +81 -0
- package/dist/a2ui/expr.js.map +1 -0
- package/dist/a2ui/icons.d.ts +30 -0
- package/dist/a2ui/icons.d.ts.map +1 -0
- package/dist/a2ui/icons.js +87 -0
- package/dist/a2ui/icons.js.map +1 -0
- package/dist/a2ui/index.d.ts +27 -0
- package/dist/a2ui/index.d.ts.map +1 -0
- package/dist/a2ui/index.js +23 -0
- package/dist/a2ui/index.js.map +1 -0
- package/dist/a2ui/table.d.ts +31 -0
- package/dist/a2ui/table.d.ts.map +1 -0
- package/dist/a2ui/table.js +155 -0
- package/dist/a2ui/table.js.map +1 -0
- package/dist/a2ui/types.d.ts +174 -0
- package/dist/a2ui/types.d.ts.map +1 -0
- package/dist/a2ui/types.js +35 -0
- package/dist/a2ui/types.js.map +1 -0
- package/dist/a2ui.min.js +1 -0
- package/dist/app.d.ts +17 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +19 -0
- package/dist/app.js.map +1 -1
- package/dist/auto/form.d.ts +25 -0
- package/dist/auto/form.d.ts.map +1 -1
- package/dist/auto/form.js +21 -8
- package/dist/auto/form.js.map +1 -1
- package/dist/core/version.d.ts +1 -1
- package/dist/core/version.d.ts.map +1 -1
- package/dist/core/version.js +1 -1
- package/dist/core/version.js.map +1 -1
- package/dist/index.d.ts +9 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/a2ui.d.ts +91 -0
- package/dist/mcp/a2ui.d.ts.map +1 -0
- package/dist/mcp/a2ui.js +134 -0
- package/dist/mcp/a2ui.js.map +1 -0
- package/dist/mcp/display.d.ts +28 -6
- package/dist/mcp/display.d.ts.map +1 -1
- package/dist/mcp/display.js +10 -9
- package/dist/mcp/display.js.map +1 -1
- package/dist/mcp/index.d.ts +7 -2
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +3 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/input-required.d.ts +79 -0
- package/dist/mcp/input-required.d.ts.map +1 -0
- package/dist/mcp/input-required.js +231 -0
- package/dist/mcp/input-required.js.map +1 -0
- package/dist/mcp/resource.d.ts +10 -0
- package/dist/mcp/resource.d.ts.map +1 -1
- package/dist/mcp/resource.js +12 -4
- package/dist/mcp/resource.js.map +1 -1
- package/dist/mcp/result.d.ts +7 -5
- package/dist/mcp/result.d.ts.map +1 -1
- package/dist/mcp/result.js +5 -3
- package/dist/mcp/result.js.map +1 -1
- package/dist/mcp/types.d.ts +117 -0
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/renderer/components/index.d.ts.map +1 -1
- package/dist/renderer/components/index.js +6 -0
- package/dist/renderer/components/index.js.map +1 -1
- package/dist/renderer/engine.d.ts +4 -0
- package/dist/renderer/engine.d.ts.map +1 -1
- package/dist/renderer/engine.js +24 -0
- package/dist/renderer/engine.js.map +1 -1
- package/dist/renderer.auto.min.js +13 -13
- package/dist/renderer.min.js +13 -13
- package/package.json +13 -3
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Table mappers — the one place a prefab component gains structure on the way
|
|
3
|
+
* out rather than losing it.
|
|
4
|
+
*
|
|
5
|
+
* The A2UI Basic catalog has no table component, so a table becomes a `Column`
|
|
6
|
+
* of `Row`s. For `DataTable` that would be a poor trade, because prefab's table
|
|
7
|
+
* is data-driven and flattening it would inline every row as its own component
|
|
8
|
+
* and lose the binding. A2UI's own answer is the child template: a `Column`
|
|
9
|
+
* whose `children` is `{ path, componentId }` instantiates one copy of the
|
|
10
|
+
* template component per item in a data-model list, and paths inside the
|
|
11
|
+
* template resolve relative to the current item. That maps onto `DataTable`
|
|
12
|
+
* exactly — one `Row` template, one `Text` per column bound to the column key —
|
|
13
|
+
* so the emitted surface stays as small and as reactive as the prefab original.
|
|
14
|
+
*
|
|
15
|
+
* The pattern follows `catalogs/basic/examples/18_track-list.json` in the A2UI
|
|
16
|
+
* specification, which is the normative example for templated lists.
|
|
17
|
+
*/
|
|
18
|
+
import type { ComponentJSON } from '../core/component.js';
|
|
19
|
+
import type { A2uiProps, EmitContext } from './catalog.js';
|
|
20
|
+
/** prefab table parts that only exist inside a `Table` and never map on their own. */
|
|
21
|
+
export declare const TABLE_PART_TYPES: readonly ["TableHead", "TableBody", "TableFooter", "TableRow", "TableCell", "TableHeader", "ExpandableRow"];
|
|
22
|
+
/**
|
|
23
|
+
* `DataTable` → a header `Row` plus a templated `Column`.
|
|
24
|
+
*
|
|
25
|
+
* A column key containing a `.` addresses a nested field on the row. Relative
|
|
26
|
+
* paths inside a template are JSON Pointers too, so the dots become slashes.
|
|
27
|
+
*/
|
|
28
|
+
export declare function mapDataTable(node: ComponentJSON, ctx: EmitContext): A2uiProps | undefined;
|
|
29
|
+
/** `Table` → a `Column` of `Row`s, one per `TableRow`. */
|
|
30
|
+
export declare function mapTable(node: ComponentJSON, ctx: EmitContext): A2uiProps | undefined;
|
|
31
|
+
//# sourceMappingURL=table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/a2ui/table.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAG1D,sFAAsF;AACtF,eAAO,MAAM,gBAAgB,6GAEnB,CAAA;AAyCV;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,aAAa,EAAE,GAAG,EAAE,WAAW,GAAG,SAAS,GAAG,SAAS,CAkCzF;AAyCD,0DAA0D;AAC1D,wBAAgB,QAAQ,CAAC,IAAI,EAAE,aAAa,EAAE,GAAG,EAAE,WAAW,GAAG,SAAS,GAAG,SAAS,CAkBrF"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Table mappers — the one place a prefab component gains structure on the way
|
|
3
|
+
* out rather than losing it.
|
|
4
|
+
*
|
|
5
|
+
* The A2UI Basic catalog has no table component, so a table becomes a `Column`
|
|
6
|
+
* of `Row`s. For `DataTable` that would be a poor trade, because prefab's table
|
|
7
|
+
* is data-driven and flattening it would inline every row as its own component
|
|
8
|
+
* and lose the binding. A2UI's own answer is the child template: a `Column`
|
|
9
|
+
* whose `children` is `{ path, componentId }` instantiates one copy of the
|
|
10
|
+
* template component per item in a data-model list, and paths inside the
|
|
11
|
+
* template resolve relative to the current item. That maps onto `DataTable`
|
|
12
|
+
* exactly — one `Row` template, one `Text` per column bound to the column key —
|
|
13
|
+
* so the emitted surface stays as small and as reactive as the prefab original.
|
|
14
|
+
*
|
|
15
|
+
* The pattern follows `catalogs/basic/examples/18_track-list.json` in the A2UI
|
|
16
|
+
* specification, which is the normative example for templated lists.
|
|
17
|
+
*/
|
|
18
|
+
import { dynamicString, toBinding } from './expr.js';
|
|
19
|
+
/** prefab table parts that only exist inside a `Table` and never map on their own. */
|
|
20
|
+
export const TABLE_PART_TYPES = [
|
|
21
|
+
'TableHead', 'TableBody', 'TableFooter', 'TableRow', 'TableCell', 'TableHeader', 'ExpandableRow',
|
|
22
|
+
];
|
|
23
|
+
/** Read a `DataTable`'s serialized column definitions defensively. */
|
|
24
|
+
function columnDefs(node) {
|
|
25
|
+
if (!Array.isArray(node.columns))
|
|
26
|
+
return [];
|
|
27
|
+
const defs = [];
|
|
28
|
+
for (const raw of node.columns) {
|
|
29
|
+
if (raw == null || typeof raw !== 'object')
|
|
30
|
+
continue;
|
|
31
|
+
const col = raw;
|
|
32
|
+
const key = typeof col.accessor === 'string' ? col.accessor : typeof col.key === 'string' ? col.key : undefined;
|
|
33
|
+
if (key == null)
|
|
34
|
+
continue;
|
|
35
|
+
defs.push({ key, header: typeof col.header === 'string' ? col.header : key });
|
|
36
|
+
}
|
|
37
|
+
return defs;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Resolve where the row list lives in the data model.
|
|
41
|
+
*
|
|
42
|
+
* `rows` is either a `{{ }}` expression already pointing at surface state, or a
|
|
43
|
+
* literal array, which is seeded into the data model under a generated key so
|
|
44
|
+
* the template has something to iterate.
|
|
45
|
+
*/
|
|
46
|
+
function rowsPointer(node, ctx) {
|
|
47
|
+
const rows = node.rows;
|
|
48
|
+
if (typeof rows === 'string') {
|
|
49
|
+
const bound = toBinding(rows);
|
|
50
|
+
if (bound.kind === 'binding')
|
|
51
|
+
return bound.value.path;
|
|
52
|
+
ctx.note('expression', 'DataTable', `rows expression "${rows}" is not a plain path; the table has no data source`);
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
if (Array.isArray(rows))
|
|
56
|
+
return ctx.bindData('rows', rows);
|
|
57
|
+
ctx.note('unsupported', 'DataTable', 'no rows to render');
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* `DataTable` → a header `Row` plus a templated `Column`.
|
|
62
|
+
*
|
|
63
|
+
* A column key containing a `.` addresses a nested field on the row. Relative
|
|
64
|
+
* paths inside a template are JSON Pointers too, so the dots become slashes.
|
|
65
|
+
*/
|
|
66
|
+
export function mapDataTable(node, ctx) {
|
|
67
|
+
const columns = columnDefs(node);
|
|
68
|
+
if (columns.length === 0) {
|
|
69
|
+
ctx.note('unsupported', 'DataTable', 'no usable column definitions');
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
const path = rowsPointer(node, ctx);
|
|
73
|
+
if (path == null)
|
|
74
|
+
return undefined;
|
|
75
|
+
const headerRow = ctx.push({
|
|
76
|
+
component: 'Row',
|
|
77
|
+
children: columns.map(c => ctx.push({ component: 'Text', text: c.header, variant: 'caption' })),
|
|
78
|
+
align: 'center',
|
|
79
|
+
});
|
|
80
|
+
const template = ctx.push({
|
|
81
|
+
component: 'Row',
|
|
82
|
+
children: columns.map(c => ctx.push({
|
|
83
|
+
component: 'Text',
|
|
84
|
+
// Relative pointer: no leading slash, so it resolves against the current row.
|
|
85
|
+
text: { path: c.key.split('.').join('/') },
|
|
86
|
+
})),
|
|
87
|
+
align: 'center',
|
|
88
|
+
});
|
|
89
|
+
// A2UI's templated-children form: one instance of `template` per item at `path`.
|
|
90
|
+
const list = ctx.push({ component: 'Column', children: { path, componentId: template } });
|
|
91
|
+
if (node.search === true || node.paginated === true) {
|
|
92
|
+
ctx.note('degraded', 'DataTable', 'search and pagination dropped; A2UI Basic has no table controls');
|
|
93
|
+
}
|
|
94
|
+
return { component: 'Column', children: [headerRow, list] };
|
|
95
|
+
}
|
|
96
|
+
// ── Static Table ─────────────────────────────────────────────────────────────
|
|
97
|
+
/** Collect the `TableRow` nodes nested under a `Table`'s section wrappers. */
|
|
98
|
+
function tableRows(node) {
|
|
99
|
+
const rows = [];
|
|
100
|
+
const visit = (n) => {
|
|
101
|
+
if (n.type === 'TableRow' || n.type === 'ExpandableRow') {
|
|
102
|
+
rows.push(n);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (Array.isArray(n.children))
|
|
106
|
+
for (const c of n.children)
|
|
107
|
+
visit(c);
|
|
108
|
+
};
|
|
109
|
+
if (Array.isArray(node.children))
|
|
110
|
+
for (const c of node.children)
|
|
111
|
+
visit(c);
|
|
112
|
+
return rows;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Emit one table cell.
|
|
116
|
+
*
|
|
117
|
+
* A cell holding components delegates to them; a cell holding only text becomes
|
|
118
|
+
* a `Text`, with header cells marked as captions so the header row still reads
|
|
119
|
+
* as a header after the table structure is gone.
|
|
120
|
+
*/
|
|
121
|
+
function cell(node, ctx) {
|
|
122
|
+
const isHeader = node.type === 'TableHeader';
|
|
123
|
+
if (Array.isArray(node.children) && node.children.length > 0) {
|
|
124
|
+
return ctx.single(node.children);
|
|
125
|
+
}
|
|
126
|
+
const raw = node.content ?? node.text ?? node.label;
|
|
127
|
+
if (typeof raw !== 'string' && typeof raw !== 'number' && typeof raw !== 'boolean')
|
|
128
|
+
return undefined;
|
|
129
|
+
const content = String(raw);
|
|
130
|
+
const text = dynamicString(content);
|
|
131
|
+
if (text == null) {
|
|
132
|
+
ctx.note('expression', node.type, `cell expression "${content}" has no A2UI equivalent`);
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
return ctx.push({ component: 'Text', text, ...(isHeader && { variant: 'caption' }) });
|
|
136
|
+
}
|
|
137
|
+
/** `Table` → a `Column` of `Row`s, one per `TableRow`. */
|
|
138
|
+
export function mapTable(node, ctx) {
|
|
139
|
+
const rows = tableRows(node);
|
|
140
|
+
const emitted = [];
|
|
141
|
+
for (const row of rows) {
|
|
142
|
+
const cells = Array.isArray(row.children) ? row.children : [];
|
|
143
|
+
const ids = cells.map(c => cell(c, ctx)).filter((id) => id != null);
|
|
144
|
+
if (ids.length === 0)
|
|
145
|
+
continue;
|
|
146
|
+
emitted.push(ctx.push({ component: 'Row', children: ids, align: 'center' }));
|
|
147
|
+
}
|
|
148
|
+
if (emitted.length === 0) {
|
|
149
|
+
ctx.note('unsupported', 'Table', 'no rows with renderable cells');
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
152
|
+
ctx.note('degraded', 'Table', 'rendered as a Column of Rows; column widths do not align');
|
|
153
|
+
return { component: 'Column', children: emitted };
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table.js","sourceRoot":"","sources":["../../src/a2ui/table.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAEpD,sFAAsF;AACtF,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,eAAe;CACxF,CAAA;AAOV,sEAAsE;AACtE,SAAS,UAAU,CAAC,IAAmB;IACrC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;QAAE,OAAO,EAAE,CAAA;IAC3C,MAAM,IAAI,GAAgB,EAAE,CAAA;IAC5B,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,GAAG,IAAI,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;YAAE,SAAQ;QACpD,MAAM,GAAG,GAAG,GAA8B,CAAA;QAC1C,MAAM,GAAG,GAAG,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAA;QAC/G,IAAI,GAAG,IAAI,IAAI;YAAE,SAAQ;QACzB,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,GAAG,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC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I,CAAC,UAAU,EAAE,OAAO,EAAE,0DAA0D,CAAC,CAAA;IACzF,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAA;AACnD,CAAC"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2UI v1.0 wire types.
|
|
3
|
+
*
|
|
4
|
+
* A2UI (`a2ui.org`) is the declarative agent-to-UI protocol: the agent streams
|
|
5
|
+
* JSON describing a component tree plus a data model, and the renderer maps the
|
|
6
|
+
* abstract component names onto its own widgets. prefab emits it as a second
|
|
7
|
+
* output target alongside the `$prefab` wire format.
|
|
8
|
+
*
|
|
9
|
+
* Two structural differences drive the whole emitter:
|
|
10
|
+
*
|
|
11
|
+
* 1. **Flat, not nested.** A2UI components live in an adjacency list — every
|
|
12
|
+
* component carries an `id`, and parents reference children by id rather
|
|
13
|
+
* than embedding them. `$prefab` nests `children` directly.
|
|
14
|
+
* 2. **Bound, not interpolated.** A2UI reads dynamic values through JSON
|
|
15
|
+
* Pointer `{ path }` bindings into the data model. `$prefab` interpolates
|
|
16
|
+
* `{{ expr }}` templates, which is strictly more expressive, so only the
|
|
17
|
+
* plain-path subset survives the crossing (see `./expr.ts`).
|
|
18
|
+
*
|
|
19
|
+
* Mirrors `specification/v1_0/json/agent_to_renderer.json` and
|
|
20
|
+
* `catalogs/basic/catalog.json` from a2ui-project/a2ui (Apache-2.0). Only the
|
|
21
|
+
* agent-to-renderer direction is modelled: prefab produces UI, it does not
|
|
22
|
+
* consume renderer events.
|
|
23
|
+
*/
|
|
24
|
+
/** Protocol version stamped on every emitted message. */
|
|
25
|
+
export declare const A2UI_VERSION = "v1.0";
|
|
26
|
+
/** Canonical id of the A2UI Basic catalog, the component set prefab targets. */
|
|
27
|
+
export declare const A2UI_BASIC_CATALOG = "https://a2ui.org/specification/v1_0/catalogs/basic/catalog.json";
|
|
28
|
+
/** MIME type identifying an A2UI payload over MCP. */
|
|
29
|
+
export declare const A2UI_MIME = "application/a2ui+json";
|
|
30
|
+
/** URI scheme for A2UI resources served over MCP. */
|
|
31
|
+
export declare const A2UI_SCHEME = "a2ui://";
|
|
32
|
+
/** The reserved root component id every surface starts from. */
|
|
33
|
+
export declare const A2UI_ROOT_ID = "root";
|
|
34
|
+
/** A JSON Pointer binding into the surface data model. */
|
|
35
|
+
export interface A2uiDataBinding {
|
|
36
|
+
path: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A call to a catalog function, used for formatting and validation.
|
|
40
|
+
*
|
|
41
|
+
* The function name lives under `call`, and the object IS the call — it is not
|
|
42
|
+
* wrapped in a `functionCall` key. That wrapper appears only where a function
|
|
43
|
+
* stands in for an {@link A2uiAction}.
|
|
44
|
+
*/
|
|
45
|
+
export interface A2uiFunctionCall {
|
|
46
|
+
call: string;
|
|
47
|
+
catalogId?: string;
|
|
48
|
+
args?: Record<string, A2uiDynamicValue>;
|
|
49
|
+
}
|
|
50
|
+
export type A2uiDynamicString = string | A2uiDataBinding | A2uiFunctionCall;
|
|
51
|
+
export type A2uiDynamicNumber = number | A2uiDataBinding | A2uiFunctionCall;
|
|
52
|
+
export type A2uiDynamicBoolean = boolean | A2uiDataBinding | A2uiFunctionCall;
|
|
53
|
+
export type A2uiDynamicValue = string | number | boolean | null | A2uiDataBinding | A2uiFunctionCall;
|
|
54
|
+
/** Dispatches a named event back to the agent. */
|
|
55
|
+
export interface A2uiEventAction {
|
|
56
|
+
event: {
|
|
57
|
+
name: string;
|
|
58
|
+
userMessage?: A2uiDynamicString;
|
|
59
|
+
context?: Record<string, A2uiDynamicValue>;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/** Runs a renderer-side catalog function without involving the agent. */
|
|
63
|
+
export interface A2uiFunctionAction {
|
|
64
|
+
functionCall: A2uiFunctionCall;
|
|
65
|
+
}
|
|
66
|
+
export type A2uiAction = A2uiEventAction | A2uiFunctionAction;
|
|
67
|
+
/** Accessibility attributes carried on any component. */
|
|
68
|
+
export interface A2uiAccessibility {
|
|
69
|
+
label?: A2uiDynamicString;
|
|
70
|
+
description?: A2uiDynamicString;
|
|
71
|
+
live?: 'off' | 'polite' | 'assertive';
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* One entry in a surface's adjacency list.
|
|
75
|
+
*
|
|
76
|
+
* The index signature carries catalog-specific props (`text`, `url`, `options`,
|
|
77
|
+
* …) that vary per component, which is how the catalog stays open to component
|
|
78
|
+
* sets beyond Basic without a type per component.
|
|
79
|
+
*/
|
|
80
|
+
export interface A2uiComponentProps {
|
|
81
|
+
component: string;
|
|
82
|
+
catalogId?: string;
|
|
83
|
+
accessibility?: A2uiAccessibility;
|
|
84
|
+
metadata?: {
|
|
85
|
+
extensions?: Record<string, unknown>;
|
|
86
|
+
};
|
|
87
|
+
[prop: string]: unknown;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Split from {@link A2uiComponentProps} by extension rather than by
|
|
91
|
+
* `Omit<A2uiComponent, 'id'>`. `Omit` resolves `keyof` to `string | number`
|
|
92
|
+
* on a type carrying an index signature, which erases every named property, so
|
|
93
|
+
* the omitted form would no longer be known to supply `component`.
|
|
94
|
+
*/
|
|
95
|
+
export interface A2uiComponent extends A2uiComponentProps {
|
|
96
|
+
id: string;
|
|
97
|
+
}
|
|
98
|
+
/** A template that instantiates one component per item in a data-model list. */
|
|
99
|
+
export interface A2uiChildTemplate {
|
|
100
|
+
componentId: string;
|
|
101
|
+
path: string;
|
|
102
|
+
}
|
|
103
|
+
export type A2uiChildList = string[] | A2uiChildTemplate;
|
|
104
|
+
export interface A2uiCreateSurface {
|
|
105
|
+
surfaceId: string;
|
|
106
|
+
catalogId?: string;
|
|
107
|
+
sendDataModel?: boolean;
|
|
108
|
+
components?: A2uiComponent[];
|
|
109
|
+
dataModel?: Record<string, unknown>;
|
|
110
|
+
metadata?: {
|
|
111
|
+
extensions?: Record<string, unknown>;
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
export interface A2uiUpdateComponents {
|
|
115
|
+
surfaceId: string;
|
|
116
|
+
components: A2uiComponent[];
|
|
117
|
+
}
|
|
118
|
+
export interface A2uiUpdateDataModel {
|
|
119
|
+
surfaceId: string;
|
|
120
|
+
/** Where in the data model to write. Omitted or `/` means the whole model. */
|
|
121
|
+
path?: string;
|
|
122
|
+
/** The data to write. An explicit `null` deletes whatever sits at `path`. */
|
|
123
|
+
value: unknown;
|
|
124
|
+
}
|
|
125
|
+
export interface A2uiDeleteSurface {
|
|
126
|
+
surfaceId: string;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* One agent-to-renderer message.
|
|
130
|
+
*
|
|
131
|
+
* A type alias rather than an interface so it keeps an implicit index
|
|
132
|
+
* signature: these land in `structuredContent`, which the MCP SDK types as
|
|
133
|
+
* `{ [x: string]: unknown }`, and TypeScript grants that signature to object
|
|
134
|
+
* aliases but never to interfaces. Same reasoning as `src/mcp/types.ts`.
|
|
135
|
+
*/
|
|
136
|
+
export type A2uiMessage = {
|
|
137
|
+
version: string;
|
|
138
|
+
createSurface: A2uiCreateSurface;
|
|
139
|
+
} | {
|
|
140
|
+
version: string;
|
|
141
|
+
updateComponents: A2uiUpdateComponents;
|
|
142
|
+
} | {
|
|
143
|
+
version: string;
|
|
144
|
+
updateDataModel: A2uiUpdateDataModel;
|
|
145
|
+
} | {
|
|
146
|
+
version: string;
|
|
147
|
+
deleteSurface: A2uiDeleteSurface;
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* The list-wrapper envelope, for transports that need a top-level JSON object
|
|
151
|
+
* rather than a bare array. This is what prefab writes into an MCP resource or
|
|
152
|
+
* an embedded resource, per `agent_to_renderer_list_wrapper.json`.
|
|
153
|
+
*/
|
|
154
|
+
export type A2uiMessageList = {
|
|
155
|
+
messages: A2uiMessage[];
|
|
156
|
+
};
|
|
157
|
+
/** Why a prefab node could not cross into A2UI unchanged. */
|
|
158
|
+
export type A2uiDiagnosticKind =
|
|
159
|
+
/** No Basic-catalog component covers this type; it was rendered as something simpler. */
|
|
160
|
+
'degraded'
|
|
161
|
+
/** No sensible degradation exists; the node was dropped. */
|
|
162
|
+
| 'unsupported'
|
|
163
|
+
/** A `{{ }}` expression was richer than a JSON Pointer; the binding was dropped. */
|
|
164
|
+
| 'expression'
|
|
165
|
+
/** A prefab action has no agent-side event equivalent. */
|
|
166
|
+
| 'action';
|
|
167
|
+
export interface A2uiDiagnostic {
|
|
168
|
+
kind: A2uiDiagnosticKind;
|
|
169
|
+
/** The prefab component type or action name the diagnostic is about. */
|
|
170
|
+
subject: string;
|
|
171
|
+
/** What the emitter did instead. */
|
|
172
|
+
detail: string;
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/a2ui/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,yDAAyD;AACzD,eAAO,MAAM,YAAY,SAAS,CAAA;AAElC,gFAAgF;AAChF,eAAO,MAAM,kBAAkB,oEAAoE,CAAA;AAEnG,sDAAsD;AACtD,eAAO,MAAM,SAAS,0BAA0B,CAAA;AAEhD,qDAAqD;AACrD,eAAO,MAAM,WAAW,YAAY,CAAA;AAEpC,gEAAgE;AAChE,eAAO,MAAM,YAAY,SAAS,CAAA;AAIlC,0DAA0D;AAC1D,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;CACxC;AAED,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,eAAe,GAAG,gBAAgB,CAAA;AAC3E,MAAM,MAAM,iBA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,kBAAkB;AAC5B,yFAAyF;AACvF,UAAU;AACZ,4DAA4D;GAC1D,aAAa;AACf,oFAAoF;GAClF,YAAY;AACd,0DAA0D;GACxD,QAAQ,CAAA;AAEZ,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,kBAAkB,CAAA;IACxB,wEAAwE;IACxE,OAAO,EAAE,MAAM,CAAA;IACf,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAA;CACf"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2UI v1.0 wire types.
|
|
3
|
+
*
|
|
4
|
+
* A2UI (`a2ui.org`) is the declarative agent-to-UI protocol: the agent streams
|
|
5
|
+
* JSON describing a component tree plus a data model, and the renderer maps the
|
|
6
|
+
* abstract component names onto its own widgets. prefab emits it as a second
|
|
7
|
+
* output target alongside the `$prefab` wire format.
|
|
8
|
+
*
|
|
9
|
+
* Two structural differences drive the whole emitter:
|
|
10
|
+
*
|
|
11
|
+
* 1. **Flat, not nested.** A2UI components live in an adjacency list — every
|
|
12
|
+
* component carries an `id`, and parents reference children by id rather
|
|
13
|
+
* than embedding them. `$prefab` nests `children` directly.
|
|
14
|
+
* 2. **Bound, not interpolated.** A2UI reads dynamic values through JSON
|
|
15
|
+
* Pointer `{ path }` bindings into the data model. `$prefab` interpolates
|
|
16
|
+
* `{{ expr }}` templates, which is strictly more expressive, so only the
|
|
17
|
+
* plain-path subset survives the crossing (see `./expr.ts`).
|
|
18
|
+
*
|
|
19
|
+
* Mirrors `specification/v1_0/json/agent_to_renderer.json` and
|
|
20
|
+
* `catalogs/basic/catalog.json` from a2ui-project/a2ui (Apache-2.0). Only the
|
|
21
|
+
* agent-to-renderer direction is modelled: prefab produces UI, it does not
|
|
22
|
+
* consume renderer events.
|
|
23
|
+
*/
|
|
24
|
+
// ── Constants ────────────────────────────────────────────────────────────────
|
|
25
|
+
/** Protocol version stamped on every emitted message. */
|
|
26
|
+
export const A2UI_VERSION = 'v1.0';
|
|
27
|
+
/** Canonical id of the A2UI Basic catalog, the component set prefab targets. */
|
|
28
|
+
export const A2UI_BASIC_CATALOG = 'https://a2ui.org/specification/v1_0/catalogs/basic/catalog.json';
|
|
29
|
+
/** MIME type identifying an A2UI payload over MCP. */
|
|
30
|
+
export const A2UI_MIME = 'application/a2ui+json';
|
|
31
|
+
/** URI scheme for A2UI resources served over MCP. */
|
|
32
|
+
export const A2UI_SCHEME = 'a2ui://';
|
|
33
|
+
/** The reserved root component id every surface starts from. */
|
|
34
|
+
export const A2UI_ROOT_ID = 'root';
|
|
35
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/a2ui/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,gFAAgF;AAEhF,yDAAyD;AACzD,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAA;AAElC,gFAAgF;AAChF,MAAM,CAAC,MAAM,kBAAkB,GAAG,iEAAiE,CAAA;AAEnG,sDAAsD;AACtD,MAAM,CAAC,MAAM,SAAS,GAAG,uBAAuB,CAAA;AAEhD,qDAAqD;AACrD,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAA;AAEpC,gEAAgE;AAChE,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAA"}
|
package/dist/a2ui.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{var{defineProperty:A,getOwnPropertyNames:z,getOwnPropertyDescriptor:Y}=Object,X=Object.prototype.hasOwnProperty;function Z(e){return this[e]}var Q=(e)=>{var n=(D??=new WeakMap).get(e),t;if(n)return n;if(n=A({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function"){for(var r of z(e))if(!X.call(n,r))A(n,r,{get:Z.bind(e,r),enumerable:!(t=Y(e,r))||t.enumerable})}return D.set(e,n),n},D;var ee=(e)=>e;function ne(e,n){this[e]=ee.bind(null,n)}var te=(e,n)=>{for(var t in n)A(e,t,{get:n[t],enumerable:!0,configurable:!0,set:ne.bind(n,t)})};var De={};te(De,{default:()=>Ie,emit:()=>G,envelope:()=>K});var I={silent:0,error:1,warn:2,info:3,debug:4},re="warn";function y(e){let n=e?`[prefab:${e}]`:"[prefab]",t=(r,i,o)=>{if(I[r]>I[re])return;console[r](`${n} ${i}`,...o)};return{error:(r,...i)=>t("error",r,i),warn:(r,...i)=>t("warn",r,i),info:(r,...i)=>t("info",r,i),debug:(r,...i)=>t("debug",r,i)}}var Me=y();var ie=/^\s*\{\{\s*(.+?)\s*\}\}\s*$/s,oe=/^[A-Za-z_$][\w$]*(?:\.(?:[A-Za-z_$][\w$]*|\d+))*$/;function b(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function ae(e){return"/"+e.map(b).join("/")}function se(e){return e.startsWith("state.")?e.slice(6):e}function d(e){let n=ie.exec(e);if(n==null){if(e.includes("{{"))return{kind:"unbindable",expression:e};return{kind:"literal",value:e}}let t=se(n[1].trim());if(!oe.test(t))return{kind:"unbindable",expression:n[1].trim()};return{kind:"binding",value:{path:ae(t.split("."))}}}function c(e){if(e==null)return;let n=d(e);if(n.kind==="literal")return n.value;if(n.kind==="binding")return n.value;return}var ue=["accountCircle","add","arrowBack","arrowForward","attachFile","calendarToday","call","camera","check","close","delete","download","edit","event","error","fastForward","favorite","favoriteOff","folder","help","home","info","locationOn","lock","lockOpen","mail","menu","moreVert","moreHoriz","notificationsOff","notifications","pause","payment","person","phone","photo","play","print","refresh","rewind","search","send","settings","share","shoppingCart","skipNext","skipPrevious","star","starHalf","starOff","stop","upload","visibility","visibilityOff","volumeDown","volumeMute","volumeOff","volumeUp","warning"],le=new Map(ue.map((e)=>[O(e),e])),ce={alertcircle:"error",alerttriangle:"warning",alertoctagon:"error",xcircle:"error",circlex:"error",circlealert:"error",checkcircle:"check",circlecheck:"check",checkcircle2:"check",infocircle:"info",circleinfo:"info",helpcircle:"help",circlehelp:"help",bell:"notifications",belloff:"notificationsOff",arrowleft:"arrowBack",arrowright:"arrowForward",chevronleft:"arrowBack",chevronright:"arrowForward",x:"close",plus:"add",trash:"delete",trash2:"delete",ellipsisvertical:"moreVert",ellipsis:"moreHoriz",morehorizontal:"moreHoriz",morevertical:"moreVert",pencil:"edit",pen:"edit",squarepen:"edit",user:"person",usercircle:"accountCircle",circleuser:"accountCircle",eye:"visibility",eyeoff:"visibilityOff",mappin:"locationOn",map:"locationOn",image:"photo",images:"photo",file:"folder",files:"folder",calendar:"calendarToday",calendardays:"calendarToday",clock:"event",creditcard:"payment",cart:"shoppingCart",shoppingbag:"shoppingCart",phonecall:"call",mailopen:"mail",inbox:"mail",cog:"settings",gear:"settings",sliders:"settings",rotatecw:"refresh",rotateccw:"refresh",refreshcw:"refresh",heart:"favorite",heartoff:"favoriteOff",volume:"volumeUp",volume1:"volumeDown",volume2:"volumeUp",volumex:"volumeOff",skipforward:"skipNext",skipback:"skipPrevious",paperclip:"attachFile",link:"share",share2:"share",magnifyingglass:"search",searchicon:"search"};function O(e){return e.replace(/[\s._-]/g,"").toLowerCase()}function M(e){let n=O(e);return le.get(n)??ce[n]}var R=["TableHead","TableBody","TableFooter","TableRow","TableCell","TableHeader","ExpandableRow"];function de(e){if(!Array.isArray(e.columns))return[];let n=[];for(let t of e.columns){if(t==null||typeof t!=="object")continue;let r=t,i=typeof r.accessor==="string"?r.accessor:typeof r.key==="string"?r.key:void 0;if(i==null)continue;n.push({key:i,header:typeof r.header==="string"?r.header:i})}return n}function pe(e,n){let t=e.rows;if(typeof t==="string"){let r=d(t);if(r.kind==="binding")return r.value.path;n.note("expression","DataTable",`rows expression "${t}" is not a plain path; the table has no data source`);return}if(Array.isArray(t))return n.bindData("rows",t);n.note("unsupported","DataTable","no rows to render");return}function E(e,n){let t=de(e);if(t.length===0){n.note("unsupported","DataTable","no usable column definitions");return}let r=pe(e,n);if(r==null)return;let i=n.push({component:"Row",children:t.map((l)=>n.push({component:"Text",text:l.header,variant:"caption"})),align:"center"}),o=n.push({component:"Row",children:t.map((l)=>n.push({component:"Text",text:{path:l.key.split(".").join("/")}})),align:"center"}),u=n.push({component:"Column",children:{path:r,componentId:o}});if(e.search===!0||e.paginated===!0)n.note("degraded","DataTable","search and pagination dropped; A2UI Basic has no table controls");return{component:"Column",children:[i,u]}}function fe(e){let n=[],t=(r)=>{if(r.type==="TableRow"||r.type==="ExpandableRow"){n.push(r);return}if(Array.isArray(r.children))for(let i of r.children)t(i)};if(Array.isArray(e.children))for(let r of e.children)t(r);return n}function ge(e,n){let t=e.type==="TableHeader";if(Array.isArray(e.children)&&e.children.length>0)return n.single(e.children);let r=e.content??e.text??e.label;if(typeof r!=="string"&&typeof r!=="number"&&typeof r!=="boolean")return;let i=String(r),o=c(i);if(o==null){n.note("expression",e.type,`cell expression "${i}" has no A2UI equivalent`);return}return n.push({component:"Text",text:o,...t&&{variant:"caption"}})}function P(e,n){let t=fe(e),r=[];for(let i of t){let u=(Array.isArray(i.children)?i.children:[]).map((l)=>ge(l,n)).filter((l)=>l!=null);if(u.length===0)continue;r.push(n.push({component:"Row",children:u,align:"center"}))}if(r.length===0){n.note("unsupported","Table","no rows with renderable cells");return}return n.note("degraded","Table","rendered as a Column of Rows; column widths do not align"),{component:"Column",children:r}}function a(e,...n){for(let t of n){let r=e[t];if(typeof r==="string"||typeof r==="number"||typeof r==="boolean")return String(r)}return}function s(e,n,t){let r=a(e,...t?.keys??["content","text","label","title"]);if(r==null){n.note("unsupported",e.type,"no text content to render");return}let i=d(r);if(i.kind==="unbindable")n.note("expression",e.type,`"${i.expression}" is richer than a JSON Pointer; the text was left as written`);let o=t?.prefix??"",u=t?.suffix??"";if(i.kind==="binding"){if(o!==""||u!=="")n.note("degraded",e.type,"Markdown emphasis dropped: the text is a data binding");return{component:"Text",text:i.value,...t?.variant!=null&&{variant:t.variant}}}let l=i.kind==="literal"?i.value:r;return{component:"Text",text:`${o}${l}${u}`,...t?.variant!=null&&{variant:t.variant}}}var me={start:"start",end:"end",center:"center",between:"spaceBetween",around:"spaceAround",evenly:"spaceEvenly",spaceBetween:"spaceBetween",spaceAround:"spaceAround",spaceEvenly:"spaceEvenly"},he={start:"start",end:"end",center:"center",stretch:"stretch",baseline:"baseline"};function g(e){return(n,t)=>{let r=t.children(n.children);if(r.length===0){t.note("unsupported",n.type,`${e} requires at least one child and none survived`);return}let i=typeof n.justify==="string"?me[n.justify]:void 0,o=typeof n.align==="string"?he[n.align]:void 0;return{component:e,children:r,...i!=null&&{justify:i},...o!=null&&{align:o}}}}var Ae=["Div","Container","Stack","Grid","GridItem","Page","Pages","Dashboard","DashboardItem","MasterDetail","Detail","Form","Fieldset","CardContent","CardHeader","CardFooter","Accordion","Carousel","SelectGroup","ComboboxGroup","Section","Article","Aside","Header","Footer","Nav","Span"],ye=["ButtonGroup","Toolbar","Inline"],be={H1:"# ",H2:"## ",H3:"### ",H4:"#### ",H5:"##### ",H6:"###### "},B={Heading:(e,n)=>{let t=typeof e.level==="number"?Math.min(6,Math.max(1,e.level)):1;return s(e,n,{prefix:`${"#".repeat(t)} `})},Text:(e,n)=>s(e,n),P:(e,n)=>s(e,n),Lead:(e,n)=>s(e,n),Large:(e,n)=>s(e,n),Small:(e,n)=>s(e,n,{variant:"caption"}),Muted:(e,n)=>s(e,n,{variant:"caption"}),Label:(e,n)=>s(e,n,{variant:"caption"}),TableCaption:(e,n)=>s(e,n,{variant:"caption"}),BlockQuote:(e,n)=>s(e,n,{prefix:"> "}),Code:(e,n)=>s(e,n,{prefix:"`",suffix:"`"}),Kbd:(e,n)=>s(e,n,{prefix:"`",suffix:"`"}),Markdown:(e,n)=>s(e,n),Badge:(e,n)=>s(e,n,{keys:["label","content"],variant:"caption"}),AlertTitle:(e,n)=>s(e,n,{prefix:"**",suffix:"**"}),AlertDescription:(e,n)=>s(e,n)};for(let[e,n]of Object.entries(be))B[e]=(t,r)=>s(t,r,{prefix:n});function v(e){return(n,t)=>{let r=c(a(n,"src","url"));if(r==null){t.note("unsupported",n.type,"no resolvable source URL");return}let i=e==="Video"?void 0:c(a(n,"alt","description")),o=e==="Video"?c(a(n,"poster","posterUrl")):void 0;return{component:e,url:r,...i!=null&&{description:i},...o!=null&&{posterUrl:o}}}}var ve={text:"shortText",email:"shortText",url:"shortText",tel:"shortText",search:"shortText",password:"obscured",number:"number"};function f(e){let n=typeof e.name==="string"?e.name:void 0;if(n==null)return;let t=d(`{{ ${n} }}`);return t.kind==="binding"?t.value:void 0}function Ce(e,n){let t=Array.isArray(e.children)?e.children:[],r=[];for(let i of t){let o=a(i,"value");if(o==null){n.note("degraded",e.type,`dropped a ${i.type} child that carries no option value`);continue}r.push({label:a(i,"label")??o,value:o})}return r}function C(e,n,t){if(a(e,"label","name")==null)n.note("degraded",e.type,"no label available for the DateTimeInput");return{component:"DateTimeInput",value:f(e)??"",...t}}function x(e){return(n,t)=>{let r=c(a(n,"label","name"));if(r==null){t.note("unsupported",n.type,"ChoicePicker requires a label and none could be derived");return}let i=Ce(n,t);if(i.length===0){t.note("unsupported",n.type,"no options to choose from");return}let o=f(n);return{component:"ChoicePicker",label:r,variant:e,options:i,...o!=null&&{value:o}}}}function N(e,n,t){let r=c(a(e,"label","name"));if(r==null){n.note("unsupported",e.type,"TextField requires a label and none could be derived");return}let i=f(e),o=c(a(e,"placeholder"));return{component:"TextField",label:r,variant:t,...i!=null&&{value:i},...o!=null&&{placeholder:o}}}var w={Input:(e,n)=>{let t=typeof e.inputType==="string"?e.inputType:"text",r=ve[t];if(r==null)n.note("degraded",e.type,`inputType "${t}" has no A2UI variant; used shortText`);return N(e,n,r??"shortText")},Textarea:(e,n)=>N(e,n,"longText"),Checkbox:(e,n)=>{let t=c(a(e,"label","name"));if(t==null){n.note("unsupported",e.type,"CheckBox requires a label and none could be derived");return}return{component:"CheckBox",label:t,value:f(e)??!1}},Slider:(e,n)=>{let t=typeof e.max==="number"?e.max:void 0;if(t==null){n.note("unsupported",e.type,"Slider requires a max and prefab left it open");return}let r=c(a(e,"label","name")),i=typeof e.min==="number"?e.min:void 0,o=typeof e.step==="number"?e.step:void 0,u=o!=null&&o>0?Math.max(1,Math.round((t-(i??0))/o)):void 0;return{component:"Slider",max:t,value:f(e)??i??0,...r!=null&&{label:r},...i!=null&&{min:i},...u!=null&&{steps:u}}},Button:(e,n)=>{let t=a(e,"label","content")??"Button",r=n.action(e.onClick,"Button")??(e.submit===!0?{event:{name:"submit"}}:void 0);if(r==null){n.note("unsupported",e.type,"Button requires an action and none could be derived");return}let i=n.push({component:"Text",text:c(t)??t}),o=e.variant==="link"||e.variant==="ghost"?"borderless":e.variant==="default"?"primary":"default";return{component:"Button",child:i,action:r,variant:o}},Link:(e,n)=>{let t=a(e,"href","url");if(t==null){n.note("unsupported",e.type,"no href to open");return}let r=a(e,"content","label")??t;return{component:"Button",child:n.push({component:"Text",text:c(r)??r}),variant:"borderless",action:{functionCall:{call:"openUrl",args:{url:t}}}}},DatePicker:(e,n)=>C(e,n,{enableDate:!0}),TimePicker:(e,n)=>C(e,n,{enableTime:!0}),DateTimePicker:(e,n)=>C(e,n,{enableDate:!0,enableTime:!0}),Select:x("mutuallyExclusive"),RadioGroup:x("mutuallyExclusive"),Combobox:x("mutuallyExclusive")};w.Switch=w.Checkbox;var xe={Card:(e,n)=>{let t=n.single(e.children);if(t==null){n.note("unsupported","Card","Card requires a child and it had none");return}return{component:"Card",child:t}},Alert:(e,n)=>{let t=n.single(e.children);if(t==null){n.note("unsupported","Alert","no alert body to render");return}let r=typeof e.variant==="string"?e.variant:"default";return n.note("degraded","Alert",`variant "${r}" rendered as a plain Card`),{component:"Card",child:t}},Separator:()=>({component:"Divider"}),Divider:()=>({component:"Divider"}),Icon:(e,n)=>{let t=a(e,"name","icon");if(t==null){n.note("unsupported","Icon","no icon name");return}let r=M(t);if(r==null){n.note("unsupported","Icon",`"${t}" has no equivalent in the A2UI icon set`);return}if(r!==t)n.note("degraded","Icon",`"${t}" mapped to the A2UI icon "${r}"`);return{component:"Icon",name:r}},Metric:(e,n)=>{let t=[],r=a(e,"label","title");if(r!=null)t.push(n.push({component:"Text",text:c(r)??r,variant:"caption"}));let i=a(e,"value");if(i!=null)t.push(n.push({component:"Text",text:c(i)??i}));if(t.length===0){n.note("unsupported","Metric","neither a label nor a value to render");return}return n.note("degraded","Metric","rendered as a Column of Text; trend and delta styling dropped"),{component:"Column",children:t}},Tabs:(e,n)=>{let t=Array.isArray(e.children)?e.children:[],r=[];for(let i of t){let o=n.single(i.children);if(o==null)continue;r.push({title:a(i,"title")??"Tab",child:o})}if(r.length===0){n.note("unsupported","Tabs","no tab had renderable content");return}return{component:"Tabs",tabs:r}},Dialog:(e,n)=>{let t=n.single(e.children);if(t==null){n.note("unsupported","Dialog","no dialog body to render");return}let r=e.trigger,i=r!=null?n.child(r):n.push({component:"Text",text:a(e,"title")??"Open"});if(i==null){n.note("unsupported","Dialog","Modal requires a trigger and none could be emitted");return}return{component:"Modal",trigger:i,content:t}},AccordionItem:(e,n)=>{let t=[],r=a(e,"title");if(r!=null)t.push(n.push({component:"Text",text:r,variant:"caption"}));if(t.push(...n.children(e.children)),t.length===0){n.note("unsupported","AccordionItem","nothing to render");return}return n.note("degraded","AccordionItem","rendered expanded; A2UI Basic has no disclosure component"),{component:"Column",children:t}}},m={Column:g("Column"),Row:g("Row"),...B,...w,...xe,Image:v("Image"),Video:v("Video"),Audio:v("AudioPlayer"),Table:P,DataTable:E};for(let e of Ae)m[e]??=g("Column");for(let e of ye)m[e]??=g("Row");var we=new Set(["Tab","SelectOption","ComboboxOption","Radio","Option",...R]),ke={LineChart:"charts",BarChart:"charts",AreaChart:"charts",PieChart:"charts",ScatterChart:"charts",RadarChart:"charts",RadialChart:"charts",Histogram:"charts",Sparkline:"charts",Svg:"inline vector graphics",Mermaid:"diagrams",Embed:"embedded frames",DropZone:"file uploads",Ring:"progress rings",Loader:"loading indicators",Progress:"progress bars"};function L(e){return m[e]}function U(e){return we.has(e)}function _(){return Object.keys(m).sort()}function F(e,n){let t=ke[e.type];if(t!=null){n.note("unsupported",e.type,`${t} are outside the A2UI Basic catalog`);return}if(Array.isArray(e.children)&&e.children.length>0){let r=n.children(e.children);if(r.length>0)return n.note("degraded",e.type,"no Basic-catalog equivalent; flattened to a Column"),{component:"Column",children:r}}if(a(e,"content","text","label","title")!=null)return n.note("degraded",e.type,"no Basic-catalog equivalent; rendered as Text"),s(e,n);n.note("unsupported",e.type,"no Basic-catalog equivalent and nothing to render");return}var p="v1.0",h="https://a2ui.org/specification/v1_0/catalogs/basic/catalog.json",J="application/a2ui+json",j="a2ui://",k="root";var Te=y("a2ui");function Se(e){let n=e.children;if(e.type==="Div"&&typeof e.cssClass==="string"&&e.cssClass.startsWith("pf-app-root")&&Array.isArray(n)&&n.length===1)return n[0];return e}class H{warn;components=new Map;dataModel={};used=new Set([k]);diagnostics=[];counter=0;constructor(e){this.warn=e}note(e,n,t){if(this.diagnostics.push({kind:e,subject:n,detail:t}),this.warn)Te.warn(`${e}: ${n} — ${t}`)}allocate(e){let n=typeof e?.id==="string"&&e.id.length>0?e.id:void 0;if(n!=null&&!this.used.has(n))return this.used.add(n),n;let t;do this.counter+=1,t=`c${this.counter}`;while(this.used.has(t));return this.used.add(t),t}push(e){let n=this.allocate();return this.components.set(n,{id:n,...e}),n}bindData(e,n){let t=e,r=0;while(t in this.dataModel)r+=1,t=`${e}${r}`;return this.dataModel[t]=n,`/${b(t)}`}child(e){return this.emit(e,!1)}children(e){if(!Array.isArray(e))return[];let n=[];for(let t of e){if(t==null||typeof t!=="object")continue;let r=this.emit(t,!1);if(r!=null)n.push(r)}return n}single(e){let n=this.children(e);if(n.length===0)return;if(n.length===1)return n[0];return this.push({component:"Column",children:n})}action(e,n){if(e==null)return;if(Array.isArray(e)){if(e.length===0)return;if(e.length>1)this.note("action",n,`${e.length} actions were bound; A2UI carries one, so the rest were dropped`);return this.action(e[0],n)}if(typeof e!=="object")return;let t=e,r=typeof t.action==="string"?t.action:void 0;if(r==null)return;switch(r){case"toolCall":{let i=typeof t.tool==="string"?t.tool:void 0;if(i==null)return;let o=this.eventContext(t.arguments,n);return{event:{name:i,...o!=null&&{context:o}}}}case"sendMessage":return{event:{name:"sendMessage",context:{message:typeof t.message==="string"?t.message:""}}};case"openLink":{let i=typeof t.url==="string"?t.url:typeof t.href==="string"?t.href:void 0;if(i==null)return;return{functionCall:{call:"openUrl",args:{url:i}}}}default:{this.note("action",n,`"${r}" has no renderer-side equivalent; emitted as an agent event`);let{action:i,...o}=t,u=this.eventContext(o,n);return{event:{name:r,...u!=null&&{context:u}}}}}}eventContext(e,n){if(e==null||typeof e!=="object"||Array.isArray(e))return;let t={};for(let[r,i]of Object.entries(e)){if(typeof i==="number"||typeof i==="boolean"||i===null){t[r]=i;continue}if(typeof i!=="string"){this.note("action",n,`argument "${r}" is not a scalar and was dropped from the event context`);continue}let o=d(i);if(o.kind==="unbindable"){this.note("action",n,`argument "${r}" uses "${o.expression}", which A2UI cannot bind; it was dropped`);continue}t[r]=o.kind==="binding"?o.value:o.value}return Object.keys(t).length>0?t:void 0}emit(e,n){if(typeof e.type!=="string")return;if(U(e.type)){this.note("unsupported",e.type,"only meaningful inside its parent; emitted standalone it has no meaning");return}let t=n?k:this.allocate(e);this.components.set(t,void 0);let i=(L(e.type)??F)(e,this);if(i==null){if(this.components.delete(t),!n)this.used.delete(t);return}return this.components.set(t,{id:t,...i}),t}finish(e,n){let t=n.surfaceId??"prefab";if(this.emit(Se(e.view),!0)==null)this.note("unsupported","view","nothing in the view could be expressed in A2UI; the surface is empty");let i=[];for(let S of this.components.values())if(S!=null)i.push(S);let o={...this.dataModel,...e.state??{}},u=Object.keys(o).length>0,l=[],T=n.catalogId??h;if(n.stream===!0){if(l.push({version:p,createSurface:{surfaceId:t,catalogId:T,...n.sendDataModel===!0&&{sendDataModel:!0}}}),i.length>0)l.push({version:p,updateComponents:{surfaceId:t,components:i}});if(u)l.push({version:p,updateDataModel:{surfaceId:t,value:o}})}else l.push({version:p,createSurface:{surfaceId:t,catalogId:T,...n.sendDataModel===!0&&{sendDataModel:!0},...i.length>0&&{components:i},...u&&{dataModel:o}}});return{messages:l,diagnostics:this.diagnostics}}}function V(e,n){let t=n??{};return new H(t.warn===!0).finish(e,t)}var q="0.3.10";function G(e,n){if(e==null||typeof e!=="object"||!("view"in e))throw TypeError('PrefabA2UI.emit: expected a $prefab payload with a "view"');return V(e,n)}function K(e){return{messages:e}}var W={emit:G,envelope:K,mappedTypes:_,VERSION:q,A2UI_VERSION:p,A2UI_BASIC_CATALOG:h,A2UI_MIME:J,A2UI_SCHEME:j},Ie=W;if(typeof window<"u")window.PrefabA2UI=W;})();
|
package/dist/app.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { ComponentJSON } from './core/component.js';
|
|
|
9
9
|
import type { Action, ActionJSON } from './actions/types.js';
|
|
10
10
|
import type { PipeFn } from './rx/pipes.js';
|
|
11
11
|
import { VERSION, PROTOCOL_VERSION } from './core/version.js';
|
|
12
|
+
import type { A2uiEmitOptions, A2uiEmitResult } from './a2ui/emit.js';
|
|
12
13
|
export { VERSION, PROTOCOL_VERSION };
|
|
13
14
|
export interface Theme {
|
|
14
15
|
light?: Record<string, string>;
|
|
@@ -104,6 +105,22 @@ export declare class PrefabApp {
|
|
|
104
105
|
* This is what gets sent over MCP or stored as a resource.
|
|
105
106
|
*/
|
|
106
107
|
toJSON(): PrefabWireFormat;
|
|
108
|
+
/**
|
|
109
|
+
* Serialize to A2UI messages — the second wire format this tree can speak.
|
|
110
|
+
*
|
|
111
|
+
* `toJSON()` targets prefab's own renderer; this targets the A2UI renderers,
|
|
112
|
+
* which draw native widgets from a flat component list rather than running
|
|
113
|
+
* prefab's renderer in an iframe. The catalogs are not the same size, so the
|
|
114
|
+
* result carries `diagnostics` describing every component that had to
|
|
115
|
+
* degrade, and callers that care should read it.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```ts
|
|
119
|
+
* const { messages, diagnostics } = app.toA2UI()
|
|
120
|
+
* if (diagnostics.some(d => d.kind === 'unsupported')) rethinkTheView()
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
toA2UI(options?: A2uiEmitOptions): A2uiEmitResult;
|
|
107
124
|
/**
|
|
108
125
|
* Serialize as a ready-to-return MCP tool result.
|
|
109
126
|
*
|
package/dist/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAE5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAG3C,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAE5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAG3C,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAE7D,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAKrE,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAA;AAIpC,MAAM,WAAW,KAAK;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9B,IAAI,CAAC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AW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAA;IACxD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;gBAEjB,IAAI,EAAE,gBAAgB;IAwBlC;;;OAGG;IACH,MAAM,IAAI,gBAAgB;IA4D1B;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,cAAc;IAIjD;;;;;;;;;;OAUG;IACH,WAAW,IAAI;QAAE,OAAO,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAAC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE;IAQxG;;;;;;;OAOG;IACH,MAAM,CAAC,IAAI,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAC;QAAC,aAAa,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM;CA6D1F"}
|
package/dist/app.js
CHANGED
|
@@ -9,6 +9,7 @@ import { drainAutoState } from './rx/state-collector.js';
|
|
|
9
9
|
import { compileThemeCss } from './core/theme-css.js';
|
|
10
10
|
import { escapeHtml } from './core/escape.js';
|
|
11
11
|
import { VERSION, PROTOCOL_VERSION } from './core/version.js';
|
|
12
|
+
import { emitA2UI } from './a2ui/emit.js';
|
|
12
13
|
// Version constants live in ./core/version.ts (single source of truth, updated
|
|
13
14
|
// at release time). Re-exported so existing `from './app.js'` imports and the
|
|
14
15
|
// package's public API keep working.
|
|
@@ -109,6 +110,24 @@ export class PrefabApp {
|
|
|
109
110
|
wire.layout = this.layout;
|
|
110
111
|
return wire;
|
|
111
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Serialize to A2UI messages — the second wire format this tree can speak.
|
|
115
|
+
*
|
|
116
|
+
* `toJSON()` targets prefab's own renderer; this targets the A2UI renderers,
|
|
117
|
+
* which draw native widgets from a flat component list rather than running
|
|
118
|
+
* prefab's renderer in an iframe. The catalogs are not the same size, so the
|
|
119
|
+
* result carries `diagnostics` describing every component that had to
|
|
120
|
+
* degrade, and callers that care should read it.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* const { messages, diagnostics } = app.toA2UI()
|
|
125
|
+
* if (diagnostics.some(d => d.kind === 'unsupported')) rethinkTheView()
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
toA2UI(options) {
|
|
129
|
+
return emitA2UI(this.toJSON(), options);
|
|
130
|
+
}
|
|
112
131
|
/**
|
|
113
132
|
* Serialize as a ready-to-return MCP tool result.
|
|
114
133
|
*
|
package/dist/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAkB,MAAM,qBAAqB,CAAA;AAGpD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAkB,MAAM,qBAAqB,CAAA;AAGpD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,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,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC;aACpD,IAAI,CAAC,QAAQ,CAAC,CAAA;QAEjB,sEAAsE;QACtE,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAgB,IAAI,CAAC,IAAI,YAAY,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;QAEnF,MAAM,UAAU,GAAG,CAAC,YAAY,EAAE,OAAO,IAAI,SAAS,OAAO,EAAE,EAAE,cAAc,IAAI,SAAS,cAAc,EAAE,CAAC;aAC1G,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,EAAE,CAAC,CAAA;QAEX,OAAO;iBACM,QAAQ;;;;aAIZ,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,UAAU;uEACe,UAAU;MAC3E,UAAU;;;;;iCAKiB,WAAW;;;;;;QAMpC,CAAA;IACN,CAAC;CACF"}
|
package/dist/auto/form.d.ts
CHANGED
|
@@ -5,6 +5,19 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { type ContainerComponent } from '../core/component.js';
|
|
7
7
|
import type { Action } from '../actions/types.js';
|
|
8
|
+
/** One choice offered by a field carrying {@link AutoFormField.options}. */
|
|
9
|
+
export interface AutoFormOption {
|
|
10
|
+
value: string;
|
|
11
|
+
label?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* One field in an auto-generated form.
|
|
15
|
+
*
|
|
16
|
+
* The same definition drives both delivery paths: {@link autoForm} renders it as
|
|
17
|
+
* prefab components, and `formSchema` in `src/mcp/input-required.ts` derives the
|
|
18
|
+
* restricted elicitation JSON Schema from it for hosts with no UI surface. Keep
|
|
19
|
+
* anything added here expressible in both.
|
|
20
|
+
*/
|
|
8
21
|
export interface AutoFormField {
|
|
9
22
|
/** Field name (used as the key in submitted data). */
|
|
10
23
|
name: string;
|
|
@@ -16,6 +29,18 @@ export interface AutoFormField {
|
|
|
16
29
|
placeholder?: string;
|
|
17
30
|
/** Whether the field is required. */
|
|
18
31
|
required?: boolean;
|
|
32
|
+
/** Longer help text. Becomes the schema `description` on the elicitation path. */
|
|
33
|
+
description?: string;
|
|
34
|
+
/** Fixed set of choices. Renders as a Select and becomes an enum on the wire. */
|
|
35
|
+
options?: AutoFormOption[];
|
|
36
|
+
/** Allow several choices. Only meaningful alongside `options`. */
|
|
37
|
+
multiple?: boolean;
|
|
38
|
+
/** Inclusive lower bound for a numeric field, or minimum length for a string. */
|
|
39
|
+
min?: number;
|
|
40
|
+
/** Inclusive upper bound for a numeric field, or maximum length for a string. */
|
|
41
|
+
max?: number;
|
|
42
|
+
/** Pre-filled value. */
|
|
43
|
+
default?: string | number | boolean | string[];
|
|
19
44
|
}
|
|
20
45
|
export interface AutoFormOptions {
|
|
21
46
|
/** Form heading. */
|