darkfire514 commited on
Commit
904d6be
·
verified ·
1 Parent(s): 9f069df

Upload 173 files

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. vendor/a2ui/.gemini/GEMINI.md +94 -0
  2. vendor/a2ui/.github/workflows/docs.yml +79 -0
  3. vendor/a2ui/.github/workflows/editor_build.yml +55 -0
  4. vendor/a2ui/.github/workflows/inspector_build.yml +56 -0
  5. vendor/a2ui/.github/workflows/java_build_and_test.yml +48 -0
  6. vendor/a2ui/.github/workflows/lit_samples_build.yml +54 -0
  7. vendor/a2ui/.github/workflows/ng_build_and_test.yml +72 -0
  8. vendor/a2ui/.github/workflows/python_samples_build.yml +62 -0
  9. vendor/a2ui/.github/workflows/web_build_and_test.yml +50 -0
  10. vendor/a2ui/.gitignore +16 -0
  11. vendor/a2ui/CONTRIBUTING.md +49 -0
  12. vendor/a2ui/LICENSE +203 -0
  13. vendor/a2ui/README.md +162 -0
  14. vendor/a2ui/mkdocs.yaml +184 -0
  15. vendor/a2ui/renderers/angular/.npmrc +2 -0
  16. vendor/a2ui/renderers/angular/README.md +9 -0
  17. vendor/a2ui/renderers/angular/angular.json +35 -0
  18. vendor/a2ui/renderers/angular/ng-package.json +8 -0
  19. vendor/a2ui/renderers/angular/package-lock.json +0 -0
  20. vendor/a2ui/renderers/angular/package.json +59 -0
  21. vendor/a2ui/renderers/angular/src/lib/catalog/audio.ts +50 -0
  22. vendor/a2ui/renderers/angular/src/lib/catalog/button.ts +56 -0
  23. vendor/a2ui/renderers/angular/src/lib/catalog/card.ts +57 -0
  24. vendor/a2ui/renderers/angular/src/lib/catalog/checkbox.ts +73 -0
  25. vendor/a2ui/renderers/angular/src/lib/catalog/column.ts +96 -0
  26. vendor/a2ui/renderers/angular/src/lib/catalog/datetime-input.ts +127 -0
  27. vendor/a2ui/renderers/angular/src/lib/catalog/default.ts +185 -0
  28. vendor/a2ui/renderers/angular/src/lib/catalog/divider.ts +37 -0
  29. vendor/a2ui/renderers/angular/src/lib/catalog/icon.ts +44 -0
  30. vendor/a2ui/renderers/angular/src/lib/catalog/image.ts +62 -0
  31. vendor/a2ui/renderers/angular/src/lib/catalog/list.ts +63 -0
  32. vendor/a2ui/renderers/angular/src/lib/catalog/modal.ts +113 -0
  33. vendor/a2ui/renderers/angular/src/lib/catalog/multiple-choice.ts +77 -0
  34. vendor/a2ui/renderers/angular/src/lib/catalog/row.ts +100 -0
  35. vendor/a2ui/renderers/angular/src/lib/catalog/slider.ts +73 -0
  36. vendor/a2ui/renderers/angular/src/lib/catalog/surface.ts +99 -0
  37. vendor/a2ui/renderers/angular/src/lib/catalog/tabs.ts +72 -0
  38. vendor/a2ui/renderers/angular/src/lib/catalog/text-field.ts +86 -0
  39. vendor/a2ui/renderers/angular/src/lib/catalog/text.ts +137 -0
  40. vendor/a2ui/renderers/angular/src/lib/catalog/video.ts +50 -0
  41. vendor/a2ui/renderers/angular/src/lib/config.ts +25 -0
  42. vendor/a2ui/renderers/angular/src/lib/data/index.ts +18 -0
  43. vendor/a2ui/renderers/angular/src/lib/data/markdown.ts +114 -0
  44. vendor/a2ui/renderers/angular/src/lib/data/processor.ts +47 -0
  45. vendor/a2ui/renderers/angular/src/lib/data/types.ts +29 -0
  46. vendor/a2ui/renderers/angular/src/lib/rendering/catalog.ts +36 -0
  47. vendor/a2ui/renderers/angular/src/lib/rendering/dynamic-component.ts +100 -0
  48. vendor/a2ui/renderers/angular/src/lib/rendering/index.ts +20 -0
  49. vendor/a2ui/renderers/angular/src/lib/rendering/renderer.ts +109 -0
  50. vendor/a2ui/renderers/angular/src/lib/rendering/theming.ts +22 -0
vendor/a2ui/.gemini/GEMINI.md ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # A2UI Gemini Agent Guide
2
+
3
+ This document serves as a guide for using the Gemini agent within the A2UI repository. It outlines the repository's structure, explains the core concepts of the A2UI protocol, and provides instructions for running the various demos and keeping this guide up-to-date.
4
+
5
+ ## Repository Structure
6
+
7
+ The A2UI repository is organized into several key directories:
8
+
9
+ - `specification/0.8/docs/`: Contains the primary human-readable documentation for the A2UI protocol.
10
+ - `a2ui_protocol.md`: The foundational specification document. This is the best place to start to understand the protocol's fundamental goals.
11
+ - `specification/0.8/json/`: Contains the formal JSON schema definitions for the protocol.
12
+ - `server_to_client.json`: Defines the schema for messages sent from the server to the client.
13
+ - `client_to_server.json`: Defines the schema for event messages sent from the client to the server.
14
+ - `a2a_agents/python/`: Contains Python code relating to server-side integration of A2UI
15
+ - `a2ui_extension/`: Python implementation of the A2UI A2A extension.
16
+ - `adk/samples/`: Contains demo applications that showcase the A2UI protocol in action using the ADK framework.
17
+ - `web/`: Contains the web-based client implementations (using Lit and Vite) for the samples, including a shared library (`renderers/lit`).
18
+ - `angular/`: Contains an alternative web-based client implementation using Angular.
19
+ - `eval/`: Contains a Genkit-based framework for evaluating LLM performance in generating A2UI responses.
20
+
21
+ ## A2UI Specification Overview
22
+
23
+ The A2UI protocol is a JSONL-based, streaming UI protocol designed to be easily generated by Large Language Models (LLMs). It enables a server to stream a platform-agnostic, abstract UI definition to a client, which then renders it progressively using a native widget set.
24
+
25
+ ### Core Concepts
26
+
27
+ The core concepts of the A2UI protocol are detailed in the main specification document. Rather than duplicating the content here, you should refer to the authoritative source:
28
+
29
+ - **A2UI Protocol Specification**: `@docs/a2ui_protocol.md`
30
+
31
+ This document covers the design philosophy, architecture, data flow, and core concepts of the protocol.
32
+
33
+ ### Schemas
34
+
35
+ The formal, machine-readable definitions of the protocol are maintained as JSON schemas:
36
+
37
+ - **Server-to-Client Schema**: `@specification/0.8/json/server_to_client.json`
38
+ - **Server-to-Client Schema, with standard catalog**: `@specification/0.8/json/server_to_client_with_standard_catalog.json`
39
+ - **Client-to-Server Schema**: `@specification/0.8/json/client_to_server.json`
40
+
41
+ ## Running the Demos
42
+
43
+ There are three demos available in the `a2a_samples/` directory. Each demo has a corresponding web client in the `web/` and `angular/` directories. To run a demo, you will need to start both the server and the client.
44
+
45
+ ### Running a Demo Server
46
+
47
+ To run a demo server, navigate to the demo's directory and run the `__main__.py` script. For example, to run the contact lookup demo:
48
+
49
+ ```bash
50
+ cd a2a_samples/a2ui_contact_lookup
51
+ python -m __main__
52
+ ```
53
+
54
+ ### Running a Demo Client (Lit)
55
+
56
+ To run a demo client, navigate to the corresponding client directory in `web/` and start the development server. For example, to run the contact lookup client:
57
+
58
+ ```bash
59
+ cd web/contact
60
+ npm install
61
+ npm run dev
62
+ ```
63
+
64
+ ### Running a Demo Client (Angular)
65
+
66
+ To run a demo client, navigate to the `angular/` directory and start the development server with the project name. For example, to run the contact lookup client:
67
+
68
+ ```bash
69
+ cd angular
70
+ npm install
71
+ npm start -- contact
72
+ ```
73
+
74
+ ## Renderers
75
+
76
+ There are three renderers available for A2UI:
77
+
78
+ - **Web (Lit)**: Located in `renderers/lit`, this is the primary web renderer used by the demos in `web/`.
79
+ - **Angular**: Located in `angular/projects/lib`, this is an alternative web renderer for Angular applications.
80
+ - **Flutter**: The Flutter renderer is in a separate repository: [https://github.com/flutter/genui](https://github.com/flutter/genui)
81
+
82
+ ## Keeping This Guide Updated
83
+
84
+ This document is intended to be a living guide for the repository. As the repository evolves, it's important to keep this file up-to-date. When making changes to the repository, please consider the following:
85
+
86
+ - **New Demos or Clients**: If you add a new demo or client, add it to the "Running the Demos" section.
87
+ - **Specification Changes**: If you make significant changes to the A2UI protocol, ensure that the "A2UI Specification Overview" section is updated to reflect the changes, and that any linked documents are also updated.
88
+ - **Repository Structure Changes**: If you change the directory structure of the repository, update the "Repository Structure" section.
89
+
90
+ To get this file back in sync, you can run the following commands:
91
+
92
+ 1. List all the files in the entire repo with `git ls-tree main --name-only -r`
93
+ 2. Read the ~50 most important files in the list, potentially in batches.
94
+ 3. Update this file.
vendor/a2ui/.github/workflows/docs.yml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ name: Docs Build and Deploy
16
+
17
+ on:
18
+ push:
19
+ branches:
20
+ - main
21
+ paths:
22
+ - ".github/workflows/docs.yml"
23
+ - "requirements-docs.txt"
24
+ - "mkdocs.yml"
25
+ - "docs/**"
26
+ pull_request:
27
+ branches:
28
+ - main
29
+ paths:
30
+ - ".github/workflows/docs.yml"
31
+ - "requirements-docs.txt"
32
+ - "mkdocs.yml"
33
+ - "docs/**"
34
+
35
+ jobs:
36
+ build_and_deploy:
37
+ runs-on: ubuntu-latest
38
+ permissions:
39
+ contents: write
40
+ actions: read
41
+
42
+ if: github.repository == 'google/A2UI'
43
+
44
+ steps:
45
+ - name: Checkout Code
46
+ uses: actions/checkout@v5
47
+ with:
48
+ token: ${{ secrets.GITHUB_TOKEN }}
49
+ fetch-depth: 0
50
+
51
+ - name: Configure Git Credentials
52
+ run: |
53
+ git config --global user.name github-actions[bot]
54
+ git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com
55
+
56
+ - name: Setup Python
57
+ uses: actions/setup-python@v6
58
+ with:
59
+ python-version: 3.13
60
+
61
+ - name: Restore pip cache
62
+ uses: actions/cache@v4
63
+ with:
64
+ key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-docs.txt') }}
65
+ path: ~/.cache/pip
66
+ restore-keys: |
67
+ ${{ runner.os }}-pip-
68
+
69
+ - name: Install documentation dependencies
70
+ run: pip install -r requirements-docs.txt
71
+
72
+ - name: Build Documentation (PR Check)
73
+ if: github.event_name == 'pull_request'
74
+ run: mkdocs build
75
+
76
+ - name: Deploy development version from main branch
77
+ if: github.event_name == 'push' && github.ref == 'refs/heads/main'
78
+ run: |
79
+ mkdocs gh-deploy
vendor/a2ui/.github/workflows/editor_build.yml ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ name: Editor build
16
+
17
+ on:
18
+ push:
19
+ paths:
20
+ - 'tools/editor/**'
21
+ - 'renderers/lit/**'
22
+ - '.github/workflows/editor_build.yml'
23
+ pull_request:
24
+ paths:
25
+ - 'tools/editor/**'
26
+ - 'renderers/lit/**'
27
+ - '.github/workflows/editor_build.yml'
28
+
29
+ jobs:
30
+ build:
31
+ runs-on: ubuntu-latest
32
+
33
+ steps:
34
+ - uses: actions/checkout@v4
35
+
36
+ - name: Set up Node.js
37
+ uses: actions/setup-node@v4
38
+ with:
39
+ node-version: '20'
40
+
41
+ - name: Install lib's deps
42
+ working-directory: ./renderers/lit
43
+ run: npm ci
44
+
45
+ - name: Build lib
46
+ working-directory: ./renderers/lit
47
+ run: npm run build
48
+
49
+ - name: Install editor deps
50
+ working-directory: ./tools/editor
51
+ run: npm install
52
+
53
+ - name: Build editor
54
+ working-directory: ./tools/editor
55
+ run: npm run build
vendor/a2ui/.github/workflows/inspector_build.yml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ name: Inspector build
16
+
17
+ on:
18
+ push:
19
+ branches: [ main ]
20
+ paths:
21
+ - 'tools/inspector/**'
22
+ - 'renderers/lit/**'
23
+ - '.github/workflows/inspector_build.yml'
24
+ pull_request:
25
+ paths:
26
+ - 'tools/inspector/**'
27
+ - 'renderers/lit/**'
28
+ - '.github/workflows/inspector_build.yml'
29
+
30
+ jobs:
31
+ build:
32
+ runs-on: ubuntu-latest
33
+
34
+ steps:
35
+ - uses: actions/checkout@v4
36
+
37
+ - name: Set up Node.js
38
+ uses: actions/setup-node@v4
39
+ with:
40
+ node-version: '20'
41
+
42
+ - name: Install lib's deps
43
+ working-directory: ./renderers/lit
44
+ run: npm ci
45
+
46
+ - name: Build lib
47
+ working-directory: ./renderers/lit
48
+ run: npm run build
49
+
50
+ - name: Install inspector deps
51
+ working-directory: ./tools/inspector
52
+ run: npm install
53
+
54
+ - name: Build inspector
55
+ working-directory: ./tools/inspector
56
+ run: npm run build
vendor/a2ui/.github/workflows/java_build_and_test.yml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ name: Java sample build and test
16
+
17
+ on:
18
+ push:
19
+ branches:
20
+ - main
21
+ paths:
22
+ - 'a2a_agents/java/**'
23
+ pull_request:
24
+ paths:
25
+ - 'a2a_agents/java/**'
26
+
27
+ jobs:
28
+ build-and-test:
29
+ name: Build and test Java agent sample
30
+ runs-on: ubuntu-latest
31
+
32
+ steps:
33
+ - name: Checkout repository
34
+ uses: actions/checkout@v3
35
+
36
+ - name: Set up JDK
37
+ uses: actions/setup-java@v3
38
+ with:
39
+ java-version: '21'
40
+ distribution: 'temurin'
41
+
42
+ - name: Build with Maven
43
+ working-directory: a2a_agents/java
44
+ run: mvn clean install
45
+
46
+ - name: Run Tests
47
+ working-directory: a2a_agents/java
48
+ run: mvn test
vendor/a2ui/.github/workflows/lit_samples_build.yml ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ name: Lit samples build
16
+
17
+ on:
18
+ push:
19
+ branches: [ main ]
20
+ paths-ignore:
21
+ - 'samples/agent/adk/**'
22
+ pull_request:
23
+ paths-ignore:
24
+ - 'samples/agent/adk/**'
25
+
26
+ jobs:
27
+ build:
28
+ runs-on: ubuntu-latest
29
+
30
+ steps:
31
+ - uses: actions/checkout@v4
32
+
33
+ - name: Set up Node.js
34
+ uses: actions/setup-node@v4
35
+ with:
36
+ node-version: '20'
37
+
38
+ - name: Install lib's deps
39
+ working-directory: ./renderers/lit
40
+ run: npm i
41
+
42
+ - name: Build lib
43
+ working-directory: ./renderers/lit
44
+ run: npm run build
45
+
46
+ - name: Install all lit samples workspaces' dependencies
47
+ working-directory: ./samples/client/lit
48
+ run: npm install --workspaces
49
+
50
+ - name: Build all lit samples workspaces
51
+ working-directory: ./samples/client/lit
52
+ run: npm run build --workspaces
53
+
54
+
vendor/a2ui/.github/workflows/ng_build_and_test.yml ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ name: Angular build and test
16
+
17
+ on:
18
+ push:
19
+ branches: [ main ]
20
+ paths-ignore:
21
+ - 'samples/agent/adk/**'
22
+ pull_request:
23
+ paths-ignore:
24
+ - 'samples/agent/adk/**'
25
+
26
+ jobs:
27
+ build-and-test:
28
+ runs-on: ubuntu-latest
29
+
30
+ steps:
31
+ - uses: actions/checkout@v4
32
+
33
+ - name: Set up Node.js
34
+ uses: actions/setup-node@v4
35
+ with:
36
+ node-version: '20'
37
+
38
+ - name: Install web lib deps
39
+ working-directory: ./renderers/lit
40
+ run: npm i
41
+
42
+ - name: Build web lib
43
+ working-directory: ./renderers/lit
44
+ run: npm run build
45
+
46
+ - name: Install renderer deps
47
+ working-directory: ./renderers/angular
48
+ run: npm i
49
+
50
+ - name: Build Angular renderer
51
+ working-directory: ./renderers/angular
52
+ run: npm run build
53
+
54
+ - name: Install top-level deps
55
+ working-directory: ./samples/client/angular
56
+ run: npm i
57
+
58
+ - name: Build contact sample
59
+ working-directory: ./samples/client/angular
60
+ run: npm run build contact
61
+
62
+ - name: Build restaurant sample
63
+ working-directory: ./samples/client/angular
64
+ run: npm run build restaurant
65
+
66
+ - name: Build Rizzchart sample
67
+ working-directory: ./samples/client/angular
68
+ run: npm run build rizzcharts
69
+
70
+ - name: Build Orchestrator
71
+ working-directory: ./samples/client/angular
72
+ run: npm run build orchestrator
vendor/a2ui/.github/workflows/python_samples_build.yml ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ name: Build python samples
16
+
17
+ on:
18
+ push:
19
+ branches:
20
+ - main
21
+ paths:
22
+ - 'samples/agent/adk/**'
23
+ - 'a2a_agents/python/a2ui_extension/**'
24
+ pull_request:
25
+ paths:
26
+ - 'samples/agent/adk/**'
27
+ - 'a2a_agents/python/a2ui_extension/**'
28
+
29
+ jobs:
30
+ build:
31
+ name: Build samples
32
+ runs-on: ubuntu-latest
33
+
34
+ steps:
35
+ - name: Checkout repository
36
+ uses: actions/checkout@v3
37
+
38
+ - name: Set up Python
39
+ uses: actions/setup-python@v4
40
+ with:
41
+ python-version: '3.x'
42
+
43
+ - name: Install `uv` globally
44
+ run: |
45
+ python -m pip install --upgrade pip
46
+ pip install uv
47
+
48
+ - name: Build contact_lookup
49
+ working-directory: samples/agent/adk/contact_lookup
50
+ run: uv build .
51
+
52
+ - name: Build orchestrator
53
+ working-directory: samples/agent/adk/orchestrator
54
+ run: uv build .
55
+
56
+ - name: Build restaurant_finder
57
+ working-directory: samples/agent/adk/restaurant_finder
58
+ run: uv build .
59
+
60
+ - name: Build rizzcharts
61
+ working-directory: samples/agent/adk/rizzcharts
62
+ run: uv build .
vendor/a2ui/.github/workflows/web_build_and_test.yml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ name: Lit renderer build and test
16
+
17
+ on:
18
+ push:
19
+ branches: [ main ]
20
+ paths:
21
+ - 'renderers/lit/**'
22
+ - '.github/workflows/web_build_and_test.yml'
23
+ pull_request:
24
+ paths:
25
+ - 'renderers/lit/**'
26
+ - '.github/workflows/web_build_and_test.yml'
27
+
28
+ jobs:
29
+ build-and-test:
30
+ runs-on: ubuntu-latest
31
+
32
+ steps:
33
+ - uses: actions/checkout@v4
34
+
35
+ - name: Set up Node.js
36
+ uses: actions/setup-node@v4
37
+ with:
38
+ node-version: '20'
39
+
40
+ - name: Install Lit renderer dependencies
41
+ working-directory: ./renderers/lit
42
+ run: npm i
43
+
44
+ - name: Build Lit renderer
45
+ working-directory: ./renderers/lit
46
+ run: npm run build
47
+
48
+ - name: Run Lit renderer tests
49
+ working-directory: ./renderers/lit
50
+ run: npm test
vendor/a2ui/.gitignore ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ node_modules
2
+ .DS_Store
3
+ .wireit
4
+ dist
5
+ .env
6
+ .idx
7
+ .vscode
8
+ __pycache__
9
+ *.pyc
10
+ .angular
11
+
12
+ # MkDocs build output
13
+ site/
14
+
15
+ # Python virtual environment
16
+ .venv/
vendor/a2ui/CONTRIBUTING.md ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # How to contribute to A2UI
2
+
3
+ We'd love to accept your patches and contributions to this project.
4
+
5
+ ## Before you begin
6
+
7
+ ### Sign our Contributor License Agreement
8
+
9
+ Contributions to this project must be accompanied by a
10
+ [Contributor License Agreement](https://cla.developers.google.com/about) (CLA).
11
+ You (or your employer) retain the copyright to your contribution; this simply
12
+ gives us permission to use and redistribute your contributions as part of the
13
+ project.
14
+
15
+ If you or your current employer have already signed the Google CLA (even if it
16
+ was for a different project), you probably don't need to do it again.
17
+
18
+ Visit <https://cla.developers.google.com/> to see your current agreements or to
19
+ sign a new one.
20
+
21
+ ### Review our community guidelines
22
+
23
+ This project follows
24
+ [Google's Open Source Community Guidelines](https://opensource.google/conduct/).
25
+
26
+ ## Contribution process
27
+
28
+ ### Code reviews
29
+
30
+ All submissions, including submissions by project members, require review. We
31
+ use GitHub pull requests for this purpose. Consult
32
+ [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
33
+ information on using pull requests.
34
+
35
+ ### Contributor Guide
36
+
37
+ You may follow these steps to contribute:
38
+
39
+ 1. **Fork the official repository.** This will create a copy of the official repository in your own account.
40
+ 2. **Sync the branches.** This will ensure that your copy of the repository is up-to-date with the latest changes from the official repository.
41
+ 3. **Work on your forked repository's feature branch.** This is where you will make your changes to the code.
42
+ 4. **Commit your updates on your forked repository's feature branch.** This will save your changes to your copy of the repository.
43
+ 5. **Submit a pull request to the official repository's main branch.** This will request that your changes be merged into the official repository.
44
+ 6. **Resolve any linting errors.** This will ensure that your changes are formatted correctly.
45
+
46
+ Here are some additional things to keep in mind during the process:
47
+
48
+ - **Test your changes.** Before you submit a pull request, make sure that your changes work as expected.
49
+ - **Be patient.** It may take some time for your pull request to be reviewed and merged.
vendor/a2ui/LICENSE ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://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
+ http://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
+
vendor/a2ui/README.md ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # A2UI: Agent-to-User Interface
2
+
3
+ A2UI is an open-source project, complete with a format
4
+ optimized for representing updateable agent-generated
5
+ UIs and an initial set of renderers, that allows agents
6
+ to generate or populate rich user interfaces.
7
+
8
+ <img src="docs/assets/a2ui_gallery_examples.png" alt="Gallery of A2UI components" height="400">
9
+
10
+ *A gallery of A2UI rendered cards, showing a variety of UI compositions that A2UI can achieve.*
11
+
12
+ ## ⚠️ Status: Early Stage Public Preview
13
+
14
+ > **Note:** A2UI is currently in **v0.8 (Public Preview)**. The specification and
15
+ implementations are functional but are still evolving. We are opening the project to
16
+ foster collaboration, gather feedback, and solicit contributions (e.g., on client renderers).
17
+ Expect changes.
18
+
19
+ ## Summary
20
+
21
+ Generative AI excels at creating text and code, but agents can struggle to
22
+ present rich, interactive interfaces to users, especially when those agents
23
+ are remote or running across trust boundaries.
24
+
25
+ **A2UI** is an open standard and set of libraries that allows agents to
26
+ "speak UI." Agents send a declarative JSON format describing the *intent* of
27
+ the UI. The client application then renders this using its own native
28
+ component library (Flutter, Angular, Lit, etc.).
29
+
30
+ This approach ensures that agent-generated UIs are
31
+ **safe like data, but expressive like code**.
32
+
33
+ ## High-Level Philosophy
34
+
35
+ A2UI was designed to address the specific challenges of interoperable,
36
+ cross-platform, generative or template-based UI responses from agents.
37
+
38
+ The project's core philosophies:
39
+
40
+ * **Security first**: Running arbitrary code generated by an LLM may present a
41
+ security risk. A2UI is a declarative data format, not executable
42
+ code. Your client application maintains a "catalog" of trusted, pre-approved
43
+ UI components (e.g., Card, Button, TextField), and the agent can only request
44
+ to render components from that catalog.
45
+ * **LLM-friendly and incrementally updateable**: The UI is represented as a flat
46
+ list of components with ID references which is easy for LLMs to generate
47
+ incrementally, allowing for progressive rendering and a responsive user
48
+ experience. An agent can efficiently make incremental changes to the UI based
49
+ on new user requests as the conversation progresses.
50
+ * **Framework-agnostic and portable**: A2UI separates the UI structure from
51
+ the UI implementation. The agent sends a description of the component tree
52
+ and its associated data model. Your client application is responsible for
53
+ mapping these abstract descriptions to its native widgets—be it web components,
54
+ Flutter widgets, React components, SwiftUI views or something else entirely.
55
+ The same A2UI JSON payload from an agent can be rendered on multiple different
56
+ clients built on top of different frameworks.
57
+ * **Flexibility**: A2UI also features an open registry pattern that allows
58
+ developers to map server-side types to custom client implementations, from
59
+ native mobile widgets to React components. By registering a "Smart Wrapper,"
60
+ you can connect any existing UI component—including secure iframe containers
61
+ for legacy content—to A2UI's data binding and event system. Crucially, this
62
+ places security firmly in the developer's hands, enabling them to enforce
63
+ strict sandboxing policies and "trust ladders" directly within their custom
64
+ component logic rather than relying solely on the core system.
65
+
66
+ ## Use Cases
67
+
68
+ Some of the use cases include:
69
+
70
+ * **Dynamic Data Collection:** An agent generates a bespoke form (date pickers,
71
+ sliders, inputs) based on the specific context of a conversation (e.g.,
72
+ booking a specialized reservation).
73
+ * **Remote Sub-Agents:** An orchestrator agent delegates a task to a
74
+ remote specialized agent (e.g., a travel booking agent) which returns a
75
+ UI payload to be rendered inside the main chat window.
76
+ * **Adaptive Workflows:** Enterprise agents that generate approval
77
+ dashboards or data visualizations on the fly based on the user's query.
78
+
79
+ ## Architecture
80
+
81
+ The A2UI flow disconnects the generation of UI from the execution of UI:
82
+
83
+ 1. **Generation:** An Agent (using Gemini or another LLM) generates or uses
84
+ a pre-generated `A2UI Response`, a JSON payload describing the composition
85
+ of UI components and their properties.
86
+ 2. **Transport:** This message is sent to the client application
87
+ (via A2A, AG UI, etc.).
88
+ 3. **Resolution:** The Client's **A2UI Renderer** parses the JSON.
89
+ 4. **Rendering:** The Renderer maps the abstract components
90
+ (e.g., `type: 'text-field'`) to the concrete implementation in the client's codebase.
91
+
92
+ ## Dependencies
93
+
94
+ A2UI is designed to be a lightweight format, but it fits into a larger ecosystem:
95
+
96
+ * **Transports:** Compatible with **A2A Protocol** and **AG UI**.
97
+ * **LLMs:** Can be generated by any model capable of generating JSON output.
98
+ * **Host Frameworks:** Requires a host application built in a supported framework
99
+ (currently: Web or Flutter).
100
+
101
+ ## Getting Started
102
+
103
+ The best way to understand A2UI is to run the samples.
104
+
105
+ ### Prerequisites
106
+
107
+ * Node.js (for web clients)
108
+ * Python (for agent samples)
109
+ * A valid [Gemini API Key](https://aistudio.google.com/) is required for the samples.
110
+
111
+ ### Running the Restaurant Finder Demo
112
+
113
+ 1. **Clone the repository:**
114
+
115
+ ```bash
116
+ git clone https://github.com/google/A2UI.git
117
+ cd A2UI
118
+ ```
119
+
120
+ 2. **Set your API Key:**
121
+
122
+ ```bash
123
+ export GEMINI_API_KEY="your_gemini_api_key"
124
+ ```
125
+
126
+ 3. **Run the Agent (Backend):**
127
+
128
+ ```bash
129
+ cd samples/agent/adk/restaurant_finder
130
+ uv run .
131
+ ```
132
+
133
+ 4. **Run the Client (Frontend):**
134
+ Open a new terminal window:
135
+
136
+ ```bash
137
+ cd samples/client/lit/shell
138
+ npm install
139
+ npm run dev
140
+ ```
141
+
142
+ For Flutter developers, check out the [GenUI SDK](https://github.com/flutter/genui),
143
+ which uses A2UI under the hood.
144
+
145
+ CopilotKit has a public [A2UI Widget Builder](https://go.copilotkit.ai/A2UI-widget-builder)
146
+ to try out as well.
147
+
148
+ ## Roadmap
149
+
150
+ We hope to work with the community on the following:
151
+
152
+ * **Spec Stabilization:** Moving towards a v1.0 specification.
153
+ * **More Renderers:** Adding official support for React, Jetpack Compose, iOS (SwiftUI), and more.
154
+ * **Additional Transports:** Support for REST and more.
155
+ * **Additional Agent Frameworks:** Genkit, LangGraph, and more.
156
+
157
+ ## Contribute
158
+
159
+ A2UI is an **Apache 2.0** licensed project. We believe the future of UI is agentic,
160
+ and we want to work with you to help build it.
161
+
162
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to get started.
vendor/a2ui/mkdocs.yaml ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ site_name: A2UI
16
+ site_url: https://a2ui.org/
17
+ site_description: A2UI, a streaming protocol for Agent-Driven User Interfaces
18
+ site_author: Google
19
+ site_dir: site
20
+
21
+ extra:
22
+ analytics:
23
+ provider: google
24
+ property: G-YX9TPV8DCC
25
+ consent:
26
+ title: Cookie consent
27
+ description: >-
28
+ We use cookies to recognize repeated visits and preferences,
29
+ as well as to measure the effectiveness of our documentation and
30
+ whether users find the information they need. With your consent,
31
+ you're helping us to make our documentation better.
32
+
33
+ # Navigation
34
+ nav:
35
+ - Home: index.md
36
+ - Introduction & FAQ:
37
+ - What is A2UI?: introduction/what-is-a2ui.md
38
+ - Who is it For?: introduction/who-is-it-for.md
39
+ - How Can I Use It?: introduction/how-to-use.md
40
+ - Where is it Used?: introduction/where-is-it-used.md
41
+ - Agent UI Ecosystem: introduction/agent-ui-ecosystem.md
42
+ - Quickstart: quickstart.md
43
+ - A2UI Composer ⭐: composer.md
44
+ - Developer Guides:
45
+ - Client Setup: guides/client-setup.md
46
+ - Agent Development: guides/agent-development.md
47
+ - Custom Components: guides/custom-components.md
48
+ - Theming & Styling: guides/theming.md
49
+ - Core Concepts:
50
+ - Overview: concepts/overview.md
51
+ - Data Flow: concepts/data-flow.md
52
+ - Components & Structure: concepts/components.md
53
+ - Data Binding: concepts/data-binding.md
54
+ - Specifications:
55
+ - v0.8 (Stable):
56
+ - A2UI Specification: specification/v0.8-a2ui.md
57
+ - A2A Extension: specification/v0.8-a2a-extension.md
58
+ - v0.9 (Draft):
59
+ - A2UI Specification: specification/v0.9-a2ui.md
60
+ - Evolution Guide: specification/v0.9-evolution-guide.md
61
+ - Renderers (Clients): renderers.md
62
+ - Transports (Message Passing): transports.md
63
+ - Agents (Server-side): agents.md
64
+ - Community: community.md
65
+ - Roadmap: roadmap.md
66
+ - Reference:
67
+ - Component Reference: reference/components.md
68
+ - Message Reference: reference/messages.md
69
+
70
+ # Repository
71
+ repo_name: google/A2UI
72
+ repo_url: https://github.com/google/A2UI
73
+
74
+ # Copyright
75
+ copyright: Copyright Google 2025&nbsp;&nbsp;|&nbsp;&nbsp;<a href="//policies.google.com/terms">Terms</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="//policies.google.com/privacy">Privacy</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="#__consent">Manage cookies</a>
76
+
77
+ # Custom CSS
78
+ extra_css:
79
+ - stylesheets/custom.css
80
+
81
+
82
+ # Configuration
83
+ theme:
84
+ name: material
85
+ font:
86
+ text: Google Sans
87
+ code: Roboto Mono
88
+ logo: assets/A2UI_light.svg
89
+ favicon: assets/A2UI_dark.svg
90
+ icon:
91
+ repo: fontawesome/brands/github
92
+ # view: material/pencil-box-multiple
93
+ admonition:
94
+ note: fontawesome/solid/note-sticky
95
+ abstract: fontawesome/solid/book
96
+ info: fontawesome/solid/circle-info
97
+ tip: fontawesome/solid/bullhorn
98
+ success: fontawesome/solid/check
99
+ question: fontawesome/solid/circle-question
100
+ warning: fontawesome/solid/triangle-exclamation
101
+ failure: fontawesome/solid/bomb
102
+ danger: fontawesome/solid/skull
103
+ bug: fontawesome/solid/robot
104
+ example: fontawesome/solid/flask
105
+ quote: fontawesome/solid/quote-left
106
+ palette:
107
+ - scheme: default
108
+ primary: teal
109
+ accent: light blue
110
+ toggle:
111
+ icon: material/brightness-7
112
+ name: Switch to dark mode
113
+
114
+ - scheme: slate
115
+ primary: teal
116
+ accent: light blue
117
+ toggle:
118
+ icon: material/brightness-4
119
+ name: Switch to light mode
120
+
121
+ features:
122
+ - announce.dismiss
123
+ - content.action.view
124
+ - content.code.annotate
125
+ - content.code.copy
126
+ - content.code.select
127
+ - content.tabs.link
128
+ - navigation.footer
129
+ - navigation.indexes
130
+ - navigation.instant
131
+ - navigation.instant.progress
132
+ - navigation.path
133
+ - navigation.top
134
+ - navigation.tracking
135
+ - toc.follow
136
+
137
+ # Extensions
138
+ markdown_extensions:
139
+ - meta
140
+ - footnotes
141
+ - admonition
142
+ - attr_list
143
+ - md_in_html
144
+ - pymdownx.details
145
+ - pymdownx.emoji:
146
+ emoji_index: !!python/name:material.extensions.emoji.twemoji
147
+ emoji_generator: !!python/name:material.extensions.emoji.to_svg
148
+ - pymdownx.highlight:
149
+ anchor_linenums: true
150
+ line_spans: __span
151
+ pygments_lang_class: true
152
+ - pymdownx.inlinehilite
153
+ - pymdownx.snippets:
154
+ url_download: true
155
+ dedent_subsections: true
156
+ - pymdownx.superfences:
157
+ custom_fences:
158
+ - name: mermaid
159
+ class: mermaid
160
+ format: !!python/name:mermaid2.fence_mermaid
161
+ - pymdownx.tabbed:
162
+ alternate_style: true
163
+ slugify: !!python/object/apply:pymdownx.slugs.slugify
164
+ kwds:
165
+ case: lower
166
+ - pymdownx.tasklist:
167
+ custom_checkbox: true
168
+ - toc:
169
+ permalink: true
170
+
171
+ # Plugins
172
+ plugins:
173
+ - search
174
+ - macros
175
+ # - include-markdown
176
+ # - mermaid2
177
+ # - llmstxt:
178
+ # full_output: llms-full.txt
179
+ # sections:
180
+ # "Specification":
181
+ # - a2ui_protocol.md
182
+ # - redirects:
183
+ # redirect_maps:
184
+ # "index.md": "a2ui_protocol.md"
vendor/a2ui/renderers/angular/.npmrc ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ @a2ui:registry=https://us-npm.pkg.dev/oss-exit-gate-prod/a2ui--npm/
2
+ //us-npm.pkg.dev/oss-exit-gate-prod/a2ui--npm/:always-auth=true
vendor/a2ui/renderers/angular/README.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ Angular implementation of A2UI.
2
+
3
+ Important: The sample code provided is for demonstration purposes and illustrates the mechanics of A2UI and the Agent-to-Agent (A2A) protocol. When building production applications, it is critical to treat any agent operating outside of your direct control as a potentially untrusted entity.
4
+
5
+ All operational data received from an external agent—including its AgentCard, messages, artifacts, and task statuses—should be handled as untrusted input. For example, a malicious agent could provide crafted data in its fields (e.g., name, skills.description) that, if used without sanitization to construct prompts for a Large Language Model (LLM), could expose your application to prompt injection attacks.
6
+
7
+ Similarly, any UI definition or data stream received must be treated as untrusted. Malicious agents could attempt to spoof legitimate interfaces to deceive users (phishing), inject malicious scripts via property values (XSS), or generate excessive layout complexity to degrade client performance (DoS). If your application supports optional embedded content (such as iframes or web views), additional care must be taken to prevent exposure to malicious external sites.
8
+
9
+ Developer Responsibility: Failure to properly validate data and strictly sandbox rendered content can introduce severe vulnerabilities. Developers are responsible for implementing appropriate security measures—such as input sanitization, Content Security Policies (CSP), strict isolation for optional embedded content, and secure credential handling—to protect their systems and users.
vendor/a2ui/renderers/angular/angular.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3
+ "version": 1,
4
+ "projects": {
5
+ "lib": {
6
+ "projectType": "library",
7
+ "root": ".",
8
+ "sourceRoot": "./src",
9
+ "prefix": "lib",
10
+ "architect": {
11
+ "build": {
12
+ "builder": "@angular/build:ng-packagr",
13
+ "configurations": {
14
+ "production": {
15
+ "tsConfig": "./tsconfig.lib.prod.json"
16
+ },
17
+ "development": {
18
+ "tsConfig": "./tsconfig.lib.json"
19
+ }
20
+ },
21
+ "defaultConfiguration": "production"
22
+ },
23
+ "test": {
24
+ "builder": "@angular/build:karma",
25
+ "options": {
26
+ "tsConfig": "./tsconfig.spec.json"
27
+ }
28
+ }
29
+ }
30
+ }
31
+ },
32
+ "cli": {
33
+ "analytics": false
34
+ }
35
+ }
vendor/a2ui/renderers/angular/ng-package.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "./dist",
4
+ "lib": {
5
+ "entryFile": "src/public-api.ts"
6
+ },
7
+ "allowedNonPeerDependencies": ["markdown-it", "@a2ui/lit"]
8
+ }
vendor/a2ui/renderers/angular/package-lock.json ADDED
The diff for this file is too large to render. See raw diff
 
vendor/a2ui/renderers/angular/package.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@a2ui/angular",
3
+ "version": "0.8.1",
4
+ "scripts": {
5
+ "build": "ng build"
6
+ },
7
+ "dependencies": {
8
+ "@a2ui/lit": "file:../lit",
9
+ "markdown-it": "^14.1.0",
10
+ "tslib": "^2.3.0"
11
+ },
12
+ "peerDependencies": {
13
+ "@angular/common": "^21.0.0",
14
+ "@angular/core": "^21.0.0",
15
+ "@angular/platform-browser": "^21.0.0"
16
+ },
17
+ "devDependencies": {
18
+ "@angular/build": "^21.0.2",
19
+ "@angular/cli": "^21.0.2",
20
+ "@angular/compiler": "^21.0.0",
21
+ "@angular/compiler-cli": "^21.0.3",
22
+ "@angular/core": "^21.0.0",
23
+ "@types/express": "^5.0.1",
24
+ "@types/jasmine": "~5.1.0",
25
+ "@types/markdown-it": "^14.1.2",
26
+ "@types/node": "^20.17.19",
27
+ "@types/uuid": "^10.0.0",
28
+ "@vitest/browser": "^4.0.15",
29
+ "cypress": "^15.6.0",
30
+ "google-artifactregistry-auth": "^3.5.0",
31
+ "jasmine-core": "~5.9.0",
32
+ "jsdom": "^27.2.0",
33
+ "karma": "^6.4.4",
34
+ "karma-chrome-launcher": "^3.2.0",
35
+ "karma-coverage": "^2.2.1",
36
+ "karma-jasmine": "^5.1.0",
37
+ "karma-jasmine-html-reporter": "^2.1.0",
38
+ "ng-packagr": "^21.0.0",
39
+ "playwright": "^1.56.1",
40
+ "prettier": "^3.6.2",
41
+ "sass": "^1.93.2",
42
+ "tslib": "^2.8.1",
43
+ "typescript": "~5.9.2",
44
+ "vitest": "^4.0.15"
45
+ },
46
+ "sideEffects": false,
47
+ "prettier": {
48
+ "printWidth": 100,
49
+ "singleQuote": true,
50
+ "overrides": [
51
+ {
52
+ "files": "*.html",
53
+ "options": {
54
+ "parser": "angular"
55
+ }
56
+ }
57
+ ]
58
+ }
59
+ }
vendor/a2ui/renderers/angular/src/lib/catalog/audio.ts ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { Component, computed, input } from '@angular/core';
18
+ import { DynamicComponent } from '../rendering/dynamic-component';
19
+ import { Primitives } from '@a2ui/lit/0.8';
20
+
21
+ @Component({
22
+ selector: 'a2ui-audio',
23
+ template: `
24
+ @let resolvedUrl = this.resolvedUrl();
25
+
26
+ @if (resolvedUrl) {
27
+ <section [class]="theme.components.AudioPlayer" [style]="theme.additionalStyles?.AudioPlayer">
28
+ <audio controls [src]="resolvedUrl"></audio>
29
+ </section>
30
+ }
31
+ `,
32
+ styles: `
33
+ :host {
34
+ display: block;
35
+ flex: var(--weight);
36
+ min-height: 0;
37
+ overflow: auto;
38
+ }
39
+
40
+ audio {
41
+ display: block;
42
+ width: 100%;
43
+ box-sizing: border-box;
44
+ }
45
+ `
46
+ })
47
+ export class Audio extends DynamicComponent {
48
+ readonly url = input.required<Primitives.StringValue | null>();
49
+ protected readonly resolvedUrl = computed(() => this.resolvePrimitive(this.url()));
50
+ }
vendor/a2ui/renderers/angular/src/lib/catalog/button.ts ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { Component, input } from '@angular/core';
18
+ import { Types } from '@a2ui/lit/0.8';
19
+ import { DynamicComponent } from '../rendering/dynamic-component';
20
+ import { Renderer } from '../rendering/renderer';
21
+
22
+ @Component({
23
+ selector: 'a2ui-button',
24
+ imports: [Renderer],
25
+ template: `
26
+ <button
27
+ [class]="theme.components.Button"
28
+ [style]="theme.additionalStyles?.Button"
29
+ (click)="handleClick()"
30
+ >
31
+ <ng-container
32
+ a2ui-renderer
33
+ [surfaceId]="surfaceId()!"
34
+ [component]="component().properties.child"
35
+ />
36
+ </button>
37
+ `,
38
+ styles: `
39
+ :host {
40
+ display: block;
41
+ flex: var(--weight);
42
+ min-height: 0;
43
+ }
44
+ `,
45
+ })
46
+ export class Button extends DynamicComponent<Types.ButtonNode> {
47
+ readonly action = input.required<Types.Action | null>();
48
+
49
+ protected handleClick() {
50
+ const action = this.action();
51
+
52
+ if (action) {
53
+ super.sendAction(action);
54
+ }
55
+ }
56
+ }
vendor/a2ui/renderers/angular/src/lib/catalog/card.ts ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { Component, ViewEncapsulation } from '@angular/core';
18
+ import { DynamicComponent } from '../rendering/dynamic-component';
19
+ import { Renderer } from '../rendering/renderer';
20
+ import { Types } from '@a2ui/lit/0.8';
21
+
22
+ @Component({
23
+ selector: 'a2ui-card',
24
+ imports: [Renderer],
25
+ encapsulation: ViewEncapsulation.None,
26
+ styles: `
27
+ a2ui-card {
28
+ display: block;
29
+ flex: var(--weight);
30
+ min-height: 0;
31
+ overflow: auto;
32
+ }
33
+
34
+ a2ui-card > section {
35
+ height: 100%;
36
+ width: 100%;
37
+ min-height: 0;
38
+ overflow: auto;
39
+ }
40
+
41
+ a2ui-card > section > * {
42
+ height: 100%;
43
+ width: 100%;
44
+ }
45
+ `,
46
+ template: `
47
+ @let properties = component().properties;
48
+ @let children = properties.children || [properties.child];
49
+
50
+ <section [class]="theme.components.Card" [style]="theme.additionalStyles?.Card">
51
+ @for (child of children; track child) {
52
+ <ng-container a2ui-renderer [surfaceId]="surfaceId()!" [component]="child" />
53
+ }
54
+ </section>
55
+ `,
56
+ })
57
+ export class Card extends DynamicComponent<Types.CardNode> { }
vendor/a2ui/renderers/angular/src/lib/catalog/checkbox.ts ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { Component, computed, input } from '@angular/core';
18
+ import { DynamicComponent } from '../rendering/dynamic-component';
19
+ import { Primitives } from '@a2ui/lit/0.8';
20
+
21
+ @Component({
22
+ selector: 'a2ui-checkbox',
23
+ template: `
24
+ <section
25
+ [class]="theme.components.CheckBox.container"
26
+ [style]="theme.additionalStyles?.CheckBox"
27
+ >
28
+ <input
29
+ autocomplete="off"
30
+ type="checkbox"
31
+ [id]="inputId"
32
+ [checked]="inputChecked()"
33
+ [class]="theme.components.CheckBox.element"
34
+ (change)="handleChange($event)"
35
+ />
36
+
37
+ <label [htmlFor]="inputId" [class]="theme.components.CheckBox.label">{{
38
+ resolvedLabel()
39
+ }}</label>
40
+ </section>
41
+ `,
42
+ styles: `
43
+ :host {
44
+ display: block;
45
+ flex: var(--weight);
46
+ min-height: 0;
47
+ overflow: auto;
48
+ }
49
+
50
+ input {
51
+ display: block;
52
+ width: 100%;
53
+ }
54
+ `,
55
+ })
56
+ export class Checkbox extends DynamicComponent {
57
+ readonly value = input.required<Primitives.BooleanValue | null>();
58
+ readonly label = input.required<Primitives.StringValue | null>();
59
+
60
+ protected inputChecked = computed(() => super.resolvePrimitive(this.value()) ?? false);
61
+ protected resolvedLabel = computed(() => super.resolvePrimitive(this.label()));
62
+ protected inputId = super.getUniqueId('a2ui-checkbox');
63
+
64
+ protected handleChange(event: Event) {
65
+ const path = this.value()?.path;
66
+
67
+ if (!(event.target instanceof HTMLInputElement) || !path) {
68
+ return;
69
+ }
70
+
71
+ this.processor.setData(this.component(), path, event.target.checked, this.surfaceId());
72
+ }
73
+ }
vendor/a2ui/renderers/angular/src/lib/catalog/column.ts ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { Component, computed, input } from '@angular/core';
18
+ import { Types } from '@a2ui/lit/0.8';
19
+ import { DynamicComponent } from '../rendering/dynamic-component';
20
+ import { Renderer } from '../rendering/renderer';
21
+
22
+ @Component({
23
+ selector: 'a2ui-column',
24
+ imports: [Renderer],
25
+ styles: `
26
+ :host {
27
+ display: flex;
28
+ flex: var(--weight);
29
+ }
30
+
31
+ section {
32
+ display: flex;
33
+ flex-direction: column;
34
+ min-width: 100%;
35
+ height: 100%;
36
+ box-sizing: border-box;
37
+ }
38
+
39
+ .align-start {
40
+ align-items: start;
41
+ }
42
+
43
+ .align-center {
44
+ align-items: center;
45
+ }
46
+
47
+ .align-end {
48
+ align-items: end;
49
+ }
50
+
51
+ .align-stretch {
52
+ align-items: stretch;
53
+ }
54
+
55
+ .distribute-start {
56
+ justify-content: start;
57
+ }
58
+
59
+ .distribute-center {
60
+ justify-content: center;
61
+ }
62
+
63
+ .distribute-end {
64
+ justify-content: end;
65
+ }
66
+
67
+ .distribute-spaceBetween {
68
+ justify-content: space-between;
69
+ }
70
+
71
+ .distribute-spaceAround {
72
+ justify-content: space-around;
73
+ }
74
+
75
+ .distribute-spaceEvenly {
76
+ justify-content: space-evenly;
77
+ }
78
+ `,
79
+ template: `
80
+ <section [class]="classes()" [style]="theme.additionalStyles?.Column">
81
+ @for (child of component().properties.children; track child) {
82
+ <ng-container a2ui-renderer [surfaceId]="surfaceId()!" [component]="child" />
83
+ }
84
+ </section>
85
+ `,
86
+ })
87
+ export class Column extends DynamicComponent<Types.ColumnNode> {
88
+ readonly alignment = input<Types.ResolvedColumn['alignment']>('stretch');
89
+ readonly distribution = input<Types.ResolvedColumn['distribution']>('start');
90
+
91
+ protected readonly classes = computed(() => ({
92
+ ...this.theme.components.Column,
93
+ [`align-${this.alignment()}`]: true,
94
+ [`distribute-${this.distribution()}`]: true,
95
+ }));
96
+ }
vendor/a2ui/renderers/angular/src/lib/catalog/datetime-input.ts ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { computed, Component, input } from '@angular/core';
18
+ import { DynamicComponent } from '../rendering/dynamic-component';
19
+ import { Primitives } from '@a2ui/lit/0.8';
20
+
21
+ @Component({
22
+ selector: 'a2ui-datetime-input',
23
+ template: `
24
+ <section [class]="theme.components.DateTimeInput.container">
25
+ <label [for]="inputId" [class]="theme.components.DateTimeInput.label">{{ label() }}</label>
26
+
27
+ <input
28
+ autocomplete="off"
29
+ [attr.type]="inputType()"
30
+ [id]="inputId"
31
+ [class]="theme.components.DateTimeInput.element"
32
+ [style]="theme.additionalStyles?.DateTimeInput"
33
+ [value]="inputValue()"
34
+ (input)="handleInput($event)"
35
+ />
36
+ </section>
37
+ `,
38
+ styles: `
39
+ :host {
40
+ display: block;
41
+ flex: var(--weight);
42
+ min-height: 0;
43
+ overflow: auto;
44
+ }
45
+
46
+ input {
47
+ display: block;
48
+ width: 100%;
49
+ box-sizing: border-box;
50
+ }
51
+ `,
52
+ })
53
+ export class DatetimeInput extends DynamicComponent {
54
+ readonly value = input.required<Primitives.StringValue | null>();
55
+ readonly enableDate = input.required<boolean>();
56
+ readonly enableTime = input.required<boolean>();
57
+ protected readonly inputId = super.getUniqueId('a2ui-datetime-input');
58
+
59
+ protected inputType = computed(() => {
60
+ const enableDate = this.enableDate();
61
+ const enableTime = this.enableTime();
62
+
63
+ if (enableDate && enableTime) {
64
+ return 'datetime-local';
65
+ } else if (enableDate) {
66
+ return 'date';
67
+ } else if (enableTime) {
68
+ return 'time';
69
+ }
70
+
71
+ return 'datetime-local';
72
+ });
73
+
74
+ protected label = computed(() => {
75
+ // TODO: this should likely be passed from the model.
76
+ const inputType = this.inputType();
77
+
78
+ if (inputType === 'date') {
79
+ return 'Date';
80
+ } else if (inputType === 'time') {
81
+ return 'Time';
82
+ }
83
+
84
+ return 'Date & Time';
85
+ });
86
+
87
+ protected inputValue = computed(() => {
88
+ const inputType = this.inputType();
89
+ const parsed = super.resolvePrimitive(this.value()) || '';
90
+ const date = parsed ? new Date(parsed) : null;
91
+
92
+ if (!date || isNaN(date.getTime())) {
93
+ return '';
94
+ }
95
+
96
+ const year = this.padNumber(date.getFullYear());
97
+ const month = this.padNumber(date.getMonth());
98
+ const day = this.padNumber(date.getDate());
99
+ const hours = this.padNumber(date.getHours());
100
+ const minutes = this.padNumber(date.getMinutes());
101
+
102
+ // Browsers are picky with what format they allow for the `value` attribute of date/time inputs.
103
+ // We need to parse it out of the provided value. Note that we don't use `toISOString`,
104
+ // because the resulting value is relative to UTC.
105
+ if (inputType === 'date') {
106
+ return `${year}-${month}-${day}`;
107
+ } else if (inputType === 'time') {
108
+ return `${hours}:${minutes}`;
109
+ }
110
+
111
+ return `${year}-${month}-${day}T${hours}:${minutes}`;
112
+ });
113
+
114
+ protected handleInput(event: Event) {
115
+ const path = this.value()?.path;
116
+
117
+ if (!(event.target instanceof HTMLInputElement) || !path) {
118
+ return;
119
+ }
120
+
121
+ this.processor.setData(this.component(), path, event.target.value, this.surfaceId());
122
+ }
123
+
124
+ private padNumber(value: number) {
125
+ return value.toString().padStart(2, '0');
126
+ }
127
+ }
vendor/a2ui/renderers/angular/src/lib/catalog/default.ts ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { inputBinding } from '@angular/core';
18
+ import { Types } from '@a2ui/lit/0.8';
19
+ import { Catalog } from '../rendering/catalog';
20
+ import { Row } from './row';
21
+ import { Column } from './column';
22
+ import { Text } from './text';
23
+
24
+ export const DEFAULT_CATALOG: Catalog = {
25
+ Row: {
26
+ type: () => Row,
27
+ bindings: (node) => {
28
+ const properties = (node as Types.RowNode).properties;
29
+ return [
30
+ inputBinding('alignment', () => properties.alignment ?? 'stretch'),
31
+ inputBinding('distribution', () => properties.distribution ?? 'start'),
32
+ ];
33
+ },
34
+ },
35
+
36
+ Column: {
37
+ type: () => Column,
38
+ bindings: (node) => {
39
+ const properties = (node as Types.ColumnNode).properties;
40
+ return [
41
+ inputBinding('alignment', () => properties.alignment ?? 'stretch'),
42
+ inputBinding('distribution', () => properties.distribution ?? 'start'),
43
+ ];
44
+ },
45
+ },
46
+
47
+ List: {
48
+ type: () => import('./list').then((r) => r.List),
49
+ bindings: (node) => {
50
+ const properties = (node as Types.ListNode).properties;
51
+ return [inputBinding('direction', () => properties.direction ?? 'vertical')];
52
+ },
53
+ },
54
+
55
+ Card: () => import('./card').then((r) => r.Card),
56
+
57
+ Image: {
58
+ type: () => import('./image').then((r) => r.Image),
59
+ bindings: (node) => {
60
+ const properties = (node as Types.ImageNode).properties;
61
+ return [
62
+ inputBinding('url', () => properties.url),
63
+ inputBinding('usageHint', () => properties.usageHint),
64
+ ];
65
+ },
66
+ },
67
+
68
+ Icon: {
69
+ type: () => import('./icon').then((r) => r.Icon),
70
+ bindings: (node) => {
71
+ const properties = (node as Types.IconNode).properties;
72
+ return [inputBinding('name', () => properties.name)];
73
+ },
74
+ },
75
+
76
+ Video: {
77
+ type: () => import('./video').then((r) => r.Video),
78
+ bindings: (node) => {
79
+ const properties = (node as Types.VideoNode).properties;
80
+ return [inputBinding('url', () => properties.url)];
81
+ },
82
+ },
83
+
84
+ AudioPlayer: {
85
+ type: () => import('./audio').then((r) => r.Audio),
86
+ bindings: (node) => {
87
+ const properties = (node as Types.AudioPlayerNode).properties;
88
+ return [inputBinding('url', () => properties.url)];
89
+ },
90
+ },
91
+
92
+ Text: {
93
+ type: () => Text,
94
+ bindings: (node) => {
95
+ const properties = (node as Types.TextNode).properties;
96
+ return [
97
+ inputBinding('text', () => properties.text),
98
+ inputBinding('usageHint', () => properties.usageHint || null),
99
+ ];
100
+ },
101
+ },
102
+
103
+ Button: {
104
+ type: () => import('./button').then((r) => r.Button),
105
+ bindings: (node) => {
106
+ const properties = (node as Types.ButtonNode).properties;
107
+ return [inputBinding('action', () => properties.action)];
108
+ },
109
+ },
110
+
111
+ Divider: () => import('./divider').then((r) => r.Divider),
112
+
113
+ MultipleChoice: {
114
+ type: () => import('./multiple-choice').then((r) => r.MultipleChoice),
115
+ bindings: (node) => {
116
+ const properties = (node as Types.MultipleChoiceNode).properties;
117
+ return [
118
+ inputBinding('options', () => properties.options || []),
119
+ inputBinding('value', () => properties.selections),
120
+ inputBinding('description', () => 'Select an item'), // TODO: this should be defined in the properties
121
+ ];
122
+ },
123
+ },
124
+
125
+ TextField: {
126
+ type: () => import('./text-field').then((r) => r.TextField),
127
+ bindings: (node) => {
128
+ const properties = (node as Types.TextFieldNode).properties;
129
+ return [
130
+ inputBinding('text', () => properties.text ?? null),
131
+ inputBinding('label', () => properties.label),
132
+ inputBinding('inputType', () => properties.type),
133
+ ];
134
+ },
135
+ },
136
+
137
+ DateTimeInput: {
138
+ type: () => import('./datetime-input').then((r) => r.DatetimeInput),
139
+ bindings: (node) => {
140
+ const properties = (node as Types.DateTimeInputNode).properties;
141
+ return [
142
+ inputBinding('enableDate', () => properties.enableDate),
143
+ inputBinding('enableTime', () => properties.enableTime),
144
+ inputBinding('value', () => properties.value),
145
+ ];
146
+ },
147
+ },
148
+
149
+ CheckBox: {
150
+ type: () => import('./checkbox').then((r) => r.Checkbox),
151
+ bindings: (node) => {
152
+ const properties = (node as Types.CheckboxNode).properties;
153
+ return [
154
+ inputBinding('label', () => properties.label),
155
+ inputBinding('value', () => properties.value),
156
+ ];
157
+ },
158
+ },
159
+
160
+ Slider: {
161
+ type: () => import('./slider').then((r) => r.Slider),
162
+ bindings: (node) => {
163
+ const properties = (node as Types.SliderNode).properties;
164
+ return [
165
+ inputBinding('value', () => properties.value),
166
+ inputBinding('minValue', () => properties.minValue),
167
+ inputBinding('maxValue', () => properties.maxValue),
168
+ inputBinding('label', () => ''), // TODO: this should be defined in the properties
169
+ ];
170
+ },
171
+ },
172
+
173
+ Tabs: {
174
+ type: () => import('./tabs').then((r) => r.Tabs),
175
+ bindings: (node) => {
176
+ const properties = (node as Types.TabsNode).properties;
177
+ return [inputBinding('tabs', () => properties.tabItems)];
178
+ },
179
+ },
180
+
181
+ Modal: {
182
+ type: () => import('./modal').then((r) => r.Modal),
183
+ bindings: () => [],
184
+ },
185
+ };
vendor/a2ui/renderers/angular/src/lib/catalog/divider.ts ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { Component } from '@angular/core';
18
+ import { DynamicComponent } from '../rendering/dynamic-component';
19
+
20
+ @Component({
21
+ selector: 'a2ui-divider',
22
+ template: '<hr [class]="theme.components.Divider" [style]="theme.additionalStyles?.Divider"/>',
23
+ styles: `
24
+ :host {
25
+ display: block;
26
+ min-height: 0;
27
+ overflow: auto;
28
+ }
29
+
30
+ hr {
31
+ height: 1px;
32
+ background: #ccc;
33
+ border: none;
34
+ }
35
+ `,
36
+ })
37
+ export class Divider extends DynamicComponent {}
vendor/a2ui/renderers/angular/src/lib/catalog/icon.ts ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { Component, computed, input } from '@angular/core';
18
+ import { DynamicComponent } from '../rendering/dynamic-component';
19
+ import { Primitives } from '@a2ui/lit/0.8';
20
+
21
+ @Component({
22
+ selector: 'a2ui-icon',
23
+ styles: `
24
+ :host {
25
+ display: block;
26
+ flex: var(--weight);
27
+ min-height: 0;
28
+ overflow: auto;
29
+ }
30
+ `,
31
+ template: `
32
+ @let resolvedName = this.resolvedName();
33
+
34
+ @if (resolvedName) {
35
+ <section [class]="theme.components.Icon" [style]="theme.additionalStyles?.Icon">
36
+ <span class="g-icon">{{ resolvedName }}</span>
37
+ </section>
38
+ }
39
+ `,
40
+ })
41
+ export class Icon extends DynamicComponent {
42
+ readonly name = input.required<Primitives.StringValue | null>();
43
+ protected readonly resolvedName = computed(() => this.resolvePrimitive(this.name()));
44
+ }
vendor/a2ui/renderers/angular/src/lib/catalog/image.ts ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { Component, computed, input } from '@angular/core';
18
+ import { Primitives, Styles, Types } from '@a2ui/lit/0.8';
19
+ import { DynamicComponent } from '../rendering/dynamic-component';
20
+
21
+ @Component({
22
+ selector: 'a2ui-image',
23
+ styles: `
24
+ :host {
25
+ display: block;
26
+ flex: var(--weight);
27
+ min-height: 0;
28
+ overflow: auto;
29
+ }
30
+
31
+ img {
32
+ display: block;
33
+ width: 100%;
34
+ height: 100%;
35
+ box-sizing: border-box;
36
+ }
37
+ `,
38
+ template: `
39
+ @let resolvedUrl = this.resolvedUrl();
40
+
41
+ @if (resolvedUrl) {
42
+ <section [class]="classes()" [style]="theme.additionalStyles?.Image">
43
+ <img [src]="resolvedUrl" />
44
+ </section>
45
+ }
46
+ `,
47
+ })
48
+ export class Image extends DynamicComponent {
49
+ readonly url = input.required<Primitives.StringValue | null>();
50
+ readonly usageHint = input.required<Types.ResolvedImage['usageHint'] | null>();
51
+
52
+ protected readonly resolvedUrl = computed(() => this.resolvePrimitive(this.url()));
53
+
54
+ protected classes = computed(() => {
55
+ const usageHint = this.usageHint();
56
+
57
+ return Styles.merge(
58
+ this.theme.components.Image.all,
59
+ usageHint ? this.theme.components.Image[usageHint] : {},
60
+ );
61
+ });
62
+ }
vendor/a2ui/renderers/angular/src/lib/catalog/list.ts ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { Component, input } from '@angular/core';
18
+ import { Types } from '@a2ui/lit/0.8';
19
+ import { DynamicComponent } from '../rendering/dynamic-component';
20
+ import { Renderer } from '../rendering/renderer';
21
+
22
+ @Component({
23
+ selector: 'a2ui-list',
24
+ imports: [Renderer],
25
+ host: {
26
+ '[attr.direction]': 'direction()',
27
+ },
28
+ styles: `
29
+ :host {
30
+ display: block;
31
+ flex: var(--weight);
32
+ min-height: 0;
33
+ overflow: auto;
34
+ }
35
+
36
+ :host([direction='vertical']) section {
37
+ display: grid;
38
+ }
39
+
40
+ :host([direction='horizontal']) section {
41
+ display: flex;
42
+ max-width: 100%;
43
+ overflow-x: scroll;
44
+ overflow-y: hidden;
45
+ scrollbar-width: none;
46
+
47
+ > ::slotted(*) {
48
+ flex: 1 0 fit-content;
49
+ max-width: min(80%, 400px);
50
+ }
51
+ }
52
+ `,
53
+ template: `
54
+ <section [class]="theme.components.List" [style]="theme.additionalStyles?.List">
55
+ @for (child of component().properties.children; track child) {
56
+ <ng-container a2ui-renderer [surfaceId]="surfaceId()!" [component]="child" />
57
+ }
58
+ </section>
59
+ `,
60
+ })
61
+ export class List extends DynamicComponent<Types.ListNode> {
62
+ readonly direction = input<'vertical' | 'horizontal'>('vertical');
63
+ }
vendor/a2ui/renderers/angular/src/lib/catalog/modal.ts ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { Component, signal, viewChild, ElementRef, effect } from '@angular/core';
18
+ import { DynamicComponent } from '../rendering/dynamic-component';
19
+ import { Types } from '@a2ui/lit/0.8';
20
+ import { Renderer } from '../rendering';
21
+
22
+ @Component({
23
+ selector: 'a2ui-modal',
24
+ imports: [Renderer],
25
+ template: `
26
+ @if (showDialog()) {
27
+ <dialog #dialog [class]="theme.components.Modal.backdrop" (click)="handleDialogClick($event)">
28
+ <section [class]="theme.components.Modal.element" [style]="theme.additionalStyles?.Modal">
29
+ <div class="controls">
30
+ <button (click)="closeDialog()">
31
+ <span class="g-icon">close</span>
32
+ </button>
33
+ </div>
34
+
35
+ <ng-container
36
+ a2ui-renderer
37
+ [surfaceId]="surfaceId()!"
38
+ [component]="component().properties.contentChild"
39
+ />
40
+ </section>
41
+ </dialog>
42
+ } @else {
43
+ <section (click)="showDialog.set(true)">
44
+ <ng-container
45
+ a2ui-renderer
46
+ [surfaceId]="surfaceId()!"
47
+ [component]="component().properties.entryPointChild"
48
+ />
49
+ </section>
50
+ }
51
+ `,
52
+ styles: `
53
+ dialog {
54
+ padding: 0;
55
+ border: none;
56
+ background: none;
57
+
58
+ & section {
59
+ & .controls {
60
+ display: flex;
61
+ justify-content: end;
62
+ margin-bottom: 4px;
63
+
64
+ & button {
65
+ padding: 0;
66
+ background: none;
67
+ width: 20px;
68
+ height: 20px;
69
+ pointer: cursor;
70
+ border: none;
71
+ cursor: pointer;
72
+ }
73
+ }
74
+ }
75
+ }
76
+ `,
77
+ })
78
+ export class Modal extends DynamicComponent<Types.ModalNode> {
79
+ protected readonly showDialog = signal(false);
80
+ protected readonly dialog = viewChild<ElementRef<HTMLDialogElement>>('dialog');
81
+
82
+ constructor() {
83
+ super();
84
+
85
+ effect(() => {
86
+ const dialog = this.dialog();
87
+
88
+ if (dialog && !dialog.nativeElement.open) {
89
+ dialog.nativeElement.showModal();
90
+ }
91
+ });
92
+ }
93
+
94
+ protected handleDialogClick(event: MouseEvent) {
95
+ if (event.target instanceof HTMLDialogElement) {
96
+ this.closeDialog();
97
+ }
98
+ }
99
+
100
+ protected closeDialog() {
101
+ const dialog = this.dialog();
102
+
103
+ if (!dialog) {
104
+ return;
105
+ }
106
+
107
+ if (!dialog.nativeElement.open) {
108
+ dialog.nativeElement.close();
109
+ }
110
+
111
+ this.showDialog.set(false);
112
+ }
113
+ }
vendor/a2ui/renderers/angular/src/lib/catalog/multiple-choice.ts ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { Component, computed, input } from '@angular/core';
18
+ import { DynamicComponent } from '../rendering/dynamic-component';
19
+ import { Primitives } from '@a2ui/lit/0.8';
20
+
21
+ @Component({
22
+ selector: 'a2ui-multiple-choice',
23
+ template: `
24
+ <section [class]="theme.components.MultipleChoice.container">
25
+ <label [class]="theme.components.MultipleChoice.label" [for]="selectId">{{
26
+ description()
27
+ }}</label>
28
+
29
+ <select
30
+ (change)="handleChange($event)"
31
+ [id]="selectId"
32
+ [value]="selectValue()"
33
+ [class]="theme.components.MultipleChoice.element"
34
+ [style]="theme.additionalStyles?.MultipleChoice"
35
+ >
36
+ @for (option of options(); track option.value) {
37
+ <option [value]="option.value">{{ resolvePrimitive(option.label) }}</option>
38
+ }
39
+ </select>
40
+ </section>
41
+ `,
42
+ styles: `
43
+ :host {
44
+ display: block;
45
+ flex: var(--weight);
46
+ min-height: 0;
47
+ overflow: auto;
48
+ }
49
+
50
+ select {
51
+ width: 100%;
52
+ box-sizing: border-box;
53
+ }
54
+ `,
55
+ })
56
+ export class MultipleChoice extends DynamicComponent {
57
+ readonly options = input.required<{ label: Primitives.StringValue; value: string }[]>();
58
+ readonly value = input.required<Primitives.StringValue | null>();
59
+ readonly description = input.required<string>();
60
+
61
+ protected readonly selectId = super.getUniqueId('a2ui-multiple-choice');
62
+ protected selectValue = computed(() => super.resolvePrimitive(this.value()));
63
+
64
+ protected handleChange(event: Event) {
65
+ const path = this.value()?.path;
66
+
67
+ if (!(event.target instanceof HTMLSelectElement) || !event.target.value || !path) {
68
+ return;
69
+ }
70
+
71
+ this.processor.setData(
72
+ this.component(),
73
+ this.processor.resolvePath(path, this.component().dataContextPath),
74
+ event.target.value,
75
+ );
76
+ }
77
+ }
vendor/a2ui/renderers/angular/src/lib/catalog/row.ts ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { Component, computed, input } from '@angular/core';
18
+ import { DynamicComponent } from '../rendering/dynamic-component';
19
+ import { Renderer } from '../rendering/renderer';
20
+ import { Types } from '@a2ui/lit/0.8';
21
+
22
+ @Component({
23
+ selector: 'a2ui-row',
24
+ imports: [Renderer],
25
+ host: {
26
+ '[attr.alignment]': 'alignment()',
27
+ '[attr.distribution]': 'distribution()',
28
+ },
29
+ styles: `
30
+ :host {
31
+ display: flex;
32
+ flex: var(--weight);
33
+ }
34
+
35
+ section {
36
+ display: flex;
37
+ flex-direction: row;
38
+ width: 100%;
39
+ min-height: 100%;
40
+ box-sizing: border-box;
41
+ }
42
+
43
+ .align-start {
44
+ align-items: start;
45
+ }
46
+
47
+ .align-center {
48
+ align-items: center;
49
+ }
50
+
51
+ .align-end {
52
+ align-items: end;
53
+ }
54
+
55
+ .align-stretch {
56
+ align-items: stretch;
57
+ }
58
+
59
+ .distribute-start {
60
+ justify-content: start;
61
+ }
62
+
63
+ .distribute-center {
64
+ justify-content: center;
65
+ }
66
+
67
+ .distribute-end {
68
+ justify-content: end;
69
+ }
70
+
71
+ .distribute-spaceBetween {
72
+ justify-content: space-between;
73
+ }
74
+
75
+ .distribute-spaceAround {
76
+ justify-content: space-around;
77
+ }
78
+
79
+ .distribute-spaceEvenly {
80
+ justify-content: space-evenly;
81
+ }
82
+ `,
83
+ template: `
84
+ <section [class]="classes()" [style]="theme.additionalStyles?.Row">
85
+ @for (child of component().properties.children; track child) {
86
+ <ng-container a2ui-renderer [surfaceId]="surfaceId()!" [component]="child" />
87
+ }
88
+ </section>
89
+ `,
90
+ })
91
+ export class Row extends DynamicComponent<Types.RowNode> {
92
+ readonly alignment = input<Types.ResolvedRow['alignment']>('stretch');
93
+ readonly distribution = input<Types.ResolvedRow['distribution']>('start');
94
+
95
+ protected readonly classes = computed(() => ({
96
+ ...this.theme.components.Row,
97
+ [`align-${this.alignment()}`]: true,
98
+ [`distribute-${this.distribution()}`]: true,
99
+ }));
100
+ }
vendor/a2ui/renderers/angular/src/lib/catalog/slider.ts ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { Component, computed, input } from '@angular/core';
18
+ import { Primitives } from '@a2ui/lit/0.8';
19
+ import { DynamicComponent } from '../rendering/dynamic-component';
20
+
21
+ @Component({
22
+ selector: '[a2ui-slider]',
23
+ template: `
24
+ <section [class]="theme.components.Slider.container">
25
+ <label [class]="theme.components.Slider.label" [for]="inputId">
26
+ {{ label() }}
27
+ </label>
28
+
29
+ <input
30
+ autocomplete="off"
31
+ type="range"
32
+ [value]="resolvedValue()"
33
+ [min]="minValue()"
34
+ [max]="maxValue()"
35
+ [id]="inputId"
36
+ (input)="handleInput($event)"
37
+ [class]="theme.components.Slider.element"
38
+ [style]="theme.additionalStyles?.Slider"
39
+ />
40
+ </section>
41
+ `,
42
+ styles: `
43
+ :host {
44
+ display: block;
45
+ flex: var(--weight);
46
+ }
47
+
48
+ input {
49
+ display: block;
50
+ width: 100%;
51
+ box-sizing: border-box;
52
+ }
53
+ `,
54
+ })
55
+ export class Slider extends DynamicComponent {
56
+ readonly value = input.required<Primitives.NumberValue | null>();
57
+ readonly label = input('');
58
+ readonly minValue = input.required<number | undefined>();
59
+ readonly maxValue = input.required<number | undefined>();
60
+
61
+ protected readonly inputId = super.getUniqueId('a2ui-slider');
62
+ protected resolvedValue = computed(() => super.resolvePrimitive(this.value()) ?? 0);
63
+
64
+ protected handleInput(event: Event) {
65
+ const path = this.value()?.path;
66
+
67
+ if (!(event.target instanceof HTMLInputElement) || !path) {
68
+ return;
69
+ }
70
+
71
+ this.processor.setData(this.component(), path, event.target.valueAsNumber, this.surfaceId());
72
+ }
73
+ }
vendor/a2ui/renderers/angular/src/lib/catalog/surface.ts ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { Component, computed, input } from '@angular/core';
18
+ import { Types } from '@a2ui/lit/0.8';
19
+ import { Renderer } from '../rendering/renderer';
20
+
21
+ @Component({
22
+ selector: 'a2ui-surface',
23
+ imports: [Renderer],
24
+ template: `
25
+ @let surfaceId = this.surfaceId();
26
+ @let surface = this.surface();
27
+
28
+ @if (surfaceId && surface) {
29
+ <ng-container a2ui-renderer [surfaceId]="surfaceId" [component]="surface.componentTree!" />
30
+ }
31
+ `,
32
+ styles: `
33
+ :host {
34
+ display: flex;
35
+ min-height: 0;
36
+ max-height: 100%;
37
+ flex-direction: column;
38
+ gap: 16px;
39
+ }
40
+ `,
41
+ host: {
42
+ '[style]': 'styles()',
43
+ },
44
+ })
45
+ export class Surface {
46
+ readonly surfaceId = input.required<Types.SurfaceID | null>();
47
+ readonly surface = input.required<Types.Surface | null>();
48
+
49
+ protected readonly styles = computed(() => {
50
+ const surface = this.surface();
51
+ const styles: Record<string, string> = {};
52
+
53
+ if (surface?.styles) {
54
+ for (const [key, value] of Object.entries(surface.styles)) {
55
+ switch (key) {
56
+ // Here we generate a palette from the singular primary color received
57
+ // from the surface data. We will want the values to range from
58
+ // 0 <= x <= 100, where 0 = back, 100 = white, and 50 = the primary
59
+ // color itself. As such we use a color-mix to create the intermediate
60
+ // values.
61
+ //
62
+ // Note: since we use half the range for black to the primary color,
63
+ // and half the range for primary color to white the mixed values have
64
+ // to go up double the amount, i.e., a range from black to primary
65
+ // color needs to fit in 0 -> 50 rather than 0 -> 100.
66
+ case 'primaryColor': {
67
+ styles['--p-100'] = '#ffffff';
68
+ styles['--p-99'] = `color-mix(in srgb, ${value} 2%, white 98%)`;
69
+ styles['--p-98'] = `color-mix(in srgb, ${value} 4%, white 96%)`;
70
+ styles['--p-95'] = `color-mix(in srgb, ${value} 10%, white 90%)`;
71
+ styles['--p-90'] = `color-mix(in srgb, ${value} 20%, white 80%)`;
72
+ styles['--p-80'] = `color-mix(in srgb, ${value} 40%, white 60%)`;
73
+ styles['--p-70'] = `color-mix(in srgb, ${value} 60%, white 40%)`;
74
+ styles['--p-60'] = `color-mix(in srgb, ${value} 80%, white 20%)`;
75
+ styles['--p-50'] = value;
76
+ styles['--p-40'] = `color-mix(in srgb, ${value} 80%, black 20%)`;
77
+ styles['--p-35'] = `color-mix(in srgb, ${value} 70%, black 30%)`;
78
+ styles['--p-30'] = `color-mix(in srgb, ${value} 60%, black 40%)`;
79
+ styles['--p-25'] = `color-mix(in srgb, ${value} 50%, black 50%)`;
80
+ styles['--p-20'] = `color-mix(in srgb, ${value} 40%, black 60%)`;
81
+ styles['--p-15'] = `color-mix(in srgb, ${value} 30%, black 70%)`;
82
+ styles['--p-10'] = `color-mix(in srgb, ${value} 20%, black 80%)`;
83
+ styles['--p-5'] = `color-mix(in srgb, ${value} 10%, black 90%)`;
84
+ styles['--0'] = '#00000';
85
+ break;
86
+ }
87
+
88
+ case 'font': {
89
+ styles['--font-family'] = value;
90
+ styles['--font-family-flex'] = value;
91
+ break;
92
+ }
93
+ }
94
+ }
95
+ }
96
+
97
+ return styles;
98
+ });
99
+ }
vendor/a2ui/renderers/angular/src/lib/catalog/tabs.ts ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { Component, computed, input, signal } from '@angular/core';
18
+ import { DynamicComponent } from '../rendering/dynamic-component';
19
+ import { Renderer } from '../rendering/renderer';
20
+ import { Styles, Types } from '@a2ui/lit/0.8';
21
+
22
+ @Component({
23
+ selector: 'a2ui-tabs',
24
+ imports: [Renderer],
25
+ template: `
26
+ @let tabs = this.tabs();
27
+ @let selectedIndex = this.selectedIndex();
28
+
29
+ <section [class]="theme.components.Tabs.container" [style]="theme.additionalStyles?.Tabs">
30
+ <div [class]="theme.components.Tabs.element">
31
+ @for (tab of tabs; track tab) {
32
+ <button
33
+ (click)="this.selectedIndex.set($index)"
34
+ [disabled]="selectedIndex === $index"
35
+ [class]="buttonClasses()[selectedIndex]"
36
+ >
37
+ {{ resolvePrimitive(tab.title) }}
38
+ </button>
39
+ }
40
+ </div>
41
+
42
+ <ng-container
43
+ a2ui-renderer
44
+ [surfaceId]="surfaceId()!"
45
+ [component]="tabs[selectedIndex].child"
46
+ />
47
+ </section>
48
+ `,
49
+ styles: `
50
+ :host {
51
+ display: block;
52
+ flex: var(--weight);
53
+ }
54
+ `,
55
+ })
56
+ export class Tabs extends DynamicComponent {
57
+ protected selectedIndex = signal(0);
58
+ readonly tabs = input.required<Types.ResolvedTabItem[]>();
59
+
60
+ protected readonly buttonClasses = computed(() => {
61
+ const selectedIndex = this.selectedIndex();
62
+
63
+ return this.tabs().map((_, index) => {
64
+ return index === selectedIndex
65
+ ? Styles.merge(
66
+ this.theme.components.Tabs.controls.all,
67
+ this.theme.components.Tabs.controls.selected,
68
+ )
69
+ : this.theme.components.Tabs.controls.all;
70
+ });
71
+ });
72
+ }
vendor/a2ui/renderers/angular/src/lib/catalog/text-field.ts ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { computed, Component, input } from '@angular/core';
18
+ import { Primitives, Types } from '@a2ui/lit/0.8';
19
+ import { DynamicComponent } from '../rendering/dynamic-component';
20
+
21
+ @Component({
22
+ selector: 'a2ui-text-field',
23
+ styles: `
24
+ :host {
25
+ display: flex;
26
+ flex: var(--weight);
27
+ }
28
+
29
+ section,
30
+ input,
31
+ label {
32
+ box-sizing: border-box;
33
+ }
34
+
35
+ input {
36
+ display: block;
37
+ width: 100%;
38
+ }
39
+
40
+ label {
41
+ display: block;
42
+ margin-bottom: 4px;
43
+ }
44
+ `,
45
+ template: `
46
+ @let resolvedLabel = this.resolvedLabel();
47
+
48
+ <section [class]="theme.components.TextField.container">
49
+ @if (resolvedLabel) {
50
+ <label [for]="inputId" [class]="theme.components.TextField.label">{{
51
+ resolvedLabel
52
+ }}</label>
53
+ }
54
+
55
+ <input
56
+ autocomplete="off"
57
+ [class]="theme.components.TextField.element"
58
+ [style]="theme.additionalStyles?.TextField"
59
+ (input)="handleInput($event)"
60
+ [id]="inputId"
61
+ [value]="inputValue()"
62
+ placeholder="Please enter a value"
63
+ [type]="inputType() === 'number' ? 'number' : 'text'"
64
+ />
65
+ </section>
66
+ `,
67
+ })
68
+ export class TextField extends DynamicComponent {
69
+ readonly text = input.required<Primitives.StringValue | null>();
70
+ readonly label = input.required<Primitives.StringValue | null>();
71
+ readonly inputType = input.required<Types.ResolvedTextField['type'] | null>();
72
+
73
+ protected inputValue = computed(() => super.resolvePrimitive(this.text()) || '');
74
+ protected resolvedLabel = computed(() => super.resolvePrimitive(this.label()));
75
+ protected inputId = super.getUniqueId('a2ui-input');
76
+
77
+ protected handleInput(event: Event) {
78
+ const path = this.text()?.path;
79
+
80
+ if (!(event.target instanceof HTMLInputElement) || !path) {
81
+ return;
82
+ }
83
+
84
+ this.processor.setData(this.component(), path, event.target.value, this.surfaceId());
85
+ }
86
+ }
vendor/a2ui/renderers/angular/src/lib/catalog/text.ts ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { Component, computed, inject, input, ViewEncapsulation } from '@angular/core';
18
+ import { DynamicComponent } from '../rendering/dynamic-component';
19
+ import { Primitives, Styles, Types } from '@a2ui/lit/0.8';
20
+ import { MarkdownRenderer } from '../data/markdown';
21
+
22
+ interface HintedStyles {
23
+ h1: Record<string, string>;
24
+ h2: Record<string, string>;
25
+ h3: Record<string, string>;
26
+ h4: Record<string, string>;
27
+ h5: Record<string, string>;
28
+ body: Record<string, string>;
29
+ caption: Record<string, string>;
30
+ }
31
+
32
+ @Component({
33
+ selector: 'a2ui-text',
34
+ template: `
35
+ <section
36
+ [class]="classes()"
37
+ [style]="additionalStyles()"
38
+ [innerHTML]="resolvedText()"
39
+ ></section>
40
+ `,
41
+ encapsulation: ViewEncapsulation.None,
42
+ styles: `
43
+ a2ui-text {
44
+ display: block;
45
+ flex: var(--weight);
46
+ }
47
+
48
+ a2ui-text h1,
49
+ a2ui-text h2,
50
+ a2ui-text h3,
51
+ a2ui-text h4,
52
+ a2ui-text h5 {
53
+ line-height: inherit;
54
+ font: inherit;
55
+ }
56
+ `,
57
+ })
58
+ export class Text extends DynamicComponent {
59
+ private markdownRenderer = inject(MarkdownRenderer);
60
+ readonly text = input.required<Primitives.StringValue | null>();
61
+ readonly usageHint = input.required<Types.ResolvedText['usageHint'] | null>();
62
+
63
+ protected resolvedText = computed(() => {
64
+ const usageHint = this.usageHint();
65
+ let value = super.resolvePrimitive(this.text());
66
+
67
+ if (value == null) {
68
+ return '(empty)';
69
+ }
70
+
71
+ switch (usageHint) {
72
+ case 'h1':
73
+ value = `# ${value}`;
74
+ break;
75
+ case 'h2':
76
+ value = `## ${value}`;
77
+ break;
78
+ case 'h3':
79
+ value = `### ${value}`;
80
+ break;
81
+ case 'h4':
82
+ value = `#### ${value}`;
83
+ break;
84
+ case 'h5':
85
+ value = `##### ${value}`;
86
+ break;
87
+ case 'caption':
88
+ value = `*${value}*`;
89
+ break;
90
+ default:
91
+ value = String(value);
92
+ break;
93
+ }
94
+
95
+ return this.markdownRenderer.render(
96
+ value,
97
+ Styles.appendToAll(this.theme.markdown, ['ol', 'ul', 'li'], {}),
98
+ );
99
+ });
100
+
101
+ protected classes = computed(() => {
102
+ const usageHint = this.usageHint();
103
+
104
+ return Styles.merge(
105
+ this.theme.components.Text.all,
106
+ usageHint ? this.theme.components.Text[usageHint] : {},
107
+ );
108
+ });
109
+
110
+ protected additionalStyles = computed(() => {
111
+ const usageHint = this.usageHint();
112
+ const styles = this.theme.additionalStyles?.Text;
113
+
114
+ if (!styles) {
115
+ return null;
116
+ }
117
+
118
+ let additionalStyles: Record<string, string> = {};
119
+
120
+ if (this.areHintedStyles(styles)) {
121
+ additionalStyles = styles[usageHint ?? 'body'];
122
+ } else {
123
+ additionalStyles = styles;
124
+ }
125
+
126
+ return additionalStyles;
127
+ });
128
+
129
+ private areHintedStyles(styles: unknown): styles is HintedStyles {
130
+ if (typeof styles !== 'object' || !styles || Array.isArray(styles)) {
131
+ return false;
132
+ }
133
+
134
+ const expected = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'caption', 'body'];
135
+ return expected.every((v) => v in styles);
136
+ }
137
+ }
vendor/a2ui/renderers/angular/src/lib/catalog/video.ts ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { Component, computed, input } from '@angular/core';
18
+ import { DynamicComponent } from '../rendering/dynamic-component';
19
+ import { Primitives } from '@a2ui/lit/0.8';
20
+
21
+ @Component({
22
+ selector: 'a2ui-video',
23
+ template: `
24
+ @let resolvedUrl = this.resolvedUrl();
25
+
26
+ @if (resolvedUrl) {
27
+ <section [class]="theme.components.Video" [style]="theme.additionalStyles?.Video">
28
+ <video controls [src]="resolvedUrl"></video>
29
+ </section>
30
+ }
31
+ `,
32
+ styles: `
33
+ :host {
34
+ display: block;
35
+ flex: var(--weight);
36
+ min-height: 0;
37
+ overflow: auto;
38
+ }
39
+
40
+ video {
41
+ display: block;
42
+ width: 100%;
43
+ box-sizing: border-box;
44
+ }
45
+ `,
46
+ })
47
+ export class Video extends DynamicComponent {
48
+ readonly url = input.required<Primitives.StringValue | null>();
49
+ protected readonly resolvedUrl = computed(() => this.resolvePrimitive(this.url()));
50
+ }
vendor/a2ui/renderers/angular/src/lib/config.ts ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { EnvironmentProviders, makeEnvironmentProviders } from '@angular/core';
18
+ import { Catalog, Theme } from './rendering';
19
+
20
+ export function provideA2UI(config: { catalog: Catalog; theme: Theme }): EnvironmentProviders {
21
+ return makeEnvironmentProviders([
22
+ { provide: Catalog, useValue: config.catalog },
23
+ { provide: Theme, useValue: config.theme },
24
+ ]);
25
+ }
vendor/a2ui/renderers/angular/src/lib/data/index.ts ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ export * from './processor';
18
+ export * from './types';
vendor/a2ui/renderers/angular/src/lib/data/markdown.ts ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { inject, Injectable, SecurityContext } from '@angular/core';
18
+ import { DomSanitizer } from '@angular/platform-browser';
19
+ import MarkdownIt from 'markdown-it';
20
+
21
+ @Injectable({ providedIn: 'root' })
22
+ export class MarkdownRenderer {
23
+ private originalClassMap = new Map<string, any>();
24
+ private sanitizer = inject(DomSanitizer);
25
+
26
+ private markdownIt = MarkdownIt({
27
+ highlight: (str, lang) => {
28
+ if (lang === 'html') {
29
+ const iframe = document.createElement('iframe');
30
+ iframe.classList.add('html-view');
31
+ iframe.srcdoc = str;
32
+ iframe.sandbox = '';
33
+ return iframe.innerHTML;
34
+ }
35
+
36
+ return str;
37
+ },
38
+ });
39
+
40
+ render(value: string, tagClassMap?: Record<string, string[]>) {
41
+ if (tagClassMap) {
42
+ this.applyTagClassMap(tagClassMap);
43
+ }
44
+ const htmlString = this.markdownIt.render(value);
45
+ this.unapplyTagClassMap();
46
+ return this.sanitizer.sanitize(SecurityContext.HTML, htmlString);
47
+ }
48
+
49
+ private applyTagClassMap(tagClassMap: Record<string, string[]>) {
50
+ Object.entries(tagClassMap).forEach(([tag, classes]) => {
51
+ let tokenName;
52
+ switch (tag) {
53
+ case 'p':
54
+ tokenName = 'paragraph';
55
+ break;
56
+ case 'h1':
57
+ case 'h2':
58
+ case 'h3':
59
+ case 'h4':
60
+ case 'h5':
61
+ case 'h6':
62
+ tokenName = 'heading';
63
+ break;
64
+ case 'ul':
65
+ tokenName = 'bullet_list';
66
+ break;
67
+ case 'ol':
68
+ tokenName = 'ordered_list';
69
+ break;
70
+ case 'li':
71
+ tokenName = 'list_item';
72
+ break;
73
+ case 'a':
74
+ tokenName = 'link';
75
+ break;
76
+ case 'strong':
77
+ tokenName = 'strong';
78
+ break;
79
+ case 'em':
80
+ tokenName = 'em';
81
+ break;
82
+ }
83
+
84
+ if (!tokenName) {
85
+ return;
86
+ }
87
+
88
+ const key = `${tokenName}_open`;
89
+ const original = this.markdownIt.renderer.rules[key];
90
+ this.originalClassMap.set(key, original);
91
+
92
+ this.markdownIt.renderer.rules[key] = (tokens, idx, options, env, self) => {
93
+ const token = tokens[idx];
94
+ for (const clazz of classes) {
95
+ token.attrJoin('class', clazz);
96
+ }
97
+
98
+ if (original) {
99
+ return original.call(this, tokens, idx, options, env, self);
100
+ } else {
101
+ return self.renderToken(tokens, idx, options);
102
+ }
103
+ };
104
+ });
105
+ }
106
+
107
+ private unapplyTagClassMap() {
108
+ for (const [key, original] of this.originalClassMap) {
109
+ this.markdownIt.renderer.rules[key] = original;
110
+ }
111
+
112
+ this.originalClassMap.clear();
113
+ }
114
+ }
vendor/a2ui/renderers/angular/src/lib/data/processor.ts ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { Data, Types } from '@a2ui/lit/0.8';
18
+ import { Injectable } from '@angular/core';
19
+ import { firstValueFrom, Subject } from 'rxjs';
20
+
21
+ export interface DispatchedEvent {
22
+ message: Types.A2UIClientEventMessage;
23
+ completion: Subject<Types.ServerToClientMessage[]>;
24
+ }
25
+
26
+ @Injectable({ providedIn: 'root' })
27
+ export class MessageProcessor extends Data.A2uiMessageProcessor {
28
+ readonly events = new Subject<DispatchedEvent>();
29
+
30
+ override setData(
31
+ node: Types.AnyComponentNode,
32
+ relativePath: string,
33
+ value: Types.DataValue,
34
+ surfaceId?: Types.SurfaceID | null,
35
+ ) {
36
+ // Override setData to convert from optional inputs (which can be null)
37
+ // to undefined so that this correctly falls back to the default value for
38
+ // surfaceId.
39
+ return super.setData(node, relativePath, value, surfaceId ?? undefined);
40
+ }
41
+
42
+ dispatch(message: Types.A2UIClientEventMessage): Promise<Types.ServerToClientMessage[]> {
43
+ const completion = new Subject<Types.ServerToClientMessage[]>();
44
+ this.events.next({ message, completion });
45
+ return firstValueFrom(completion);
46
+ }
47
+ }
vendor/a2ui/renderers/angular/src/lib/data/types.ts ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { Types } from '@a2ui/lit/0.8';
18
+
19
+ export interface A2TextPayload {
20
+ kind: 'text';
21
+ text: string;
22
+ }
23
+
24
+ export interface A2DataPayload {
25
+ kind: 'data';
26
+ data: Types.ServerToClientMessage;
27
+ }
28
+
29
+ export type A2AServerPayload = Array<A2DataPayload | A2TextPayload> | { error: string };
vendor/a2ui/renderers/angular/src/lib/rendering/catalog.ts ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { Binding, InjectionToken, Type } from '@angular/core';
18
+ import { DynamicComponent } from './dynamic-component';
19
+ import { Types } from '@a2ui/lit/0.8';
20
+
21
+ export type CatalogLoader = () =>
22
+ | Promise<Type<DynamicComponent<any>>>
23
+ | Type<DynamicComponent<any>>;
24
+
25
+ export type CatalogEntry<T extends Types.AnyComponentNode> =
26
+ | CatalogLoader
27
+ | {
28
+ type: CatalogLoader;
29
+ bindings: (data: T) => Binding[];
30
+ };
31
+
32
+ export interface Catalog {
33
+ [key: string]: CatalogEntry<Types.AnyComponentNode>;
34
+ }
35
+
36
+ export const Catalog = new InjectionToken<Catalog>('Catalog');
vendor/a2ui/renderers/angular/src/lib/rendering/dynamic-component.ts ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { Types, Primitives } from '@a2ui/lit/0.8';
18
+ import { Directive, inject, input } from '@angular/core';
19
+ import { MessageProcessor } from '../data';
20
+ import { Theme } from './theming';
21
+
22
+ let idCounter = 0;
23
+
24
+ @Directive({
25
+ host: {
26
+ '[style.--weight]': 'weight()',
27
+ },
28
+ })
29
+ export abstract class DynamicComponent<T extends Types.AnyComponentNode = Types.AnyComponentNode> {
30
+ protected readonly processor = inject(MessageProcessor);
31
+ protected readonly theme = inject(Theme);
32
+
33
+ readonly surfaceId = input.required<Types.SurfaceID | null>();
34
+ readonly component = input.required<T>();
35
+ readonly weight = input.required<string | number>();
36
+
37
+ protected sendAction(action: Types.Action): Promise<Types.ServerToClientMessage[]> {
38
+ const component = this.component();
39
+ const surfaceId = this.surfaceId() ?? undefined;
40
+ const context: Record<string, unknown> = {};
41
+
42
+ if (action.context) {
43
+ for (const item of action.context) {
44
+ if (item.value.literalBoolean) {
45
+ context[item.key] = item.value.literalBoolean;
46
+ } else if (item.value.literalNumber) {
47
+ context[item.key] = item.value.literalNumber;
48
+ } else if (item.value.literalString) {
49
+ context[item.key] = item.value.literalString;
50
+ } else if (item.value.path) {
51
+ const path = this.processor.resolvePath(item.value.path, component.dataContextPath);
52
+ const value = this.processor.getData(component, path, surfaceId);
53
+ context[item.key] = value;
54
+ }
55
+ }
56
+ }
57
+
58
+ const message: Types.A2UIClientEventMessage = {
59
+ userAction: {
60
+ name: action.name,
61
+ sourceComponentId: component.id,
62
+ surfaceId: surfaceId!,
63
+ timestamp: new Date().toISOString(),
64
+ context,
65
+ },
66
+ };
67
+
68
+ return this.processor.dispatch(message);
69
+ }
70
+
71
+ protected resolvePrimitive(value: Primitives.StringValue | null): string | null;
72
+ protected resolvePrimitive(value: Primitives.BooleanValue | null): boolean | null;
73
+ protected resolvePrimitive(value: Primitives.NumberValue | null): number | null;
74
+ protected resolvePrimitive(
75
+ value: Primitives.StringValue | Primitives.BooleanValue | Primitives.NumberValue | null,
76
+ ) {
77
+ const component = this.component();
78
+ const surfaceId = this.surfaceId();
79
+
80
+ if (!value || typeof value !== 'object') {
81
+ return null;
82
+ } else if (value.literal != null) {
83
+ return value.literal;
84
+ } else if (value.path) {
85
+ return this.processor.getData(component, value.path, surfaceId ?? undefined);
86
+ } else if ('literalString' in value) {
87
+ return value.literalString;
88
+ } else if ('literalNumber' in value) {
89
+ return value.literalNumber;
90
+ } else if ('literalBoolean' in value) {
91
+ return value.literalBoolean;
92
+ }
93
+
94
+ return null;
95
+ }
96
+
97
+ protected getUniqueId(prefix: string) {
98
+ return `${prefix}-${idCounter++}`;
99
+ }
100
+ }
vendor/a2ui/renderers/angular/src/lib/rendering/index.ts ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ export * from './catalog';
18
+ export * from './dynamic-component';
19
+ export * from './renderer';
20
+ export * from './theming';
vendor/a2ui/renderers/angular/src/lib/rendering/renderer.ts ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import {
18
+ Binding,
19
+ ComponentRef,
20
+ Directive,
21
+ DOCUMENT,
22
+ effect,
23
+ inject,
24
+ input,
25
+ inputBinding,
26
+ OnDestroy,
27
+ PLATFORM_ID,
28
+ Type,
29
+ untracked,
30
+ ViewContainerRef,
31
+ } from '@angular/core';
32
+ import { Types, Styles } from '@a2ui/lit/0.8';
33
+ import { Catalog } from './catalog';
34
+ import { isPlatformBrowser } from '@angular/common';
35
+
36
+ @Directive({
37
+ selector: 'ng-container[a2ui-renderer]',
38
+ })
39
+ export class Renderer implements OnDestroy {
40
+ private viewContainerRef = inject(ViewContainerRef);
41
+ private catalog = inject(Catalog);
42
+ private static hasInsertedStyles = false;
43
+
44
+ private currentRef: ComponentRef<unknown> | null = null;
45
+ private isDestroyed = false;
46
+
47
+ readonly surfaceId = input.required<Types.SurfaceID>();
48
+ readonly component = input.required<Types.AnyComponentNode>();
49
+
50
+ constructor() {
51
+ effect(() => {
52
+ const surfaceId = this.surfaceId();
53
+ const component = this.component();
54
+ untracked(() => this.render(surfaceId, component));
55
+ });
56
+
57
+ const platformId = inject(PLATFORM_ID);
58
+ const document = inject(DOCUMENT);
59
+
60
+ if (!Renderer.hasInsertedStyles && isPlatformBrowser(platformId)) {
61
+ const styles = document.createElement('style');
62
+ styles.textContent = Styles.structuralStyles;
63
+ document.head.appendChild(styles);
64
+ Renderer.hasInsertedStyles = true;
65
+ }
66
+ }
67
+
68
+ ngOnDestroy(): void {
69
+ this.isDestroyed = true;
70
+ this.clear();
71
+ }
72
+
73
+ private async render(surfaceId: Types.SurfaceID, component: Types.AnyComponentNode) {
74
+ const config = this.catalog[component.type];
75
+ let newComponent: Type<unknown> | null = null;
76
+ let componentBindings: Binding[] | null = null;
77
+
78
+ if (typeof config === 'function') {
79
+ newComponent = await config();
80
+ } else if (typeof config === 'object') {
81
+ newComponent = await config.type();
82
+ componentBindings = config.bindings(component as any);
83
+ }
84
+
85
+ this.clear();
86
+
87
+ if (newComponent && !this.isDestroyed) {
88
+ const bindings = [
89
+ inputBinding('surfaceId', () => surfaceId),
90
+ inputBinding('component', () => component),
91
+ inputBinding('weight', () => component.weight ?? 'initial'),
92
+ ];
93
+
94
+ if (componentBindings) {
95
+ bindings.push(...componentBindings);
96
+ }
97
+
98
+ this.currentRef = this.viewContainerRef.createComponent(newComponent, {
99
+ bindings,
100
+ injector: this.viewContainerRef.injector,
101
+ });
102
+ }
103
+ }
104
+
105
+ private clear() {
106
+ this.currentRef?.destroy();
107
+ this.currentRef = null;
108
+ }
109
+ }
vendor/a2ui/renderers/angular/src/lib/rendering/theming.ts ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2025 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { Types } from '@a2ui/lit/0.8';
18
+ import { InjectionToken } from '@angular/core';
19
+
20
+ export const Theme = new InjectionToken<Theme>('Theme');
21
+
22
+ export type Theme = Types.Theme;