a2ui-core 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. a2ui_core-0.0.1/.gitignore +127 -0
  2. a2ui_core-0.0.1/PKG-INFO +105 -0
  3. a2ui_core-0.0.1/README.md +95 -0
  4. a2ui_core-0.0.1/pyproject.toml +42 -0
  5. a2ui_core-0.0.1/scripts/generate_schemas.py +875 -0
  6. a2ui_core-0.0.1/src/a2ui/core/basic_catalog/__init__.py +87 -0
  7. a2ui_core-0.0.1/src/a2ui/core/basic_catalog/components.py +486 -0
  8. a2ui_core-0.0.1/src/a2ui/core/basic_catalog/expression_parser.py +268 -0
  9. a2ui_core-0.0.1/src/a2ui/core/basic_catalog/function_apis.py +214 -0
  10. a2ui_core-0.0.1/src/a2ui/core/basic_catalog/function_impls.py +463 -0
  11. a2ui_core-0.0.1/src/a2ui/core/basic_catalog/locale_config.py +278 -0
  12. a2ui_core-0.0.1/src/a2ui/core/basic_catalog/operator_apis.py +143 -0
  13. a2ui_core-0.0.1/src/a2ui/core/basic_catalog/styles.py +39 -0
  14. a2ui_core-0.0.1/src/a2ui/core/catalog/__init__.py +37 -0
  15. a2ui_core-0.0.1/src/a2ui/core/catalog/catalog.py +232 -0
  16. a2ui_core-0.0.1/src/a2ui/core/catalog/components.py +78 -0
  17. a2ui_core-0.0.1/src/a2ui/core/catalog/functions.py +81 -0
  18. a2ui_core-0.0.1/src/a2ui/core/common/__init__.py +22 -0
  19. a2ui_core-0.0.1/src/a2ui/core/common/events.py +112 -0
  20. a2ui_core-0.0.1/src/a2ui/core/processing/__init__.py +19 -0
  21. a2ui_core-0.0.1/src/a2ui/core/processing/message_processor.py +232 -0
  22. a2ui_core-0.0.1/src/a2ui/core/rendering/__init__.py +24 -0
  23. a2ui_core-0.0.1/src/a2ui/core/rendering/component_context.py +68 -0
  24. a2ui_core-0.0.1/src/a2ui/core/rendering/data_context.py +344 -0
  25. a2ui_core-0.0.1/src/a2ui/core/rendering/generic_binder.py +174 -0
  26. a2ui_core-0.0.1/src/a2ui/core/schema/__init__.py +56 -0
  27. a2ui_core-0.0.1/src/a2ui/core/schema/client_capabilities.py +69 -0
  28. a2ui_core-0.0.1/src/a2ui/core/schema/client_to_server.py +106 -0
  29. a2ui_core-0.0.1/src/a2ui/core/schema/common_types.py +131 -0
  30. a2ui_core-0.0.1/src/a2ui/core/schema/constants.py +27 -0
  31. a2ui_core-0.0.1/src/a2ui/core/schema/server_to_client.py +109 -0
  32. a2ui_core-0.0.1/src/a2ui/core/state/__init__.py +32 -0
  33. a2ui_core-0.0.1/src/a2ui/core/state/component_model.py +53 -0
  34. a2ui_core-0.0.1/src/a2ui/core/state/component_node.py +60 -0
  35. a2ui_core-0.0.1/src/a2ui/core/state/data_model.py +175 -0
  36. a2ui_core-0.0.1/src/a2ui/core/state/surface_components_model.py +55 -0
  37. a2ui_core-0.0.1/src/a2ui/core/state/surface_group_model.py +70 -0
  38. a2ui_core-0.0.1/src/a2ui/core/state/surface_model.py +395 -0
  39. a2ui_core-0.0.1/src/a2ui/core/validating/__init__.py +33 -0
  40. a2ui_core-0.0.1/src/a2ui/core/validating/catalog_validator.py +434 -0
  41. a2ui_core-0.0.1/src/a2ui/core/validating/integrity_checker.py +149 -0
  42. a2ui_core-0.0.1/src/a2ui/core/validating/topology_analyzer.py +88 -0
  43. a2ui_core-0.0.1/src/a2ui/core/validating/validator.py +191 -0
  44. a2ui_core-0.0.1/tests/test_catalog.py +1010 -0
  45. a2ui_core-0.0.1/tests/test_components.py +250 -0
  46. a2ui_core-0.0.1/tests/test_expression_parser.py +108 -0
  47. a2ui_core-0.0.1/tests/test_functions.py +396 -0
  48. a2ui_core-0.0.1/tests/test_generate_schemas.py +517 -0
  49. a2ui_core-0.0.1/tests/test_processing.py +883 -0
  50. a2ui_core-0.0.1/tests/test_rendering.py +390 -0
  51. a2ui_core-0.0.1/tests/test_schema.py +133 -0
  52. a2ui_core-0.0.1/tests/test_state.py +937 -0
  53. a2ui_core-0.0.1/tests/test_validating.py +465 -0
  54. a2ui_core-0.0.1/tests/text_renderer.py +203 -0
  55. a2ui_core-0.0.1/uv.lock +392 -0
@@ -0,0 +1,127 @@
1
+ node_modules
2
+ .DS_Store
3
+ .wireit
4
+ dist
5
+ .env
6
+ .idx
7
+ .idea/
8
+ *.pyc
9
+ .angular/
10
+ *.tsbuildinfo
11
+
12
+ # MkDocs build output
13
+ site/
14
+
15
+ # Python virtual environment
16
+ .venv/
17
+ coverage/
18
+
19
+ # Generated spec assets in the agent SDK
20
+ ## old agent SDK path
21
+ a2a_agents/python/a2ui_agent/src/a2ui/assets/**/*.json
22
+ agent_sdks/python/src/a2ui/assets/**/*.json
23
+ ## new agent SDK path
24
+ agent_sdks/python/a2ui_agent/src/a2ui/assets/**/*.json
25
+ ## Generated files for sandbox frame.
26
+ samples/client/angular/projects/mcp_calculator/public/mcp_apps_inner_iframe/
27
+
28
+ # Yarn Modern
29
+ .yarn/*
30
+ !.yarn/patches
31
+ !.yarn/plugins
32
+ !.yarn/sdks
33
+ .yarn/cache
34
+
35
+ ## Generated files for a2ui-in-mcpapps
36
+ samples/mcp/a2ui-in-mcpapps/server/apps/dist
37
+ samples/mcp/a2ui-in-mcpapps/server/apps/public
38
+
39
+ # Vite cache
40
+ .vite/
41
+
42
+ # Git worktrees
43
+ worktrees/
44
+
45
+ # TypeScript incremental build info
46
+ *.tsbuildinfo
47
+
48
+ # Local-only scratch files.
49
+ .local/
50
+
51
+ # Diagrams, produced by https://pub.dev/packages/layerlens.
52
+ DEPS.md
53
+
54
+ # Firebase
55
+ google-services.json
56
+ **/lib/firebase_options.dart
57
+ firebase.json
58
+ GoogleService-Info.plist
59
+ .firebase
60
+ .firebaserc
61
+
62
+ # This package's specific logs.
63
+ *.log.*
64
+ *.log
65
+
66
+ # Python
67
+ __pycache__/
68
+ *.py[cod]
69
+ *$py.class
70
+ venv/
71
+ ENV/
72
+ build/
73
+ *.egg-info/
74
+ .pytest_cache/
75
+ .coverage
76
+ htmlcov/
77
+
78
+ # ==============================================================================
79
+ #
80
+ # STANDARD FLUTTER GITIGNORE
81
+ #
82
+ # ==============================================================================
83
+
84
+ # Miscellaneous
85
+ *.class
86
+ *.swp
87
+ .atom/
88
+ .build/
89
+ .buildlog/
90
+ .history
91
+ .svn/
92
+ .swiftpm/
93
+ migrate_working_dir/
94
+
95
+ # IntelliJ related
96
+ *.iml
97
+ *.ipr
98
+ *.iws
99
+
100
+ # Flutter/Dart/Pub related
101
+ **/doc/api/
102
+ **/ios/Flutter/.last_build_id
103
+ .dart_tool/
104
+ .flutter-plugins-dependencies
105
+ .pub-cache/
106
+ .pub/
107
+ /build/
108
+
109
+ # iOS/macOS generated files
110
+ **/ios/Runner/GeneratedPluginRegistrant.h
111
+ **/ios/Runner/GeneratedPluginRegistrant.m
112
+ **/ios/Runner/GeneratedPluginRegistrant.swift
113
+ **/macos/Flutter/GeneratedPluginRegistrant.swift
114
+
115
+ /coverage/
116
+ pubspec.lock
117
+
118
+ # Symbolication related
119
+ app.*.symbols
120
+
121
+ # Obfuscation related
122
+ app.*.map.json
123
+
124
+ # Android Studio will place build artifacts here
125
+ /android/app/debug
126
+ /android/app/profile
127
+ /android/app/release
@@ -0,0 +1,105 @@
1
+ Metadata-Version: 2.4
2
+ Name: a2ui-core
3
+ Version: 0.0.1
4
+ Summary: A2UI Python SDK - Core Library
5
+ Requires-Python: >=3.14
6
+ Requires-Dist: jsonschema>=4.26.0
7
+ Requires-Dist: pydantic>=2.10.0
8
+ Requires-Dist: referencing>=0.37.0
9
+ Description-Content-Type: text/markdown
10
+
11
+ # A2UI Core Library (`a2ui_core`)
12
+
13
+ `a2ui_core` is a framework-agnostic Python library containing the core data models, reactive state management, and JSON schema validation logic for the A2UI protocol (v0.9 and onwards).
14
+
15
+ It provides the logic-neutral, visual-agnostic layer used by python-based server agents, rendering backends, and conformance testing frameworks.
16
+
17
+ ## Features
18
+
19
+ - **Protocol Handling**: Symmetrical processing and validation of A2UI specification envelope messages (`CreateSurface`, `UpdateComponents`, `UpdateDataModel`, and `DeleteSurface`).
20
+ - **State Management**: Reactive state tracking driven by a high-performance custom `Signal` implementation and decoupled hierarchical models (`SurfaceGroupModel`, `SurfaceModel`, and `ComponentNode` layers).
21
+ - **DataContext**: Advanced data binding and function execution environment with support for dynamic path resolution and automatic dependency updates.
22
+ - **Catalog System**: Extensible catalog registry supporting compiled object models (`ModelCatalog`) and raw text-based schemas (`JsonCatalog`) for LLM prompt integration.
23
+ - **Validation & Integrity**: Strict validation engine combining **Pydantic** (compiled envelopes) and **JSON Schema Draft 2020-12** (dynamic catalogs) with advanced topological and integrity checks (cyclic layout detection, reachability analysis, orphan tracking, and recursive reference verification).
24
+
25
+ > [!IMPORTANT]
26
+ > **Specification Support**: The `a2ui_core` library strictly targets the **A2UI specification v0.9 and onwards**. Unlike client-side renderers that may support legacy v0.8 layouts for backward compatibility, this Python core library does not support legacy v0.8 protocol definitions.
27
+
28
+ ## Architecture
29
+
30
+ The `a2ui_core` architecture aligns symmetrically with the client-side `@a2ui/web_core` engine, allowing exact parity when evaluating state representations and resolving dynamic layout values.
31
+
32
+ ```mermaid
33
+ graph TD
34
+ MP[MessageProcessor] -->|Executes Messages| SGM[SurfaceGroupModel]
35
+ SGM -->|Manages active surfaces| SM[SurfaceModel]
36
+ SM -->|Dynamic Components| SCM[Components Model]
37
+ SM -->|State Context| DM[DataModel]
38
+ SCM --> GB[GenericBinder]
39
+ DM --> GB
40
+ GB -->|Re-resolves dynamic values| CN[ComponentNode<br/>Resolved Tree]
41
+ ```
42
+
43
+ ### Core Packages
44
+
45
+ #### 1. State Layer (`src/a2ui/core/state`)
46
+
47
+ - **`Signal`**: Thread-safe (where applicable) core reactive primitive. Allows components and rendering pipelines to subscribe to precise state increments.
48
+ - **`DataModel`**: Active state key-value dictionary path observer supporting reactive wildcard queries and path resolution.
49
+ - **`ComponentNode`**: Represents a live, reactively bound component instance in the final visual tree hierarchy. Automatically disposes of nested resources and subscriptions when unmounted.
50
+ - **`SurfaceModel`**: Orchestrates components and data model pipelines for a single viewport surface.
51
+ - **`SurfaceGroupModel`**: Manages a collection of active client rendering surfaces.
52
+
53
+ #### 2. Rendering Engine (`src/a2ui/core/rendering`)
54
+
55
+ - **`DataContext`**: Coordinates lexical scopes, resolves data paths (e.g., `/some/data`), and handles dynamic expressions.
56
+ - **`GenericBinder`**: Subscribes to relevant data path models and binds component properties dynamically.
57
+ - **`ComponentContext`**: Connects standard component models with their target `DataContext` execution environments.
58
+
59
+ #### 3. Message Processing (`src/a2ui/core/processing`)
60
+
61
+ - **`MessageProcessor`**: A stateless protocol processor. Translates raw incoming A2UI messages into structural mutations across the `SurfaceGroupModel` layer.
62
+
63
+ #### 4. Catalogs (`src/a2ui/core/catalog`)
64
+
65
+ - **`JsonCatalog`**: Loads raw JSON schemas directly, compiling schema-validated references dynamically for prompt injection.
66
+ - **`ModelCatalog`**: Compiles catalog rules based on structured Pydantic or standard object class configurations.
67
+
68
+ #### 5. Basic Catalog (`src/a2ui/core/basic_catalog`)
69
+
70
+ - **Basic Component Models**: Symmetrical declarations of core out-of-the-box components (`TextComponent`, `ButtonComponent`, `CardComponent`, etc.) conforming directly to standard schema configurations.
71
+ - **`BasicCatalog`**: Factory provider initializing standard schemas and layout parameters.
72
+
73
+ #### 6. Symmetrical Schemas (`src/a2ui/core/schema`)
74
+
75
+ - **Pydantic Message Wrappers**: Compiled Pydantic models representing `A2uiMessage`, envelopes, and capabilities configuration structures.
76
+ - **`constants`**: Spec constants defining default reachability links and single/list component reference parameters.
77
+
78
+ ## Development & Testing
79
+
80
+ We use [uv](https://github.com/astral-sh/uv) for extremely fast and reliable environment management and task execution.
81
+
82
+ ### Setup Environment
83
+
84
+ To synchronize the virtual environment and dependencies, run the following from the `agent_sdks/python` directory:
85
+
86
+ ```bash
87
+ uv sync
88
+ ```
89
+
90
+ ### Running Tests
91
+
92
+ Run all unit, conformance, and structural integrity test suites:
93
+
94
+ ```bash
95
+ # From the package directory (agent_sdks/python/a2ui_core)
96
+ uv run pytest
97
+ ```
98
+
99
+ ### Code Formatting
100
+
101
+ Format and lint source files before committing changes:
102
+
103
+ ```bash
104
+ uv run pyink .
105
+ ```
@@ -0,0 +1,95 @@
1
+ # A2UI Core Library (`a2ui_core`)
2
+
3
+ `a2ui_core` is a framework-agnostic Python library containing the core data models, reactive state management, and JSON schema validation logic for the A2UI protocol (v0.9 and onwards).
4
+
5
+ It provides the logic-neutral, visual-agnostic layer used by python-based server agents, rendering backends, and conformance testing frameworks.
6
+
7
+ ## Features
8
+
9
+ - **Protocol Handling**: Symmetrical processing and validation of A2UI specification envelope messages (`CreateSurface`, `UpdateComponents`, `UpdateDataModel`, and `DeleteSurface`).
10
+ - **State Management**: Reactive state tracking driven by a high-performance custom `Signal` implementation and decoupled hierarchical models (`SurfaceGroupModel`, `SurfaceModel`, and `ComponentNode` layers).
11
+ - **DataContext**: Advanced data binding and function execution environment with support for dynamic path resolution and automatic dependency updates.
12
+ - **Catalog System**: Extensible catalog registry supporting compiled object models (`ModelCatalog`) and raw text-based schemas (`JsonCatalog`) for LLM prompt integration.
13
+ - **Validation & Integrity**: Strict validation engine combining **Pydantic** (compiled envelopes) and **JSON Schema Draft 2020-12** (dynamic catalogs) with advanced topological and integrity checks (cyclic layout detection, reachability analysis, orphan tracking, and recursive reference verification).
14
+
15
+ > [!IMPORTANT]
16
+ > **Specification Support**: The `a2ui_core` library strictly targets the **A2UI specification v0.9 and onwards**. Unlike client-side renderers that may support legacy v0.8 layouts for backward compatibility, this Python core library does not support legacy v0.8 protocol definitions.
17
+
18
+ ## Architecture
19
+
20
+ The `a2ui_core` architecture aligns symmetrically with the client-side `@a2ui/web_core` engine, allowing exact parity when evaluating state representations and resolving dynamic layout values.
21
+
22
+ ```mermaid
23
+ graph TD
24
+ MP[MessageProcessor] -->|Executes Messages| SGM[SurfaceGroupModel]
25
+ SGM -->|Manages active surfaces| SM[SurfaceModel]
26
+ SM -->|Dynamic Components| SCM[Components Model]
27
+ SM -->|State Context| DM[DataModel]
28
+ SCM --> GB[GenericBinder]
29
+ DM --> GB
30
+ GB -->|Re-resolves dynamic values| CN[ComponentNode<br/>Resolved Tree]
31
+ ```
32
+
33
+ ### Core Packages
34
+
35
+ #### 1. State Layer (`src/a2ui/core/state`)
36
+
37
+ - **`Signal`**: Thread-safe (where applicable) core reactive primitive. Allows components and rendering pipelines to subscribe to precise state increments.
38
+ - **`DataModel`**: Active state key-value dictionary path observer supporting reactive wildcard queries and path resolution.
39
+ - **`ComponentNode`**: Represents a live, reactively bound component instance in the final visual tree hierarchy. Automatically disposes of nested resources and subscriptions when unmounted.
40
+ - **`SurfaceModel`**: Orchestrates components and data model pipelines for a single viewport surface.
41
+ - **`SurfaceGroupModel`**: Manages a collection of active client rendering surfaces.
42
+
43
+ #### 2. Rendering Engine (`src/a2ui/core/rendering`)
44
+
45
+ - **`DataContext`**: Coordinates lexical scopes, resolves data paths (e.g., `/some/data`), and handles dynamic expressions.
46
+ - **`GenericBinder`**: Subscribes to relevant data path models and binds component properties dynamically.
47
+ - **`ComponentContext`**: Connects standard component models with their target `DataContext` execution environments.
48
+
49
+ #### 3. Message Processing (`src/a2ui/core/processing`)
50
+
51
+ - **`MessageProcessor`**: A stateless protocol processor. Translates raw incoming A2UI messages into structural mutations across the `SurfaceGroupModel` layer.
52
+
53
+ #### 4. Catalogs (`src/a2ui/core/catalog`)
54
+
55
+ - **`JsonCatalog`**: Loads raw JSON schemas directly, compiling schema-validated references dynamically for prompt injection.
56
+ - **`ModelCatalog`**: Compiles catalog rules based on structured Pydantic or standard object class configurations.
57
+
58
+ #### 5. Basic Catalog (`src/a2ui/core/basic_catalog`)
59
+
60
+ - **Basic Component Models**: Symmetrical declarations of core out-of-the-box components (`TextComponent`, `ButtonComponent`, `CardComponent`, etc.) conforming directly to standard schema configurations.
61
+ - **`BasicCatalog`**: Factory provider initializing standard schemas and layout parameters.
62
+
63
+ #### 6. Symmetrical Schemas (`src/a2ui/core/schema`)
64
+
65
+ - **Pydantic Message Wrappers**: Compiled Pydantic models representing `A2uiMessage`, envelopes, and capabilities configuration structures.
66
+ - **`constants`**: Spec constants defining default reachability links and single/list component reference parameters.
67
+
68
+ ## Development & Testing
69
+
70
+ We use [uv](https://github.com/astral-sh/uv) for extremely fast and reliable environment management and task execution.
71
+
72
+ ### Setup Environment
73
+
74
+ To synchronize the virtual environment and dependencies, run the following from the `agent_sdks/python` directory:
75
+
76
+ ```bash
77
+ uv sync
78
+ ```
79
+
80
+ ### Running Tests
81
+
82
+ Run all unit, conformance, and structural integrity test suites:
83
+
84
+ ```bash
85
+ # From the package directory (agent_sdks/python/a2ui_core)
86
+ uv run pytest
87
+ ```
88
+
89
+ ### Code Formatting
90
+
91
+ Format and lint source files before committing changes:
92
+
93
+ ```bash
94
+ uv run pyink .
95
+ ```
@@ -0,0 +1,42 @@
1
+ # Copyright 2026 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
+ # http://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
+ [project]
16
+ name = "a2ui-core"
17
+ version = "0.0.1"
18
+ description = "A2UI Python SDK - Core Library"
19
+ readme = "README.md"
20
+ requires-python = ">=3.14"
21
+ dependencies = [
22
+ "jsonschema>=4.26.0",
23
+ "pydantic>=2.10.0",
24
+ "referencing>=0.37.0",
25
+ ]
26
+
27
+ [dependency-groups]
28
+ dev = [
29
+ "pytest>=8.0.0",
30
+ "pyink>=24.10.0",
31
+ ]
32
+
33
+ [build-system]
34
+ requires = ["hatchling"]
35
+ build-backend = "hatchling.build"
36
+
37
+ [tool.hatch.build.targets.wheel]
38
+ packages = ["src/a2ui"]
39
+
40
+ [[tool.uv.index]]
41
+ url = "https://pypi.org/simple"
42
+ default = true