@lynx-js/genui 0.0.2 → 0.0.4
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/README.md +5 -9
- package/a2ui/AGENTS.md +167 -0
- package/a2ui/README.md +76 -780
- package/a2ui/README_zh.md +103 -0
- package/a2ui/dist/catalog/Button/catalog.json +2 -1
- package/a2ui/dist/catalog/Button/index.d.ts +5 -0
- package/a2ui/dist/catalog/Button/index.jsx +3 -0
- package/a2ui/dist/catalog/Button/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Card/catalog.json +2 -1
- package/a2ui/dist/catalog/Card/index.d.ts +5 -0
- package/a2ui/dist/catalog/Card/index.jsx +3 -0
- package/a2ui/dist/catalog/Card/index.jsx.map +1 -1
- package/a2ui/dist/catalog/CheckBox/catalog.json +2 -1
- package/a2ui/dist/catalog/CheckBox/index.d.ts +5 -0
- package/a2ui/dist/catalog/CheckBox/index.jsx +3 -0
- package/a2ui/dist/catalog/CheckBox/index.jsx.map +1 -1
- package/a2ui/dist/catalog/ChoicePicker/catalog.json +2 -1
- package/a2ui/dist/catalog/ChoicePicker/index.d.ts +5 -0
- package/a2ui/dist/catalog/ChoicePicker/index.jsx +3 -0
- package/a2ui/dist/catalog/ChoicePicker/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Column/catalog.json +2 -1
- package/a2ui/dist/catalog/Column/index.d.ts +5 -0
- package/a2ui/dist/catalog/Column/index.jsx +3 -0
- package/a2ui/dist/catalog/Column/index.jsx.map +1 -1
- package/a2ui/dist/catalog/DateTimeInput/catalog.json +2 -1
- package/a2ui/dist/catalog/DateTimeInput/index.d.ts +5 -0
- package/a2ui/dist/catalog/DateTimeInput/index.jsx +4 -10
- package/a2ui/dist/catalog/DateTimeInput/index.jsx.map +1 -1
- package/a2ui/dist/catalog/DateTimeInput/utils.d.ts +0 -1
- package/a2ui/dist/catalog/DateTimeInput/utils.js +0 -3
- package/a2ui/dist/catalog/DateTimeInput/utils.js.map +1 -1
- package/a2ui/dist/catalog/Divider/catalog.json +2 -1
- package/a2ui/dist/catalog/Divider/index.d.ts +5 -0
- package/a2ui/dist/catalog/Divider/index.jsx +3 -0
- package/a2ui/dist/catalog/Divider/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Icon/catalog.json +2 -1
- package/a2ui/dist/catalog/Icon/index.d.ts +5 -0
- package/a2ui/dist/catalog/Icon/index.jsx +3 -0
- package/a2ui/dist/catalog/Icon/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Image/catalog.json +2 -1
- package/a2ui/dist/catalog/Image/index.d.ts +5 -0
- package/a2ui/dist/catalog/Image/index.jsx +3 -0
- package/a2ui/dist/catalog/Image/index.jsx.map +1 -1
- package/a2ui/dist/catalog/LazyComponent/catalog.json +37 -0
- package/a2ui/dist/catalog/LazyComponent/index.d.ts +27 -0
- package/a2ui/dist/catalog/LazyComponent/index.jsx +39 -0
- package/a2ui/dist/catalog/LazyComponent/index.jsx.map +1 -0
- package/a2ui/dist/catalog/LineChart/catalog.json +2 -1
- package/a2ui/dist/catalog/LineChart/index.d.ts +8 -0
- package/a2ui/dist/catalog/LineChart/index.jsx +3 -0
- package/a2ui/dist/catalog/LineChart/index.jsx.map +1 -1
- package/a2ui/dist/catalog/List/catalog.json +2 -1
- package/a2ui/dist/catalog/List/index.d.ts +5 -0
- package/a2ui/dist/catalog/List/index.jsx +3 -0
- package/a2ui/dist/catalog/List/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Loading/catalog.json +16 -0
- package/a2ui/dist/catalog/Loading/index.d.ts +15 -0
- package/a2ui/dist/catalog/Loading/index.jsx +14 -0
- package/a2ui/dist/catalog/Loading/index.jsx.map +1 -0
- package/a2ui/dist/catalog/Modal/catalog.json +2 -1
- package/a2ui/dist/catalog/Modal/index.d.ts +5 -0
- package/a2ui/dist/catalog/Modal/index.jsx +3 -0
- package/a2ui/dist/catalog/Modal/index.jsx.map +1 -1
- package/a2ui/dist/catalog/PieChart/catalog.json +2 -1
- package/a2ui/dist/catalog/PieChart/index.d.ts +8 -0
- package/a2ui/dist/catalog/PieChart/index.jsx +3 -0
- package/a2ui/dist/catalog/PieChart/index.jsx.map +1 -1
- package/a2ui/dist/catalog/RadioGroup/catalog.json +2 -1
- package/a2ui/dist/catalog/RadioGroup/index.d.ts +5 -0
- package/a2ui/dist/catalog/RadioGroup/index.jsx +3 -0
- package/a2ui/dist/catalog/RadioGroup/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Row/catalog.json +2 -1
- package/a2ui/dist/catalog/Row/index.d.ts +5 -0
- package/a2ui/dist/catalog/Row/index.jsx +3 -0
- package/a2ui/dist/catalog/Row/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Slider/catalog.json +2 -1
- package/a2ui/dist/catalog/Slider/index.d.ts +5 -0
- package/a2ui/dist/catalog/Slider/index.jsx +3 -0
- package/a2ui/dist/catalog/Slider/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Tabs/catalog.json +2 -1
- package/a2ui/dist/catalog/Tabs/index.d.ts +5 -0
- package/a2ui/dist/catalog/Tabs/index.jsx +3 -0
- package/a2ui/dist/catalog/Tabs/index.jsx.map +1 -1
- package/a2ui/dist/catalog/Text/catalog.json +2 -1
- package/a2ui/dist/catalog/Text/index.d.ts +5 -0
- package/a2ui/dist/catalog/Text/index.jsx +3 -0
- package/a2ui/dist/catalog/Text/index.jsx.map +1 -1
- package/a2ui/dist/catalog/TextField/catalog.json +2 -1
- package/a2ui/dist/catalog/TextField/index.d.ts +5 -0
- package/a2ui/dist/catalog/TextField/index.jsx +3 -0
- package/a2ui/dist/catalog/TextField/index.jsx.map +1 -1
- package/a2ui/dist/catalog/defineCatalog.d.ts +4 -4
- package/a2ui/dist/catalog/defineCatalog.js.map +1 -1
- package/a2ui/dist/catalog/index.d.ts +2 -0
- package/a2ui/dist/catalog/index.js +92 -18
- package/a2ui/dist/catalog/index.js.map +1 -1
- package/a2ui/dist/catalog.json +2603 -0
- package/a2ui/dist/index.d.ts +1 -1
- package/a2ui/dist/index.js +2 -2
- package/a2ui/dist/index.js.map +1 -1
- package/a2ui/dist/react/A2UI.d.ts +3 -0
- package/a2ui/dist/react/A2UI.jsx.map +1 -1
- package/a2ui/dist/react/A2UIRenderer.d.ts +5 -18
- package/a2ui/dist/react/A2UIRenderer.jsx +3 -13
- package/a2ui/dist/react/A2UIRenderer.jsx.map +1 -1
- package/a2ui/dist/react/useAction.d.ts +7 -0
- package/a2ui/dist/react/useAction.js +4 -0
- package/a2ui/dist/react/useAction.js.map +1 -1
- package/a2ui/dist/react/useDataBinding.d.ts +7 -5
- package/a2ui/dist/react/useDataBinding.js +18 -0
- package/a2ui/dist/react/useDataBinding.js.map +1 -1
- package/a2ui/dist/store/FunctionRegistry.d.ts +7 -0
- package/a2ui/dist/store/FunctionRegistry.js +4 -0
- package/a2ui/dist/store/FunctionRegistry.js.map +1 -1
- package/a2ui/dist/store/MessageProcessor.d.ts +7 -0
- package/a2ui/dist/store/MessageProcessor.js +4 -0
- package/a2ui/dist/store/MessageProcessor.js.map +1 -1
- package/a2ui/dist/store/MessageStore.d.ts +6 -0
- package/a2ui/dist/store/MessageStore.js +3 -0
- package/a2ui/dist/store/MessageStore.js.map +1 -1
- package/a2ui/dist/store/Resource.d.ts +8 -0
- package/a2ui/dist/store/Resource.js +4 -0
- package/a2ui/dist/store/Resource.js.map +1 -1
- package/a2ui/dist/store/SignalStore.d.ts +3 -2
- package/a2ui/dist/store/SignalStore.js +9 -0
- package/a2ui/dist/store/SignalStore.js.map +1 -1
- package/a2ui/dist/store/resolveDynamic.d.ts +4 -3
- package/a2ui/dist/store/resolveDynamic.js +19 -0
- package/a2ui/dist/store/resolveDynamic.js.map +1 -1
- package/a2ui/dist/store/resolveFunctionCall.d.ts +7 -0
- package/a2ui/dist/store/resolveFunctionCall.js +4 -0
- package/a2ui/dist/store/resolveFunctionCall.js.map +1 -1
- package/a2ui/dist/store/types.d.ts +13 -0
- package/a2ui/dist/store/utils.d.ts +6 -4
- package/a2ui/dist/store/utils.js +26 -0
- package/a2ui/dist/store/utils.js.map +1 -1
- package/a2ui/dist/tsconfig.build.tsbuildinfo +1 -1
- package/a2ui/docs/catalog-guide.md +407 -0
- package/a2ui/docs/catalog-guide_zh.md +379 -0
- package/a2ui/docs/overview.md +312 -0
- package/a2ui/docs/overview_zh.md +289 -0
- package/a2ui/docs/system-prompts.md +187 -0
- package/a2ui/docs/system-prompts_zh.md +187 -0
- package/a2ui/src/catalog/README.md +12 -0
- package/a2ui/src/catalog/index.ts +52 -0
- package/a2ui/src/catalog/readme_zh.md +11 -0
- package/a2ui/src/index.ts +116 -0
- package/a2ui/styles/catalog/Button.css +5 -5
- package/a2ui/styles/catalog/DateTimeInput.css +22 -30
- package/a2ui/styles/catalog/Loading.css +61 -0
- package/a2ui-catalog-extractor/README.md +14 -7
- package/a2ui-catalog-extractor/dist/cli.d.ts +1 -0
- package/a2ui-catalog-extractor/dist/cli.js +15 -6
- package/a2ui-catalog-extractor/dist/cli.js.map +1 -1
- package/a2ui-catalog-extractor/dist/index.d.ts +97 -2
- package/a2ui-catalog-extractor/dist/index.js +91 -6
- package/a2ui-catalog-extractor/dist/index.js.map +1 -1
- package/a2ui-catalog-extractor/dist/tsconfig.build.tsbuildinfo +1 -1
- package/a2ui-catalog-extractor/skills/a2ui-catalog-extractor/SKILL.md +1 -1
- package/a2ui-prompt/README.md +3 -2
- package/a2ui-prompt/dist/index.d.ts +41 -0
- package/a2ui-prompt/dist/index.js +159 -84
- package/cli/README.md +26 -0
- package/cli/bin/cli.js +7 -265
- package/cli/dist/a2ui/create.d.ts +5 -0
- package/cli/dist/a2ui/create.js +178 -0
- package/cli/dist/a2ui/create.js.map +1 -0
- package/cli/dist/a2ui/index.d.ts +5 -0
- package/cli/dist/a2ui/index.js +170 -0
- package/cli/dist/a2ui/index.js.map +1 -0
- package/cli/dist/cli.d.ts +4 -0
- package/cli/dist/cli.js +40 -0
- package/cli/dist/cli.js.map +1 -0
- package/cli/dist/openui.d.ts +1 -0
- package/cli/dist/openui.js +21 -0
- package/cli/dist/openui.js.map +1 -0
- package/cli/dist/tsconfig.build.tsbuildinfo +1 -0
- package/cli/dist/utils.d.ts +2 -0
- package/cli/dist/utils.js +17 -0
- package/cli/dist/utils.js.map +1 -0
- package/cli/templates/default/lynx.config.ts +13 -0
- package/cli/templates/default/package.json +27 -0
- package/cli/templates/default/src/App.css +88 -0
- package/cli/templates/default/src/App.tsx +100 -0
- package/cli/templates/default/src/index.tsx +10 -0
- package/cli/templates/default/src/messages.ts +158 -0
- package/cli/templates/default/src/rspeedy-env.d.ts +14 -0
- package/cli/templates/default/src/tsconfig.json +17 -0
- package/cli/templates/default/tsconfig.json +15 -0
- package/cli/templates/default/tsconfig.node.json +16 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/index.ts +12 -0
- package/openui/README.md +50 -46
- package/openui/dist/catalog/Action/{index.js → index.jsx} +1 -1
- package/openui/dist/catalog/Action/index.jsx.map +1 -0
- package/openui/dist/catalog/Button/index.d.ts +8 -8
- package/openui/dist/catalog/Button/{index.js → index.jsx} +28 -14
- package/openui/dist/catalog/Button/index.jsx.map +1 -0
- package/openui/dist/catalog/Card/index.d.ts +1 -1
- package/openui/dist/catalog/Card/{index.js → index.jsx} +5 -4
- package/openui/dist/catalog/Card/{index.js.map → index.jsx.map} +1 -1
- package/openui/dist/catalog/CardHeader/index.d.ts +1 -1
- package/openui/dist/catalog/CardHeader/index.jsx +20 -0
- package/openui/dist/catalog/CardHeader/index.jsx.map +1 -0
- package/openui/dist/catalog/CheckBox/index.d.ts +16 -0
- package/openui/dist/catalog/CheckBox/index.jsx +82 -0
- package/openui/dist/catalog/CheckBox/index.jsx.map +1 -0
- package/openui/dist/catalog/Icon/index.d.ts +44 -0
- package/openui/dist/catalog/Icon/index.jsx +66 -0
- package/openui/dist/catalog/Icon/index.jsx.map +1 -0
- package/openui/dist/catalog/Image/index.d.ts +19 -0
- package/openui/dist/catalog/Image/index.jsx +40 -0
- package/openui/dist/catalog/Image/index.jsx.map +1 -0
- package/openui/dist/catalog/Loading/index.d.ts +7 -0
- package/openui/dist/catalog/Loading/index.jsx +25 -0
- package/openui/dist/catalog/Loading/index.jsx.map +1 -0
- package/openui/dist/catalog/RadioGroup/index.d.ts +21 -0
- package/openui/dist/catalog/RadioGroup/index.jsx +99 -0
- package/openui/dist/catalog/RadioGroup/index.jsx.map +1 -0
- package/openui/dist/catalog/Separator/index.d.ts +1 -1
- package/openui/dist/catalog/Separator/{index.js → index.jsx} +3 -4
- package/openui/dist/catalog/Separator/index.jsx.map +1 -0
- package/openui/dist/catalog/Slider/index.d.ts +19 -0
- package/openui/dist/catalog/Slider/index.jsx +139 -0
- package/openui/dist/catalog/Slider/index.jsx.map +1 -0
- package/openui/dist/catalog/Stack/index.d.ts +1 -1
- package/openui/dist/catalog/Stack/{index.js → index.jsx} +3 -4
- package/openui/dist/catalog/Stack/{index.js.map → index.jsx.map} +1 -1
- package/openui/dist/catalog/Tag/index.d.ts +1 -1
- package/openui/dist/catalog/Tag/{index.js → index.jsx} +5 -4
- package/openui/dist/catalog/Tag/index.jsx.map +1 -0
- package/openui/dist/catalog/TextContent/index.d.ts +1 -1
- package/openui/dist/catalog/TextContent/{index.js → index.jsx} +5 -4
- package/openui/dist/catalog/TextContent/{index.js.map → index.jsx.map} +1 -1
- package/openui/dist/catalog/TextField/index.d.ts +23 -0
- package/openui/dist/catalog/TextField/index.jsx +132 -0
- package/openui/dist/catalog/TextField/index.jsx.map +1 -0
- package/openui/dist/catalog/index.d.ts +14 -7
- package/openui/dist/catalog/index.js +14 -7
- package/openui/dist/catalog/index.js.map +1 -1
- package/openui/dist/core/context.d.ts +22 -8
- package/openui/dist/core/{context.js → context.jsx} +10 -3
- package/openui/dist/core/context.jsx.map +1 -0
- package/openui/dist/core/createLibrary.d.ts +8 -1
- package/openui/dist/core/{createLibrary.js → createLibrary.jsx} +18 -3
- package/openui/dist/core/createLibrary.jsx.map +1 -0
- package/openui/dist/core/hooks/index.d.ts +1 -0
- package/openui/dist/core/hooks/index.js +1 -0
- package/openui/dist/core/hooks/index.js.map +1 -1
- package/openui/dist/core/hooks/useFormValidation.d.ts +9 -0
- package/openui/dist/core/hooks/useFormValidation.js +6 -0
- package/openui/dist/core/hooks/useFormValidation.js.map +1 -1
- package/openui/dist/core/hooks/useOpenUIState.d.ts +8 -2
- package/openui/dist/core/hooks/useOpenUIState.js +3 -1
- package/openui/dist/core/hooks/useOpenUIState.js.map +1 -1
- package/openui/dist/core/hooks/useStateField.d.ts +3 -0
- package/openui/dist/core/hooks/useStateField.js +4 -1
- package/openui/dist/core/hooks/useStateField.js.map +1 -1
- package/openui/dist/core/index.d.ts +13 -7
- package/openui/dist/core/index.js +7 -4
- package/openui/dist/core/index.js.map +1 -1
- package/openui/dist/core/library.d.ts +6 -1
- package/openui/dist/core/{library.js → library.jsx} +9 -1
- package/openui/dist/core/library.jsx.map +1 -0
- package/openui/dist/core/renderer.css +527 -0
- package/openui/dist/core/renderer.d.ts +41 -4
- package/openui/dist/core/renderer.jsx +284 -0
- package/openui/dist/core/renderer.jsx.map +1 -0
- package/openui/dist/core/runtime/index.d.ts +1 -0
- package/openui/dist/core/runtime/index.js +5 -0
- package/openui/dist/core/runtime/index.js.map +1 -0
- package/openui/dist/core/runtime/reactive.d.ts +7 -0
- package/openui/dist/core/runtime/reactive.js +10 -0
- package/openui/dist/core/runtime/reactive.js.map +1 -0
- package/openui/dist/openui-prompt/index.d.ts +47 -0
- package/openui/dist/openui-prompt/index.js +321 -0
- package/openui/dist/openui-prompt/index.js.map +1 -0
- package/package.json +20 -8
- package/openui/dist/catalog/Action/index.js.map +0 -1
- package/openui/dist/catalog/Button/index.js.map +0 -1
- package/openui/dist/catalog/CardHeader/index.js +0 -18
- package/openui/dist/catalog/CardHeader/index.js.map +0 -1
- package/openui/dist/catalog/Separator/index.js.map +0 -1
- package/openui/dist/catalog/Tag/index.js.map +0 -1
- package/openui/dist/core/context.js.map +0 -1
- package/openui/dist/core/createLibrary.js.map +0 -1
- package/openui/dist/core/library.js.map +0 -1
- package/openui/dist/core/renderer.js +0 -139
- package/openui/dist/core/renderer.js.map +0 -1
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
# Catalogs, built-ins, and custom components
|
|
2
|
+
|
|
3
|
+
A **catalog** is the contract between your Agent and your client: it lists
|
|
4
|
+
the components the renderer is allowed to instantiate and the functions it
|
|
5
|
+
can execute, and it carries the optional JSON schemas an Agent reads during
|
|
6
|
+
a handshake. This guide covers everything about composing that contract —
|
|
7
|
+
from the one-line minimum, through the built-in component set, to shipping
|
|
8
|
+
your own components and generating their schemas.
|
|
9
|
+
|
|
10
|
+
If you only skim one section, make it [The built-in components](#the-built-in-components) and [Basic-catalog functions](#basic-catalog-functions): those are the vocabulary your Agent
|
|
11
|
+
gets to work with.
|
|
12
|
+
|
|
13
|
+
## What a catalog is
|
|
14
|
+
|
|
15
|
+
A catalog has two kinds of entries:
|
|
16
|
+
|
|
17
|
+
- **Components** — map a protocol name (`"Text"`, `"Card"`, your
|
|
18
|
+
`"MyChart"`) to a ReactLynx component the client renders.
|
|
19
|
+
- **Functions** — map a protocol function name (`"formatDate"`,
|
|
20
|
+
`"required"`) to a client-side implementation the renderer calls while
|
|
21
|
+
resolving props, actions, and validation checks.
|
|
22
|
+
|
|
23
|
+
You build one with `defineCatalog`, then either pass it (or a raw input
|
|
24
|
+
array) to `<A2UI catalogs={…}>` for rendering, or run it through
|
|
25
|
+
`serializeCatalog` to announce the contract to your Agent.
|
|
26
|
+
|
|
27
|
+
A component's **protocol name** comes from `displayName ?? component.name`,
|
|
28
|
+
unless you pair it with a manifest — in which case the manifest's top-level
|
|
29
|
+
key is authoritative. The name is the only thing the Agent references, so
|
|
30
|
+
keeping it stable matters (see the minifier warning below).
|
|
31
|
+
|
|
32
|
+
## Start small: renderer-only components
|
|
33
|
+
|
|
34
|
+
If your app only needs to render, pass bare components. No schemas, no
|
|
35
|
+
ceremony.
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { defineCatalog, Text, Button } from '@lynx-js/genui/a2ui';
|
|
39
|
+
|
|
40
|
+
const catalog = defineCatalog([Text, Button]);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
You can pass the same array straight to `<A2UI>` without calling
|
|
44
|
+
`defineCatalog` yourself — the component composes it internally:
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
<A2UI messageStore={store} catalogs={[Text, Button]} onAction={…} />;
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Bundlers tree-shake unused components: pulling in `Text` does **not** drag
|
|
51
|
+
`Button`, `Card`, or any other built-in into your bundle.
|
|
52
|
+
|
|
53
|
+
> ⚠️ **Production minifiers rename function declarations**, which breaks the
|
|
54
|
+
> `component.name` fallback. For production safety, either set an explicit
|
|
55
|
+
> `displayName` on every custom component (the string literal survives
|
|
56
|
+
> minification) or pair the component with its `catalog.json` manifest using
|
|
57
|
+
> the tuple form — the manifest key is authoritative and immune to
|
|
58
|
+
> minification.
|
|
59
|
+
|
|
60
|
+
## The built-in components
|
|
61
|
+
|
|
62
|
+
The package ships 21 A2UI v0.9 basic-catalog renderers. Each is an
|
|
63
|
+
independent, tree-shakeable export, available from the root or from
|
|
64
|
+
`@lynx-js/genui/a2ui/catalog/<Name>`.
|
|
65
|
+
|
|
66
|
+
**Layout and containers**
|
|
67
|
+
|
|
68
|
+
| Component | What it renders |
|
|
69
|
+
| --------- | ------------------------------------------------------------------ |
|
|
70
|
+
| `Row` | A horizontal layout container for a `children` list. |
|
|
71
|
+
| `Column` | A vertical layout container for a `children` list. |
|
|
72
|
+
| `Card` | A padded, elevated surface that wraps a single `child`. |
|
|
73
|
+
| `List` | A scrollable collection — the usual target for templated children. |
|
|
74
|
+
| `Tabs` | Tabbed sections that switch between child views. |
|
|
75
|
+
| `Modal` | An overlay/dialog surface layered above the rest of the UI. |
|
|
76
|
+
| `Divider` | A thin separator rule between items. |
|
|
77
|
+
|
|
78
|
+
**Content**
|
|
79
|
+
|
|
80
|
+
| Component | What it renders |
|
|
81
|
+
| --------------- | -------------------------------------------------------------- |
|
|
82
|
+
| `Text` | A string of text, with a `variant` such as `body` for styling. |
|
|
83
|
+
| `Image` | An image from a source URL. |
|
|
84
|
+
| `Icon` | A named icon glyph. |
|
|
85
|
+
| `LazyComponent` | A ReactLynx lazy bundle loaded from a resource URL. |
|
|
86
|
+
|
|
87
|
+
**Input and actions**
|
|
88
|
+
|
|
89
|
+
| Component | What it renders |
|
|
90
|
+
| --------------- | ------------------------------------------------- |
|
|
91
|
+
| `Button` | A tappable button that dispatches a user action. |
|
|
92
|
+
| `TextField` | A single-line text input bound to the data model. |
|
|
93
|
+
| `CheckBox` | A boolean toggle. |
|
|
94
|
+
| `RadioGroup` | A single-choice set of radio options. |
|
|
95
|
+
| `ChoicePicker` | A picker/select for choosing among options. |
|
|
96
|
+
| `Slider` | A numeric value selected along a range. |
|
|
97
|
+
| `DateTimeInput` | A date and/or time input. |
|
|
98
|
+
|
|
99
|
+
**Data visualization**
|
|
100
|
+
|
|
101
|
+
| Component | What it renders |
|
|
102
|
+
| ----------- | ------------------------------------------ |
|
|
103
|
+
| `LineChart` | A line chart over a series of data points. |
|
|
104
|
+
| `PieChart` | A pie chart over a set of values. |
|
|
105
|
+
|
|
106
|
+
**Feedback**
|
|
107
|
+
|
|
108
|
+
| Component | What it renders |
|
|
109
|
+
| --------- | ----------------------------------------------------------------------------------------------- |
|
|
110
|
+
| `Loading` | A loading indicator. Also the default `renderFallback` for `<A2UI>` while a surface is pending. |
|
|
111
|
+
|
|
112
|
+
To learn the exact props each one accepts, read its manifest at
|
|
113
|
+
`@lynx-js/genui/a2ui/catalog/<Name>/catalog.json` — that JSON is the same
|
|
114
|
+
schema the Agent sees.
|
|
115
|
+
|
|
116
|
+
## Adding manifests for Agent handshakes
|
|
117
|
+
|
|
118
|
+
If you want `serializeCatalog(...)` to emit JSON Schema for each component
|
|
119
|
+
(so the Agent knows which props to send), pair each component with the JSON
|
|
120
|
+
generated at `dist/catalog/<Name>/catalog.json` using the tuple form:
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
import { Text, defineCatalog, serializeCatalog } from '@lynx-js/genui/a2ui';
|
|
124
|
+
import textManifest from '@lynx-js/genui/a2ui/catalog/Text/catalog.json'
|
|
125
|
+
with { type: 'json' };
|
|
126
|
+
|
|
127
|
+
const catalog = defineCatalog([[Text, textManifest]]);
|
|
128
|
+
agentChannel.handshake({ catalog: serializeCatalog(catalog) });
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
The protocol name lives in the JSON as the top-level key, so the runtime
|
|
132
|
+
never duplicates it. Components you register without a manifest still
|
|
133
|
+
render fine — they just serialize to `{ name }` only, which tells the Agent
|
|
134
|
+
the component exists without describing its props.
|
|
135
|
+
|
|
136
|
+
## Basic-catalog functions
|
|
137
|
+
|
|
138
|
+
A2UI messages can embed function calls in dynamic props, action payloads,
|
|
139
|
+
and validation checks — for example `{ call: 'formatDate', args: { … } }`.
|
|
140
|
+
These run **on the client at render time**. To make them available, spread
|
|
141
|
+
`...basicFunctions` into the same catalog input list:
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
import { Text, basicFunctions, defineCatalog } from '@lynx-js/genui/a2ui';
|
|
145
|
+
|
|
146
|
+
const catalog = defineCatalog([Text, ...basicFunctions]);
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
`basicFunctions` is an array of ready-made entries whose implementations
|
|
150
|
+
come straight from the upstream `@a2ui/web_core` basic catalog, so the wire
|
|
151
|
+
contract stays aligned with the A2UI v0.9 spec for free. It covers 25
|
|
152
|
+
functions:
|
|
153
|
+
|
|
154
|
+
| Category | Functions (protocol names) |
|
|
155
|
+
| ---------- | --------------------------------------------------------------------------- |
|
|
156
|
+
| Arithmetic | `add`, `subtract`, `multiply`, `divide` |
|
|
157
|
+
| Comparison | `equals`, `not_equals`, `greater_than`, `less_than` |
|
|
158
|
+
| Logic | `and`, `or`, `not` |
|
|
159
|
+
| Text | `contains`, `starts_with`, `ends_with`, `length` |
|
|
160
|
+
| Validation | `required`, `regex`, `numeric`, `email` |
|
|
161
|
+
| Formatting | `formatString`, `formatNumber`, `formatCurrency`, `formatDate`, `pluralize` |
|
|
162
|
+
| Action | `openUrl` |
|
|
163
|
+
|
|
164
|
+
> Note the mixed casing — comparison/text helpers use `snake_case`
|
|
165
|
+
> (`not_equals`, `starts_with`) while formatters use `camelCase`
|
|
166
|
+
> (`formatDate`, `openUrl`). These are the upstream A2UI v0.9 names; use
|
|
167
|
+
> them verbatim in messages.
|
|
168
|
+
|
|
169
|
+
Include `...basicFunctions` whenever your Agent might emit any of these. If
|
|
170
|
+
a message references a function the catalog does not contain, that call
|
|
171
|
+
resolves to `undefined` rather than throwing.
|
|
172
|
+
|
|
173
|
+
If you build your own renderer instead of using `<A2UI>`, call
|
|
174
|
+
`registerBasicFunctions()` once to register the same implementations into
|
|
175
|
+
the shared `functionRegistry`.
|
|
176
|
+
|
|
177
|
+
## Why there is no `catalog/all`
|
|
178
|
+
|
|
179
|
+
The package intentionally does **not** ship an "all-in-one" catalog
|
|
180
|
+
constant or a `@lynx-js/genui/a2ui/catalog/all` export. A single top-level
|
|
181
|
+
array referencing every built-in would defeat tree-shaking — every consumer
|
|
182
|
+
of that aggregate would bundle every component, even the ones they never
|
|
183
|
+
render. Composition is per-component, and the bundle cost stays visible at
|
|
184
|
+
the import site.
|
|
185
|
+
|
|
186
|
+
## The paste-able "every built-in" recipe
|
|
187
|
+
|
|
188
|
+
When you genuinely want all of them, keep the list at the integration site.
|
|
189
|
+
This composes every built-in component with its manifest, plus the basic
|
|
190
|
+
functions:
|
|
191
|
+
|
|
192
|
+
```tsx
|
|
193
|
+
import {
|
|
194
|
+
basicFunctions,
|
|
195
|
+
defineCatalog,
|
|
196
|
+
Button,
|
|
197
|
+
Card,
|
|
198
|
+
CheckBox,
|
|
199
|
+
ChoicePicker,
|
|
200
|
+
Column,
|
|
201
|
+
DateTimeInput,
|
|
202
|
+
Divider,
|
|
203
|
+
LazyComponent,
|
|
204
|
+
Icon,
|
|
205
|
+
Image,
|
|
206
|
+
LineChart,
|
|
207
|
+
List,
|
|
208
|
+
Loading,
|
|
209
|
+
Modal,
|
|
210
|
+
PieChart,
|
|
211
|
+
RadioGroup,
|
|
212
|
+
Row,
|
|
213
|
+
Slider,
|
|
214
|
+
Tabs,
|
|
215
|
+
Text,
|
|
216
|
+
TextField,
|
|
217
|
+
} from '@lynx-js/genui/a2ui';
|
|
218
|
+
import buttonManifest from '@lynx-js/genui/a2ui/catalog/Button/catalog.json' with {
|
|
219
|
+
type: 'json',
|
|
220
|
+
};
|
|
221
|
+
import cardManifest from '@lynx-js/genui/a2ui/catalog/Card/catalog.json' with {
|
|
222
|
+
type: 'json',
|
|
223
|
+
};
|
|
224
|
+
import checkBoxManifest from '@lynx-js/genui/a2ui/catalog/CheckBox/catalog.json' with {
|
|
225
|
+
type: 'json',
|
|
226
|
+
};
|
|
227
|
+
import choicePickerManifest from '@lynx-js/genui/a2ui/catalog/ChoicePicker/catalog.json' with {
|
|
228
|
+
type: 'json',
|
|
229
|
+
};
|
|
230
|
+
import columnManifest from '@lynx-js/genui/a2ui/catalog/Column/catalog.json' with {
|
|
231
|
+
type: 'json',
|
|
232
|
+
};
|
|
233
|
+
import dateTimeInputManifest from '@lynx-js/genui/a2ui/catalog/DateTimeInput/catalog.json' with {
|
|
234
|
+
type: 'json',
|
|
235
|
+
};
|
|
236
|
+
import dividerManifest from '@lynx-js/genui/a2ui/catalog/Divider/catalog.json' with {
|
|
237
|
+
type: 'json',
|
|
238
|
+
};
|
|
239
|
+
import lazyComponentManifest from '@lynx-js/genui/a2ui/catalog/LazyComponent/catalog.json' with {
|
|
240
|
+
type: 'json',
|
|
241
|
+
};
|
|
242
|
+
import iconManifest from '@lynx-js/genui/a2ui/catalog/Icon/catalog.json' with {
|
|
243
|
+
type: 'json',
|
|
244
|
+
};
|
|
245
|
+
import imageManifest from '@lynx-js/genui/a2ui/catalog/Image/catalog.json' with {
|
|
246
|
+
type: 'json',
|
|
247
|
+
};
|
|
248
|
+
import lineChartManifest from '@lynx-js/genui/a2ui/catalog/LineChart/catalog.json' with {
|
|
249
|
+
type: 'json',
|
|
250
|
+
};
|
|
251
|
+
import listManifest from '@lynx-js/genui/a2ui/catalog/List/catalog.json' with {
|
|
252
|
+
type: 'json',
|
|
253
|
+
};
|
|
254
|
+
import loadingManifest from '@lynx-js/genui/a2ui/catalog/Loading/catalog.json' with {
|
|
255
|
+
type: 'json',
|
|
256
|
+
};
|
|
257
|
+
import modalManifest from '@lynx-js/genui/a2ui/catalog/Modal/catalog.json' with {
|
|
258
|
+
type: 'json',
|
|
259
|
+
};
|
|
260
|
+
import pieChartManifest from '@lynx-js/genui/a2ui/catalog/PieChart/catalog.json' with {
|
|
261
|
+
type: 'json',
|
|
262
|
+
};
|
|
263
|
+
import radioGroupManifest from '@lynx-js/genui/a2ui/catalog/RadioGroup/catalog.json' with {
|
|
264
|
+
type: 'json',
|
|
265
|
+
};
|
|
266
|
+
import rowManifest from '@lynx-js/genui/a2ui/catalog/Row/catalog.json' with {
|
|
267
|
+
type: 'json',
|
|
268
|
+
};
|
|
269
|
+
import sliderManifest from '@lynx-js/genui/a2ui/catalog/Slider/catalog.json' with {
|
|
270
|
+
type: 'json',
|
|
271
|
+
};
|
|
272
|
+
import tabsManifest from '@lynx-js/genui/a2ui/catalog/Tabs/catalog.json' with {
|
|
273
|
+
type: 'json',
|
|
274
|
+
};
|
|
275
|
+
import textManifest from '@lynx-js/genui/a2ui/catalog/Text/catalog.json' with {
|
|
276
|
+
type: 'json',
|
|
277
|
+
};
|
|
278
|
+
import textFieldManifest from '@lynx-js/genui/a2ui/catalog/TextField/catalog.json' with {
|
|
279
|
+
type: 'json',
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
export const allBuiltins = defineCatalog([
|
|
283
|
+
[Text, textManifest],
|
|
284
|
+
[Image, imageManifest],
|
|
285
|
+
[Row, rowManifest],
|
|
286
|
+
[Column, columnManifest],
|
|
287
|
+
[List, listManifest],
|
|
288
|
+
[Card, cardManifest],
|
|
289
|
+
[Modal, modalManifest],
|
|
290
|
+
[Button, buttonManifest],
|
|
291
|
+
[Divider, dividerManifest],
|
|
292
|
+
[LazyComponent, lazyComponentManifest],
|
|
293
|
+
[LineChart, lineChartManifest],
|
|
294
|
+
[PieChart, pieChartManifest],
|
|
295
|
+
[TextField, textFieldManifest],
|
|
296
|
+
[CheckBox, checkBoxManifest],
|
|
297
|
+
[ChoicePicker, choicePickerManifest],
|
|
298
|
+
[DateTimeInput, dateTimeInputManifest],
|
|
299
|
+
[Icon, iconManifest],
|
|
300
|
+
[RadioGroup, radioGroupManifest],
|
|
301
|
+
[Slider, sliderManifest],
|
|
302
|
+
[Tabs, tabsManifest],
|
|
303
|
+
[Loading, loadingManifest],
|
|
304
|
+
...basicFunctions,
|
|
305
|
+
]);
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
Drop the manifest import and tuple form for any component whose schema you
|
|
309
|
+
do not need to send to the Agent — `defineCatalog([Text, Button])` is
|
|
310
|
+
perfectly valid. Keep `...basicFunctions` if your messages use function
|
|
311
|
+
calls.
|
|
312
|
+
|
|
313
|
+
## Custom components
|
|
314
|
+
|
|
315
|
+
A catalog component is _anything_ that takes a single props object and
|
|
316
|
+
returns a `ReactNode`. Its function name — or its `displayName` — is the
|
|
317
|
+
protocol name the Agent will use:
|
|
318
|
+
|
|
319
|
+
```tsx
|
|
320
|
+
function MyChart(props: { data: number[] }) { /* … */ }
|
|
321
|
+
// Required for production-safe naming: minifiers rewrite `function` names,
|
|
322
|
+
// but the `displayName` string literal survives.
|
|
323
|
+
MyChart.displayName = 'MyChart';
|
|
324
|
+
|
|
325
|
+
<A2UI catalogs={[Text, Button, MyChart]} … />;
|
|
326
|
+
// Agent emits `{ component: 'MyChart', data: [...] }` → renders MyChart.
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
Custom components receive runtime-shaped props from the protocol stream. For
|
|
330
|
+
anything beyond a leaf component, reach into `@lynx-js/genui/a2ui/react`,
|
|
331
|
+
the contract custom components plug into:
|
|
332
|
+
|
|
333
|
+
- **`useDataBinding`** — resolve a bound value (`{ path }`) against the
|
|
334
|
+
surface's data model and get a setter back, so inputs can write user edits
|
|
335
|
+
into the model.
|
|
336
|
+
- **`useResolvedProps`** — resolve a whole prop bag at once, expanding data
|
|
337
|
+
bindings and function calls into concrete values.
|
|
338
|
+
- **`useAction`** — turn a protocol action into a `sendAction` callback you
|
|
339
|
+
fire on tap/submit; the result loops back out through `<A2UI onAction>`.
|
|
340
|
+
- **`useChecks`** — evaluate validation checks (built from basic functions
|
|
341
|
+
like `required`/`email`) and report pass/fail with messages.
|
|
342
|
+
- **`NodeRenderer`** — render child component ids against the same surface,
|
|
343
|
+
the same way the built-ins render their children.
|
|
344
|
+
|
|
345
|
+
## Generating a manifest for a custom component
|
|
346
|
+
|
|
347
|
+
If the Agent needs to know a custom component's props, generate a manifest
|
|
348
|
+
and pair it the same way you would a built-in.
|
|
349
|
+
|
|
350
|
+
1. Describe the props as a TypeScript `interface` and annotate it with the
|
|
351
|
+
`@a2uiCatalog <ComponentName>` JSDoc tag so the extractor picks it up.
|
|
352
|
+
2. Run the public CLI to emit the JSON:
|
|
353
|
+
|
|
354
|
+
```bash
|
|
355
|
+
npx @lynx-js/genui a2ui generate catalog --catalog-dir src/catalog --out-dir dist
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
3. Pair the generated JSON with the component:
|
|
359
|
+
|
|
360
|
+
```tsx
|
|
361
|
+
import myChartManifest from './dist/catalog/MyChart/catalog.json'
|
|
362
|
+
with { type: 'json' };
|
|
363
|
+
|
|
364
|
+
const catalog = defineCatalog([[MyChart, myChartManifest]]);
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
`npx @lynx-js/genui a2ui generate catalog` is the user-facing command;
|
|
368
|
+
`@lynx-js/genui/a2ui-catalog-extractor` is the TypeDoc-powered engine behind
|
|
369
|
+
it. Two constraints to keep extraction happy: the component folder name must
|
|
370
|
+
match the exported function name (`src/catalog/MyChart/index.tsx` exports
|
|
371
|
+
`function MyChart`), and framework-level props are excluded from the emitted
|
|
372
|
+
schema. See the
|
|
373
|
+
[extractor README](../../a2ui-catalog-extractor/README.md) for details.
|
|
374
|
+
|
|
375
|
+
## Catalog API reference
|
|
376
|
+
|
|
377
|
+
All of these are exported from `@lynx-js/genui/a2ui` (and from the
|
|
378
|
+
`/catalog` subpath).
|
|
379
|
+
|
|
380
|
+
- **`defineCatalog(inputs)`** — builds the runtime catalog. `inputs` is an
|
|
381
|
+
array that can mix bare components, `[component, manifest]` tuples,
|
|
382
|
+
already-resolved entries (e.g. from `mergeCatalogs`), and function
|
|
383
|
+
entries. Duplicate names within the same kind are rejected. Function
|
|
384
|
+
entries register their impls into `functionRegistry` immediately, so any
|
|
385
|
+
`executeFunctionCall` after `defineCatalog` can route to them.
|
|
386
|
+
- **`mergeCatalogs(...catalogs)`** — merges catalogs with **last-write-wins**
|
|
387
|
+
on duplicate names. Useful for layering: a page catalog overrides a brand
|
|
388
|
+
catalog which overrides the built-ins.
|
|
389
|
+
- **`serializeCatalog(catalog)`** — emits the JSON manifest for the Agent
|
|
390
|
+
handshake. Components without an attached schema serialize to `{ name }`
|
|
391
|
+
only; functions serialize with their parameter schema when available.
|
|
392
|
+
- **`resolveCatalog(catalog)`** — returns a `name → component` map. The
|
|
393
|
+
renderer uses it internally to resolve `{ component: 'Text' }`; exposed for
|
|
394
|
+
advanced cases.
|
|
395
|
+
- **`defineFunction(impl, manifest?)`** — wraps a function implementation
|
|
396
|
+
into a catalog entry. With a manifest, the name comes from the manifest's
|
|
397
|
+
key and the schema is announced to the Agent; without one, the name comes
|
|
398
|
+
from `impl.displayName ?? impl.name` and the Agent simply won't see the
|
|
399
|
+
parameter schema.
|
|
400
|
+
|
|
401
|
+
## Where to go next
|
|
402
|
+
|
|
403
|
+
- [Overview and architecture](./overview.md) — how a message becomes UI, the
|
|
404
|
+
responsibility split, and the export map.
|
|
405
|
+
- [System prompts](./system-prompts.md) — generate the model instructions
|
|
406
|
+
that pair an Agent with your catalog.
|
|
407
|
+
- [Open the A2UI playground](https://lynxjs.org/a2ui) — try it live.
|