@polyxd/a2ui 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,133 @@
1
+ export const MAPPING = {
2
+ Action: {
3
+ target: "custom",
4
+ basicAnalog: "Button + Text child",
5
+ why: "Button needs a synthesized Text child and has only default/primary/borderless; it has no danger tone and no disabled state.",
6
+ },
7
+ ActionBar: {
8
+ target: "custom",
9
+ basicAnalog: "Row of Button",
10
+ why: "Row is pure layout. It loses the 'set of actions ordered by importance' semantics and the stacking on narrow screens.",
11
+ },
12
+ Card: {
13
+ target: "custom",
14
+ basicAnalog: "Card > Column(Image, Text, Text, ...)",
15
+ why: "Basic Card is a single-child container with no action. Title, subtitle, badge (with tone), media slot and whole-card action would need synthesized components or would be dropped.",
16
+ },
17
+ Chart: {
18
+ target: "custom",
19
+ basicAnalog: "Text(summary) + List",
20
+ why: "Basic has no chart. Intent, axes, series and formats would be dropped.",
21
+ },
22
+ Choice: {
23
+ target: "custom",
24
+ basicAnalog: "ChoicePicker",
25
+ why: "ChoicePicker options must be literal (Polyxd options can come from host data), option descriptions are missing, the value must be a string list, and there is no help text.",
26
+ },
27
+ Collection: {
28
+ target: "custom",
29
+ basicAnalog: "List (templated children)",
30
+ why: "List has no label, no empty state and no selection model.",
31
+ },
32
+ Comparison: {
33
+ target: "custom",
34
+ basicAnalog: "List of Card",
35
+ why: "Basic has no comparison. Attribute rows, 'better' direction, recommendation and per-item choose action would be flattened away.",
36
+ },
37
+ Confirm: {
38
+ target: "custom",
39
+ basicAnalog: "Modal(trigger, content: Column(Text, Button, Button))",
40
+ why: "Modal needs a trigger component. Severity, consequence, type-to-confirm and the default cancel behaviour have no Basic form.",
41
+ },
42
+ DateInput: {
43
+ target: "custom",
44
+ basicAnalog: "DateTimeInput",
45
+ why: "DateTimeInput has no date-range kind and no help text, and 'required' becomes a check function.",
46
+ },
47
+ DetailList: {
48
+ target: "custom",
49
+ basicAnalog: "Column of Row(Text, Text)",
50
+ why: "The label/value pairing (a description list for assistive tech), stable item keys and value formats would be lost.",
51
+ },
52
+ Navigation: {
53
+ target: "custom",
54
+ basicAnalog: "Column of Button",
55
+ why: "A column of buttons loses which section you are in, the grouping, the counts needing attention, and the side-navigation-or-menu behaviour.",
56
+ },
57
+ FilterPanel: {
58
+ target: "custom",
59
+ basicAnalog: "Column of inputs beside a List, with a Modal on narrow screens",
60
+ why: "Column and Modal are layout. They lose the link between filters and the results they narrow, the result count, removable active-filter chips and the sidebar-or-sheet behaviour.",
61
+ },
62
+ Disclosure: {
63
+ target: "custom",
64
+ basicAnalog: "Column (content always shown)",
65
+ why: "Basic has no expand/collapse.",
66
+ },
67
+ Form: {
68
+ target: "custom",
69
+ basicAnalog: "Column + Button",
70
+ why: "Submit/cancel semantics (Enter submits, cancel defaults to dismiss) and form grouping have no Basic form.",
71
+ },
72
+ Group: {
73
+ target: "custom",
74
+ basicAnalog: "Column or Row",
75
+ why: "Basic forces one axis. The adaptive 'auto'/'inline'/'grid' arrangement hint would be lost.",
76
+ },
77
+ Media: {
78
+ target: "custom",
79
+ basicAnalog: "Image",
80
+ why: "Image takes a URL string. Polyxd's src is a host-data binding, and 'decorative' and the aspect hint have no Image equivalent (Image.variant is a size, not an aspect).",
81
+ },
82
+ Metric: {
83
+ target: "custom",
84
+ basicAnalog: "Column of Text",
85
+ why: "Value format, change value and favourable direction (the colour follows the meaning) would be lost.",
86
+ },
87
+ RangeInput: {
88
+ target: "custom",
89
+ basicAnalog: "Slider",
90
+ why: "Slider has a step count, not a step size, and no value format.",
91
+ },
92
+ Section: {
93
+ target: "custom",
94
+ basicAnalog: "Column with a Text heading",
95
+ why: "Basic Text has no heading level, so the section heading and landmark would be lost.",
96
+ },
97
+ Status: {
98
+ target: "custom",
99
+ basicAnalog: "Row(Icon, Text)",
100
+ why: "Status kinds (loading, empty, error, ...) and their live-region semantics would be lost.",
101
+ },
102
+ Steps: {
103
+ target: "custom",
104
+ basicAnalog: "Column of the current step",
105
+ why: "Basic has no stepper. Step keys, progress and the finish action would be lost.",
106
+ },
107
+ Table: {
108
+ target: "custom",
109
+ basicAnalog: "List of Row",
110
+ why: "Basic has no table. Caption, column headers, formats, row action and empty state would be lost.",
111
+ },
112
+ Text: {
113
+ target: "custom",
114
+ basicAnalog: "Text",
115
+ why: "Basic Text interprets Markdown (Polyxd text is plain), has no 'supporting' variant and no value format.",
116
+ },
117
+ TextInput: {
118
+ target: "custom",
119
+ basicAnalog: "TextField",
120
+ why: "TextField has no currency/email/phone/url/search kinds, help text or autocomplete hint, and validation becomes Basic check functions.",
121
+ },
122
+ Toggle: {
123
+ target: "custom",
124
+ basicAnalog: "CheckBox",
125
+ why: "CheckBox has no description and no immediate-apply action (a setting that saves on change).",
126
+ },
127
+ Views: {
128
+ target: "custom",
129
+ basicAnalog: "Tabs",
130
+ why: "Tabs has no stable view keys and no binding for the selected view.",
131
+ },
132
+ };
133
+ //# sourceMappingURL=mapping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapping.js","sourceRoot":"","sources":["../src/mapping.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,MAAM,OAAO,GAAoC;IACtD,MAAM,EAAE;QACN,MAAM,EAAE,QAAQ;QAChB,WAAW,EAAE,qBAAqB;QAClC,GAAG,EAAE,6HAA6H;KACnI;IACD,SAAS,EAAE;QACT,MAAM,EAAE,QAAQ;QAChB,WAAW,EAAE,eAAe;QAC5B,GAAG,EAAE,uHAAuH;KAC7H;IACD,IAAI,EAAE;QACJ,MAAM,EAAE,QAAQ;QAChB,WAAW,EAAE,uCAAuC;QACpD,GAAG,EAAE,oLAAoL;KAC1L;IACD,KAAK,EAAE;QACL,MAAM,EAAE,QAAQ;QAChB,WAAW,EAAE,sBAAsB;QACnC,GAAG,EAAE,wEAAwE;KAC9E;IACD,MAAM,EAAE;QACN,MAAM,EAAE,QAAQ;QAChB,WAAW,EAAE,cAAc;QAC3B,GAAG,EAAE,6KAA6K;KACnL;IACD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E,QAAQ;QAChB,WAAW,EAAE,QAAQ;QACrB,GAAG,EAAE,gEAAgE;KACtE;IACD,OAAO,EAAE;QACP,MAAM,EAAE,QAAQ;QAChB,WAAW,EAAE,4BAA4B;QACzC,GAAG,EAAE,qFAAqF;KAC3F;IACD,MAAM,EAAE;QACN,MAAM,EAAE,QAAQ;QAChB,WAAW,EAAE,iBAAiB;QAC9B,GAAG,EAAE,0FAA0F;KAChG;IACD,KAAK,EAAE;QACL,MAAM,EAAE,QAAQ;QAChB,WAAW,EAAE,4BAA4B;QACzC,GAAG,EAAE,gFAAgF;KACtF;IACD,KAAK,EAAE;QACL,MAAM,EAAE,QAAQ;QAChB,WAAW,EAAE,aAAa;QAC1B,GAAG,EAAE,iGAAiG;KACvG;IACD,IAAI,EAAE;QACJ,MAAM,EAAE,QAAQ;QAChB,WAAW,EAAE,MAAM;QACnB,GAAG,EAAE,yGAAyG;KAC/G;IACD,SAAS,EAAE;QACT,MAAM,EAAE,QAAQ;QAChB,WAAW,EAAE,WAAW;QACxB,GAAG,EAAE,uIAAuI;KAC7I;IACD,MAAM,EAAE;QACN,MAAM,EAAE,QAAQ;QAChB,WAAW,EAAE,UAAU;QACvB,GAAG,EAAE,6FAA6F;KACnG;IACD,KAAK,EAAE;QACL,MAAM,EAAE,QAAQ;QAChB,WAAW,EAAE,MAAM;QACnB,GAAG,EAAE,oEAAoE;KAC1E;CACF,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { type Json } from "./a2ui.ts";
2
+ export interface A2UIValidationError {
3
+ at: string;
4
+ message: string;
5
+ }
6
+ export interface A2UIValidator {
7
+ /** Validates one agent-to-renderer message against agent_to_renderer.json with `catalog` as the active catalog. */
8
+ message(msg: unknown): A2UIValidationError[];
9
+ /** Validates a catalog document against catalog_definition.json. */
10
+ catalogDefinition(catalog: unknown): A2UIValidationError[];
11
+ }
12
+ export declare function createValidator(catalog?: Json): A2UIValidator;
13
+ /**
14
+ * Checks the component tree the way A2UI validators do. Structural links are found through the catalog's
15
+ * `ComponentId` / `ChildList` references. It checks that exactly one component is `root`, ids are unique, and
16
+ * every reference resolves. `allowedChildren` constraints are checked too.
17
+ */
18
+ export declare function checkComponentTree(components: Json[], catalog?: Json): A2UIValidationError[];
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Validation against the vendored official A2UI v1.0 schemas.
3
+ *
4
+ * `agent_to_renderer.json` refers to the active catalog as `catalog.json#/$defs/anyComponent`, resolved
5
+ * against its own $id. As in the upstream test runner (specification/v1_0/test/run_tests.py), the catalog in
6
+ * use is registered under `https://a2ui.org/specification/v1_0/catalog.json`, so its relative
7
+ * `common_types.json#/...` references resolve to the official common types.
8
+ */
9
+ import { Ajv2020 } from "ajv/dist/2020.js";
10
+ import addFormatsModule from "ajv-formats";
11
+ import { a2uiSchemas } from "./a2ui.js";
12
+ import { loadPolyxdCatalog } from "./catalog.js";
13
+ const CATALOG_ALIAS = "https://a2ui.org/specification/v1_0/catalog.json";
14
+ const addFormats = addFormatsModule;
15
+ const describe = (errors) => (errors ?? []).map((e) => ({ at: e.instancePath || "/", message: `${e.message ?? e.keyword} ${JSON.stringify(e.params)}` }));
16
+ /** Settings match the upstream runner: `ajv validate --spec=draft2020 --strict=false -c ajv-formats`. */
17
+ const newAjv = () => addFormats(new Ajv2020({ strict: false, allErrors: true }));
18
+ export function createValidator(catalog = loadPolyxdCatalog()) {
19
+ const ajv = newAjv();
20
+ ajv.addSchema(a2uiSchemas.commonTypes());
21
+ ajv.addSchema({ ...catalog, $id: CATALOG_ALIAS });
22
+ const catalogDefinition = a2uiSchemas.catalogDefinition();
23
+ ajv.addSchema(catalogDefinition);
24
+ const message = ajv.compile(a2uiSchemas.agentToRenderer());
25
+ const definition = ajv.getSchema(catalogDefinition.$id);
26
+ return {
27
+ message: (msg) => (message(msg) ? [] : describe(message.errors)),
28
+ catalogDefinition: (c) => (definition(c) ? [] : describe(definition.errors)),
29
+ };
30
+ }
31
+ /**
32
+ * Checks the component tree the way A2UI validators do. Structural links are found through the catalog's
33
+ * `ComponentId` / `ChildList` references. It checks that exactly one component is `root`, ids are unique, and
34
+ * every reference resolves. `allowedChildren` constraints are checked too.
35
+ */
36
+ export function checkComponentTree(components, catalog = loadPolyxdCatalog()) {
37
+ const errors = [];
38
+ const byId = new Map();
39
+ components.forEach((c, i) => {
40
+ if (byId.has(c.id))
41
+ errors.push({ at: `/${i}/id`, message: `duplicate id "${c.id}"` });
42
+ byId.set(c.id, c);
43
+ });
44
+ if (!byId.has("root"))
45
+ errors.push({ at: "/", message: 'no component with id "root"' });
46
+ const refsOf = (schema, value, at, out) => {
47
+ if (!schema || value === undefined)
48
+ return;
49
+ const ref = schema.$ref;
50
+ if (ref?.endsWith("/ComponentId") && typeof value === "string")
51
+ return void out.push({ id: value, at });
52
+ if (ref?.endsWith("/ChildList")) {
53
+ if (Array.isArray(value))
54
+ value.forEach((id, i) => out.push({ id, at: `${at}/${i}` }));
55
+ else if (value && typeof value === "object")
56
+ out.push({ id: value.componentId, at: `${at}/componentId` });
57
+ return;
58
+ }
59
+ if (Array.isArray(value) && schema.items)
60
+ value.forEach((v, i) => refsOf(schema.items, v, `${at}/${i}`, out));
61
+ else if (value && typeof value === "object" && schema.properties) {
62
+ for (const [k, v] of Object.entries(value))
63
+ refsOf(schema.properties[k], v, `${at}/${k}`, out);
64
+ }
65
+ };
66
+ components.forEach((c, i) => {
67
+ const def = catalog.components?.[c.component];
68
+ if (!def)
69
+ return void errors.push({ at: `/${i}/component`, message: `"${c.component}" is not in catalog ${catalog.catalogId}` });
70
+ const refs = [];
71
+ refsOf(def, c, `/${i}`, refs);
72
+ for (const r of refs) {
73
+ const target = byId.get(r.id);
74
+ if (!target)
75
+ errors.push({ at: r.at, message: `references unknown component "${r.id}"` });
76
+ else if (def.allowedChildren && !def.allowedChildren.includes(target.component)) {
77
+ errors.push({ at: r.at, message: `UNALLOWED_CHILD: ${c.component} cannot contain ${target.component}` });
78
+ }
79
+ }
80
+ });
81
+ return errors;
82
+ }
83
+ //# s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AAE,EAAE,CAAC,CAAC;YAC3G,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@polyxd/a2ui",
3
+ "version": "0.1.0",
4
+ "description": "Exports Polyxd UI documents to A2UI v1.0 message streams, with a Polyxd A2UI catalog",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "scripts": {
10
+ "build": "tsc -b",
11
+ "test": "node --test \"test/**/*.test.ts\"",
12
+ "build:catalog": "node scripts/build-catalog.ts"
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "catalog",
17
+ "vendor",
18
+ "LICENSE",
19
+ "NOTICE"
20
+ ],
21
+ "dependencies": {
22
+ "@polyxd/spec": "^0.1.0",
23
+ "ajv": "^8.20.0",
24
+ "ajv-formats": "^3.0.1"
25
+ },
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/visualfart/polyxd.git",
29
+ "directory": "packages/a2ui"
30
+ },
31
+ "homepage": "https://polyxd.com",
32
+ "bugs": "https://github.com/visualfart/polyxd/issues",
33
+ "publishConfig": {
34
+ "access": "public"
35
+ }
36
+ }
@@ -0,0 +1,227 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ https://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ https://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
203
+
204
+ --------------------------------------------------------------------------------
205
+ The file eval/bin/transcrypt is licensed under the MIT License:
206
+
207
+ Copyright (c) 2019-2025 James Murty <james@murty.co>
208
+ Copyright (c) 2014-2020 Aaron Bull Schaefer <aaron@elasticdog.com>
209
+
210
+ Permission is hereby granted, free of charge, to any person obtaining a copy
211
+ of this software and associated documentation files (the "Software"), to deal
212
+ in the Software without restriction, including without limitation the rights
213
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
214
+ copies of the Software, and to permit persons to whom the Software is
215
+ furnished to do so, subject to the following conditions:
216
+
217
+ The above copyright notice and this permission notice shall be included in all
218
+ copies or substantial portions of the Software.
219
+
220
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
221
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
222
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
223
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
224
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
225
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
226
+ SOFTWARE.
227
+ --------------------------------------------------------------------------------
@@ -0,0 +1,29 @@
1
+ # Vendored A2UI v1.0 schemas
2
+
3
+ These files are unmodified copies of the official A2UI specification JSON Schemas. `@polyxd/a2ui` validates its exported messages and its catalog against them.
4
+
5
+ - **Source:** https://github.com/a2ui-project/a2ui, directory `specification/v1_0/`
6
+ - **Commit:** `04e6f07fde12ff2638b3b489bd9e3033066cb957` (tip of `main`, committed 2026-09-18T11:34:38Z)
7
+ - **Fetched:** 2026-09-19, from `https://raw.githubusercontent.com/a2ui-project/a2ui/04e6f07fde12ff2638b3b489bd9e3033066cb957/specification/v1_0/<path>`
8
+ - **Spec status:** v1.0 **release candidate**. The upstream README says it "is currently a candidate for becoming stable". Messages carry `"version": "v1.0"`.
9
+ - **License:** Apache-2.0 (upstream `LICENSE` copied alongside as `LICENSE`).
10
+
11
+ | File | Upstream path | Used for |
12
+ |---|---|---|
13
+ | `json/agent_to_renderer.json` | `specification/v1_0/json/agent_to_renderer.json` | Server-to-client message envelope (`createSurface`, `updateComponents`, `updateDataModel`, ...) |
14
+ | `json/common_types.json` | `specification/v1_0/json/common_types.json` | Shared types (`ComponentCommon`, `ChildList`, `Dynamic*`, `Action`, `AccessibilityAttributes`, `Extensions`) |
15
+ | `json/catalog_definition.json` | `specification/v1_0/json/catalog_definition.json` | Validates the Polyxd catalog as an A2UI catalog |
16
+ | `catalogs/basic/catalog.json` | `specification/v1_0/catalogs/basic/catalog.json` | The Basic catalog, for comparison and as a sanity check of the catalog-definition schema |
17
+
18
+ SHA-256 of the files as fetched:
19
+
20
+ ```
21
+ 468c8e544dbe0b02d5d5586ebcdca399ecfa6d07a7b875d887089ce3bd2df160 json/agent_to_renderer.json
22
+ f2911c1cc05ca1dae2cf78ed18bf463816daf75c44c43bb5603144934425bcb2 json/common_types.json
23
+ f3c15537c179f06217b3746f9106674a747668a3109e6f380b5f3f9a52a060eb json/catalog_definition.json
24
+ 29d843fccbe24e2314a134ae04fee4d64b078e2f43fa364b1beb9b2bd6adb9f5 catalogs/basic/catalog.json
25
+ ```
26
+
27
+ `agent_to_renderer.json` refers to the active catalog as `catalog.json#/$defs/anyComponent`. Following the upstream test runner (`specification/v1_0/test/run_tests.py`), validation registers the catalog in use under the `$id` `https://a2ui.org/specification/v1_0/catalog.json`. The files here are never edited. The aliasing happens in memory (see `src/validate.ts`).
28
+
29
+ To update: fetch the same paths at a newer commit into a new `v1_0-<short-sha>/` directory, point `VENDOR_DIR` in `src/a2ui.ts` at it, and run the tests.