xovis-sdk 0.0.1 → 1.0.0-a10

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 (185) hide show
  1. package/.env.example +9 -0
  2. package/.github/CODEOWNERS +14 -0
  3. package/.github/PULL_REQUEST_TEMPLATE.md +31 -0
  4. package/.github/workflows/ci.yml +80 -0
  5. package/.github/workflows/docs.yml +0 -0
  6. package/.github/workflows/publish.yml +68 -0
  7. package/CONTRIBUTING.md +66 -0
  8. package/LICENSE +21 -0
  9. package/README.md +282 -0
  10. package/docs/ai/agentic_layer.md +134 -0
  11. package/docs/ai/img/ai_privacy.png +0 -0
  12. package/docs/ai/img/ai_tool_safety.png +0 -0
  13. package/docs/ai/img/fleet_explorer.png +0 -0
  14. package/docs/ai/img/fleet_list.png +0 -0
  15. package/docs/ai/img/push_studio.png +0 -0
  16. package/docs/ai/mcp.md +87 -0
  17. package/docs/api/hub_device_ref.md +50 -0
  18. package/docs/api/hub_license_ref.md +50 -0
  19. package/docs/api/index.md +42 -0
  20. package/docs/api/python/core.md +39 -0
  21. package/docs/api/python/datapush.md +31 -0
  22. package/docs/api/python/device.md +26 -0
  23. package/docs/api/python/hub.md +16 -0
  24. package/docs/api/python/skills.md +17 -0
  25. package/docs/api/reference.md +50 -0
  26. package/docs/architecture.md +147 -0
  27. package/docs/assets/images/logo.jpg +0 -0
  28. package/docs/cli.md +97 -0
  29. package/docs/contributing/agent_instructions.md +66 -0
  30. package/docs/contributing/engineering_guidelines.md +104 -0
  31. package/docs/index.md +82 -0
  32. package/docs/llms-small.txt +15 -0
  33. package/docs/llms.txt +29 -0
  34. package/docs/project_structure.md +222 -0
  35. package/docs/recipes/langgraph_congestion_control.md +39 -0
  36. package/docs/stylesheets/extra.css +107 -0
  37. package/docs/troubleshooting_ai.md +28 -0
  38. package/docs_check.txt +0 -0
  39. package/examples/01_edge_basics.py +85 -0
  40. package/examples/02_telemetry_pipeline.py +66 -0
  41. package/examples/03_topology_and_state.py +67 -0
  42. package/examples/04_fleet_orchestration.py +75 -0
  43. package/examples/README.md +59 -0
  44. package/mkdocs.yml +117 -0
  45. package/package.json +22 -6
  46. package/pyproject.toml +150 -0
  47. package/requirements.txt +20 -0
  48. package/scripts/docs/llms-full.txt +7 -0
  49. package/scripts/docs/llms-small.txt +15 -0
  50. package/scripts/docs/llms.txt +29 -0
  51. package/scripts/generate_ai_context.py +145 -0
  52. package/scripts/prepare_docs.py +45 -0
  53. package/scripts/sync_models.py +150 -0
  54. package/scripts/sync_project_structure.py +116 -0
  55. package/scripts/test_docs.py +88 -0
  56. package/smithery.yaml +63 -0
  57. package/src/xovis/__init__.py +5 -0
  58. package/src/xovis/api/core/__init__.py +0 -0
  59. package/src/xovis/api/core/auth.py +251 -0
  60. package/src/xovis/api/core/exceptions.py +125 -0
  61. package/src/xovis/api/core/http.py +283 -0
  62. package/src/xovis/api/core/tui.py +513 -0
  63. package/src/xovis/api/device/__init__.py +0 -0
  64. package/src/xovis/api/device/cache.py +827 -0
  65. package/src/xovis/api/device/client.py +654 -0
  66. package/src/xovis/api/device/discovery.py +159 -0
  67. package/src/xovis/api/device/models.py +70 -0
  68. package/src/xovis/api/device/resources/__init__.py +0 -0
  69. package/src/xovis/api/device/resources/analytics.py +561 -0
  70. package/src/xovis/api/device/resources/datapush.py +639 -0
  71. package/src/xovis/api/device/resources/history.py +191 -0
  72. package/src/xovis/api/device/resources/images.py +135 -0
  73. package/src/xovis/api/device/resources/itxpt.py +193 -0
  74. package/src/xovis/api/device/resources/network.py +397 -0
  75. package/src/xovis/api/device/resources/privacy.py +250 -0
  76. package/src/xovis/api/device/resources/scene.py +492 -0
  77. package/src/xovis/api/device/resources/system.py +281 -0
  78. package/src/xovis/api/device/resources/time_config.py +144 -0
  79. package/src/xovis/api/device/resources/update.py +281 -0
  80. package/src/xovis/api/device/resources/users.py +135 -0
  81. package/src/xovis/api/device/sync.py +119 -0
  82. package/src/xovis/api/device/topology.py +443 -0
  83. package/src/xovis/api/hub/__init__.py +0 -0
  84. package/src/xovis/api/hub/cache.py +355 -0
  85. package/src/xovis/api/hub/client.py +215 -0
  86. package/src/xovis/api/hub/resources/__init__.py +0 -0
  87. package/src/xovis/api/hub/resources/base.py +80 -0
  88. package/src/xovis/api/hub/resources/hub_device.py +111 -0
  89. package/src/xovis/api/hub/resources/hub_license.py +63 -0
  90. package/src/xovis/api/hub/sync.py +107 -0
  91. package/src/xovis/cli.py +820 -0
  92. package/src/xovis/config.py +35 -0
  93. package/src/xovis/datapush/__init__.py +0 -0
  94. package/src/xovis/datapush/http_server.py +136 -0
  95. package/src/xovis/datapush/mqtt_client.py +124 -0
  96. package/src/xovis/datapush/sinks.py +51 -0
  97. package/src/xovis/datapush/tcp_client.py +128 -0
  98. package/src/xovis/datapush/tcp_server.py +150 -0
  99. package/src/xovis/datapush/transmission_check.py +328 -0
  100. package/src/xovis/datapush/udp_server.py +144 -0
  101. package/src/xovis/datapush/utils.py +88 -0
  102. package/src/xovis/device_state.json.example +27 -0
  103. package/src/xovis/mcp/README.md +72 -0
  104. package/src/xovis/mcp/server.py +144 -0
  105. package/src/xovis/models/__init__.py +178 -0
  106. package/src/xovis/models/device.py +1145 -0
  107. package/src/xovis/models/device_auto/DeviceManagementService.py +63 -0
  108. package/src/xovis/models/device_auto/DoorStateService.py +19 -0
  109. package/src/xovis/models/device_auto/PassengerCountingService.py +19 -0
  110. package/src/xovis/models/device_auto/__init__.py +19 -0
  111. package/src/xovis/models/device_auto/versions/v5_9_11/DeviceManagementService.py +47 -0
  112. package/src/xovis/models/device_auto/versions/v5_9_11/DoorStateService.py +13 -0
  113. package/src/xovis/models/device_auto/versions/v5_9_11/PassengerCountingService.py +13 -0
  114. package/src/xovis/models/device_auto/versions/v5_9_11/__init__.py +5488 -0
  115. package/src/xovis/models/device_auto/versions/v5_9_2/DeviceManagementService.py +47 -0
  116. package/src/xovis/models/device_auto/versions/v5_9_2/DoorStateService.py +13 -0
  117. package/src/xovis/models/device_auto/versions/v5_9_2/PassengerCountingService.py +13 -0
  118. package/src/xovis/models/device_auto/versions/v5_9_2/__init__.py +5488 -0
  119. package/src/xovis/models/hub_auto.py +112 -0
  120. package/src/xovis/models/hub_device.py +113 -0
  121. package/src/xovis/models/hub_license_auto.py +82 -0
  122. package/src/xovis/skills/README.md +95 -0
  123. package/src/xovis/skills/__init__.py +21 -0
  124. package/src/xovis/skills/crewai_adapter.py +67 -0
  125. package/src/xovis/skills/langchain_adapter.py +61 -0
  126. package/src/xovis/skills/toolkit.py +910 -0
  127. package/src/xovis/tui/app.py +151 -0
  128. package/src/xovis/tui/screens/ai_privacy.py +334 -0
  129. package/src/xovis/tui/screens/bucket_modal.py +138 -0
  130. package/src/xovis/tui/screens/confirm_modal.py +89 -0
  131. package/src/xovis/tui/screens/device_dashboard.py +109 -0
  132. package/src/xovis/tui/screens/fleet_explorer.py +749 -0
  133. package/src/xovis/tui/screens/scanner_modal.py +104 -0
  134. package/src/xovis/tui/widgets/datapush_studio.py +1396 -0
  135. package/src/xovis/utils/__init__.py +6 -0
  136. package/src/xovis/utils/loop.py +47 -0
  137. package/src/xovis/utils/privacy.py +121 -0
  138. package/src/xovis/utils/time.py +79 -0
  139. package/tests/README.md +108 -0
  140. package/tests/__init__.py +0 -0
  141. package/tests/api/__init__.py +0 -0
  142. package/tests/api/device/__init__.py +0 -0
  143. package/tests/api/device/test_analytics.py +138 -0
  144. package/tests/api/device/test_cache_persistence.py +132 -0
  145. package/tests/api/device/test_cp_datapush_crud.py +240 -0
  146. package/tests/api/device/test_cp_datapush_limits.py +172 -0
  147. package/tests/api/device/test_cp_datapush_stateless.py +505 -0
  148. package/tests/api/device/test_cp_datapush_triggers.py +413 -0
  149. package/tests/api/device/test_cp_licenses.py +54 -0
  150. package/tests/api/device/test_history.py +41 -0
  151. package/tests/api/device/test_itxpt.py +80 -0
  152. package/tests/api/device/test_network.py +114 -0
  153. package/tests/api/device/test_privacy.py +135 -0
  154. package/tests/api/device/test_scene.py +117 -0
  155. package/tests/api/device/test_spider_granularity.py +92 -0
  156. package/tests/api/device/test_system.py +61 -0
  157. package/tests/api/device/test_time.py +74 -0
  158. package/tests/api/device/test_update.py +57 -0
  159. package/tests/api/device/test_users.py +84 -0
  160. package/tests/api/device/test_xovistime_integration.py +77 -0
  161. package/tests/api/hub/test_hub_devices.py +99 -0
  162. package/tests/api/hub/test_hub_licenses.py +64 -0
  163. package/tests/api/hub/test_hub_resources_e2e.py +213 -0
  164. package/tests/api/skills/test_toolkit_dynamic.py +272 -0
  165. package/tests/api/skills/test_toolkit_privacy.py +110 -0
  166. package/tests/api/test_cache_complete.py +301 -0
  167. package/tests/api/test_routing.py +65 -0
  168. package/tests/api/utils/test_privacy_session.py +103 -0
  169. package/tests/api/utils/test_time_parser.py +141 -0
  170. package/tests/conftest.py +386 -0
  171. package/tests/datapush/__init__.py +0 -0
  172. package/tests/datapush/conftest.py +71 -0
  173. package/tests/datapush/dp_validation_sink.py +123 -0
  174. package/tests/datapush/test_dp_data_alignment.py +230 -0
  175. package/tests/datapush/test_dp_matrix_universal.py +363 -0
  176. package/tests/datapush/test_dp_mqtt_client.py +133 -0
  177. package/tests/datapush/test_dp_server_compliance.py +182 -0
  178. package/tests/datapush/test_dp_sink_protocol.py +43 -0
  179. package/tests/datapush/test_dp_tcp_raw_parsing.py +96 -0
  180. package/tests/mcp/test_mcp_server_privacy.py +77 -0
  181. package/tests/test_tui_fleet.py +337 -0
  182. package/tests/verify_examples.py +86 -0
  183. package/uv.lock +4890 -0
  184. /package/{__init__.py → src/__init__.py} +0 -0
  185. /package/{setup.py → src/xovis/api/__init__.py} +0 -0
package/.env.example ADDED
@@ -0,0 +1,9 @@
1
+ # Xovis HUB Cloud Credentials
2
+ XOVIS_HUB_CLIENT_ID=your_client_id
3
+ XOVIS_HUB_CLIENT_SECRET=your_client_secret
4
+ XOVIS_HUB_BASE_URL=https://hub.xovis.com
5
+
6
+ # Device Configuration
7
+ XOVIS_TEST_HOST=192.168.1.10
8
+ XOVIS_DEVICE_USERNAME=admin
9
+ XOVIS_DEVICE_PASSWORD=pass
@@ -0,0 +1,14 @@
1
+ # .github/CODEOWNERS
2
+ # This file defines the owners of various paths in the repository.
3
+
4
+ # Default owners
5
+ * @xovis-dev
6
+
7
+ # Core SDK Planes
8
+ /src/xovis/datapush/ @xovis-dev
9
+ /src/xovis/api/ @xovis-dev
10
+ /src/xovis/fleet/ @xovis-dev
11
+
12
+ # Infrastructure & Configuration
13
+ /pyproject.toml @xovis-dev
14
+ /.github/workflows/ @xovis-dev
@@ -0,0 +1,31 @@
1
+ # Description
2
+
3
+ Fixes # (issue)
4
+
5
+ Please include a summary of the change and which issue is fixed. Include relevant motivation and context.
6
+
7
+ ## Type of Change
8
+
9
+ - [ ] Bug fix (non-breaking change which fixes an issue)
10
+ - [ ] New feature (non-breaking change which adds functionality)
11
+ - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
12
+ - [ ] Documentation update
13
+ - [ ] Refactor
14
+
15
+ ## Architecture Plane
16
+
17
+ - [ ] Data Plane (`src/xovis/datapush/`)
18
+ - [ ] Control Plane (`src/xovis/api/`)
19
+ - [ ] State Plane (`src/xovis/fleet/`)
20
+ - [ ] Skill Plane (`src/xovis/skills/`)
21
+
22
+ ## Checklist:
23
+
24
+ - [ ] My code follows the Google-style docstring standards.
25
+ - [ ] I have performed a self-review of my own code.
26
+ - [ ] I have commented my code, particularly in hard-to-understand areas (sparingly).
27
+ - [ ] I have made corresponding changes to the documentation.
28
+ - [ ] My changes generate no new warnings.
29
+ - [ ] I have added tests that prove my fix is effective or that my feature works.
30
+ - [ ] New and existing unit tests pass locally with my changes.
31
+ - [ ] I have run `xovis-cli check-docs` and coverage is maintained.
@@ -0,0 +1,80 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+
8
+ env:
9
+ FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
10
+
11
+ jobs:
12
+ lint:
13
+ name: Lint & Format
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - name: Install uv
18
+ uses: astral-sh/setup-uv@v5
19
+ with:
20
+ enable-cache: true
21
+ - name: Set up Python
22
+ run: uv python install 3.12
23
+ - name: Run Ruff Check
24
+ run: uv run --extra test ruff check .
25
+ - name: Run Ruff Format Check
26
+ run: uv run --extra test ruff format --check .
27
+
28
+ test:
29
+ name: Test (Python ${{ matrix.python-version }})
30
+ runs-on: ubuntu-latest
31
+ strategy:
32
+ fail-fast: false
33
+ matrix:
34
+ python-version: ["3.11", "3.12", "3.13", "3.14"]
35
+ env:
36
+ XOVIS_TEST_HOST: ${{ secrets.XOVIS_TEST_HOST }}
37
+ XOVIS_TEST_USER: ${{ secrets.XOVIS_TEST_USER }}
38
+ XOVIS_TEST_PASS: ${{ secrets.XOVIS_TEST_PASS }}
39
+ XOVIS_HUB_CLIENT_ID: ${{ secrets.XOVIS_HUB_CLIENT_ID }}
40
+ XOVIS_HUB_CLIENT_SECRET: ${{ secrets.XOVIS_HUB_CLIENT_SECRET }}
41
+ steps:
42
+ - uses: actions/checkout@v4
43
+ - name: Install uv
44
+ uses: astral-sh/setup-uv@v5
45
+ with:
46
+ enable-cache: true
47
+ - name: Set up Python ${{ matrix.python-version }}
48
+ run: uv python install ${{ matrix.python-version }}
49
+ - name: Run Non-Destructive Tests
50
+ run: uv run --extra all pytest tests/ -m "not destructive"
51
+ - name: Run Destructive Tests (Mocked)
52
+ run: uv run --extra all pytest tests/ -m "destructive"
53
+
54
+ cli-dry-run:
55
+ name: CLI Dry-Run
56
+ runs-on: ubuntu-latest
57
+ steps:
58
+ - uses: actions/checkout@v4
59
+ - name: Install uv
60
+ uses: astral-sh/setup-uv@v5
61
+ with:
62
+ enable-cache: true
63
+ - name: Set up Python
64
+ run: uv python install 3.12
65
+ - name: CLI Help Check
66
+ run: uv run xovis-cli --help
67
+
68
+ security:
69
+ name: Security Scan
70
+ runs-on: ubuntu-latest
71
+ steps:
72
+ - uses: actions/checkout@v4
73
+ - name: Install uv
74
+ uses: astral-sh/setup-uv@v5
75
+ with:
76
+ enable-cache: true
77
+ - name: Set up Python
78
+ run: uv python install 3.12
79
+ - name: Run Bandit Scan
80
+ run: uv run --extra test bandit -r src/ -ll
Binary file
@@ -0,0 +1,68 @@
1
+ name: Publish to PyPI, NPM, and Smithery
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ publish:
10
+ name: Upload release to PyPI, NPM, and Smithery
11
+ runs-on: ubuntu-latest
12
+ if: github.repository_owner == 'xovis-open-sdk' # Strict security guard to protect tenant execution
13
+ environment: pypi # Bound environment for trusted cryptographic identity tokens
14
+ permissions:
15
+ id-token: write
16
+ contents: read
17
+ steps:
18
+ - name: Checkout code
19
+ uses: actions/checkout@v4
20
+
21
+ # ==========================================
22
+ # 1. PYTHON / PYPI BUILD & PUBLISH
23
+ # ==========================================
24
+ - name: Install uv
25
+ uses: astral-sh/setup-uv@v5
26
+ with:
27
+ enable-cache: true
28
+
29
+ - name: Set up Python
30
+ run: uv python install 3.11
31
+
32
+ - name: Run Quality Check (Lint)
33
+ run: uv run --extra test ruff check .
34
+
35
+ - name: Run Quality Check (Tests)
36
+ run: uv run --extra all pytest tests/ -m "not destructive"
37
+
38
+ - name: Build Python package
39
+ run: uv build
40
+
41
+ - name: Publish package distributions to PyPI
42
+ uses: pypa/gh-action-pypi-publish@release/v1
43
+
44
+ # ==========================================
45
+ # 2. NODE / NPM BUILD & PUBLISH
46
+ # ==========================================
47
+ - name: Setup Node.js
48
+ uses: actions/setup-node@v4
49
+ with:
50
+ node-version: '24.x'
51
+
52
+ - name: Install Node Dependencies
53
+ run: npm ci || npm install
54
+
55
+ - name: Publish to NPM
56
+ # Node 24 & npm v11 automatically generate provenance and handle OIDC natively.
57
+ # No tokens are needed! We must specify '--tag next' when publishing prereleases to the registry.
58
+ run: npm publish --access public --tag next
59
+
60
+ # ==========================================
61
+ # 3. SMITHERY MCP REGISTRY PUBLISH
62
+ # ==========================================
63
+ - name: Publish to Smithery MCP Registry
64
+ # Dispatches the unified compilation payload to the Smithery indexing plane.
65
+ # This securely bridges our layer translations directly onto their consumer routing catalog.
66
+ run: npm run smithery:publish
67
+ env:
68
+ SMITHERY_API_KEY: ${{ secrets.SMITHERY_API_KEY }}
@@ -0,0 +1,66 @@
1
+ # Contributing to xovis-sdk
2
+
3
+ Thank you for your interest in contributing to the Xovis SDK! To maintain the high-performance and architectural integrity of this project, we have established the following guidelines.
4
+
5
+ ## Architectural Philosophy: The Quadrifurcation
6
+
7
+ The SDK is strictly divided into four distinct planes. **Never mix the design patterns of these planes:**
8
+
9
+ 1. **The Data Plane (`src/xovis/datapush/`)**: High-frequency ingestion. Use pure `asyncio`, no Pydantic validation in the hot path.
10
+ 2. **The Control Plane (`src/xovis/api/`)**: REST API wrappers. Enforce strict Pydantic CRUD and robust error handling.
11
+ 3. **The State Plane (`src/xovis/fleet/`)**: Topology-aware fleet management and caching.
12
+ 4. **The Skill Plane (`src/xovis/skills/`)**: AI-powered toolkit and MCP integrations.
13
+
14
+ ## Coding Standards
15
+
16
+ - **Google-Style Docstrings**: Every module, class, and public method MUST have a comprehensive Google-style docstring.
17
+ - **Type Hinting**: Use strict type hinting across the entire codebase.
18
+ - **Zero-Inline-Comments**: Code should be self-documenting. Use docstrings for architectural intent, not inline chatter.
19
+ - **Pydantic V2**: Use Pydantic V2 models for all API payloads and configurations.
20
+
21
+ ## Testing Requirements
22
+
23
+ - All new features must include tests.
24
+ - **Tier 1 (Smoke)**: Fast, non-destructive tests.
25
+ - **Tier 2 (CRUD)**: Stateful operations. Use `try...finally` for hard teardown.
26
+ - **Tier 3 (Data)**: Telemetry pipeline validation.
27
+ - Tests must be idempotent and respect hardware pacing delays.
28
+
29
+ ## Testing with Mocks (CI Safety)
30
+
31
+ Since physical Xovis hardware is not available in the CI environment, the SDK uses a **Mocked Device Layer** triggered automatically when hardware environment variables are missing.
32
+
33
+ - **Local Development**: Set `XOVIS_TEST_HOST`, `XOVIS_TEST_USER`, and `XOVIS_TEST_PASS` to run tests against real hardware.
34
+ - **CI / Isolated Testing**: Omit these variables to use the `unittest.mock` based surrogate defined in `tests/conftest.py`.
35
+ - **Stateless Tests**: Prefer using `respx` for fine-grained HTTP lifecycle validation as demonstrated in `tests/api/device/test_cp_datapush_stateless.py`.
36
+
37
+ ## Pull Request Process
38
+
39
+ 1. **Branching**: Create a feature branch from `main`.
40
+ 2. **Linting**: Run `ruff check .` and `ruff format .` before submitting.
41
+ 3. **Documentation**: Verify docstring coverage using `xovis-cli check-docs`.
42
+ 4. **Security**: Ensure no sensitive data (MAC addresses, API keys) is included in tests or code.
43
+ 5. **Review**: All PRs require at least one approval from a code owner.
44
+
45
+ ## Safety Guardrails
46
+
47
+ When developing, leverage the `XovisSafetyGuardrail`. Destructive operations (factory reset, network changes) are marked as `CRITICAL` and require human-in-the-loop confirmation.
48
+
49
+ ### 5. Proper & DRY Standards
50
+ To ensure the SDK maintains professional standards and isn't "dissed" by senior developers, we enforce strict code quality rules:
51
+
52
+ * **DRY (Don't Repeat Yourself)**: Shared logic (e.g., ID resolution) MUST be refactored into base classes (like `HubResourceManager`) or utility modules.
53
+ * **Static Typing**: All public APIs MUST have type hints. Use `mypy` for verification.
54
+ * **Linting**: Use `ruff` for ultra-fast linting and import sorting.
55
+ * **Security**: Use `bandit` to catch common security pitfalls.
56
+ * **Documentation**: Every public class and method MUST have a Google-style docstring.
57
+
58
+ #### Quality Audit Tool
59
+ Run the unified quality audit before submitting any PR:
60
+ ```bash
61
+ python scripts/check_quality.py
62
+ ```
63
+ This script aggregates results from Ruff, MyPy, Pylint (DRY check), Bandit, and the internal Docstring Audit.
64
+
65
+ ---
66
+ *By contributing to this project, you agree that your contributions will be licensed under the project's license.*
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Xovis Open SDK
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,282 @@
1
+ # Xovis SDK
2
+
3
+ <div align="center">
4
+
5
+ | **Core SDK** | **Integrations** | **Agentic Layer** |
6
+ |:---:|:---:|:---:|
7
+ | [![PyPI version](https://badge.fury.io/py/xovis-sdk.svg)](https://pypi.org/project/xovis-sdk/1.0.0a10/) | [![Smithery: Verified](https://img.shields.io/badge/Smithery-Placeholder-orange)](https://smithery.ai/server/xovis-sdk) | [![MCP Ready](https://img.shields.io/badge/MCP-Ready-5B32A8.svg?logo=server&logoColor=white)](https://modelcontextprotocol.io/) |
8
+ | [![GitHub](https://img.shields.io/badge/GitHub-xovis--sdk-181717?logo=github)](https://github.com/xovis-open-sdk/xovis-sdk) | [![OpenAI Compatible](https://img.shields.io/badge/OpenAI-Compatible-412991.svg?logo=openai&logoColor=white)](https://openai.com/) | [![LangGraph Ready](https://img.shields.io/badge/LangGraph-Ready-1C3C3C.svg?logo=langchain&logoColor=white)](https://langchain.com/) |
9
+ | [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) | [![Anthropic Compatible](https://img.shields.io/badge/Anthropic-Compatible-D2B8A3.svg?logo=anthropic&logoColor=black)](https://www.anthropic.com/) | [![CrewAI Ready](https://img.shields.io/badge/CrewAI-Ready-FF4B4B.svg?logo=google-cloud&logoColor=white)](https://crewai.com/) |
10
+ | [![npm version](https://badge.fury.io/js/xovis-sdk.svg)](https://badge.fury.io/js/xovis-sdk) | [![Smithery: Install](https://img.shields.io/badge/Smithery-Install--Pending-white)](https://smithery.ai/server/xovis-sdk) | [![Cursor Optimized](https://img.shields.io/badge/Cursor-Optimized-000000.svg?logo=python&logoColor=white)](https://cursor.sh/) |
11
+
12
+ </div>
13
+
14
+ An enterprise-grade integration SDK for Xovis 3D Sensors and the Xovis HUB Cloud infrastructure.
15
+
16
+ **[Read the Full Documentation →](https://xovis-open-sdk.github.io/xovis-sdk/)**
17
+
18
+ **Compliance Note:** This project is an independent, open-source initiative. It is not officially affiliated with, maintained by, or endorsed by Xovis AG.
19
+
20
+ ---
21
+
22
+ ## ⚠️ Xovis HUB Cloud Compatibility & Rate Limits
23
+
24
+ This SDK is architected for enterprise-scale fleet orchestration. Due to the high concurrency of the `HubClient` and `bulk_execute` methods, a **Xovis HUB Pro** subscription is strongly suggested by the development team. Operating the SDK on the free tier may result in aggressive HTTP 429 Rate Limit exhaustion, which will disrupt automated provisioning and telemetry pipelines.
25
+
26
+ ---
27
+
28
+ ## Overview
29
+
30
+ Integrating native Xovis DataPush protocols and REST APIs into enterprise data pipelines typically requires substantial boilerplate, complex state management, and strict network handling to maintain real-time DataPush ingestion (up to 12.5Hz).
31
+
32
+ This SDK abstracts the complexities of the Xovis hardware into a unified, modern, and type-safe "Universal Translator" architecture. It completely decouples raw edge telemetry from downstream infrastructure, enabling engineers to focus strictly on spatial analytics, fleet orchestration, and data warehousing.
33
+
34
+ ### System Data Flow
35
+
36
+ ```mermaid
37
+ graph TB
38
+ subgraph "Xovis Hardware Layer"
39
+ direction TB
40
+ A[Physical Sensors / Spiders]
41
+ H[Xovis HUB Cloud]
42
+ H -- Secure Proxy Tunnel (M2M) --> A
43
+ end
44
+
45
+ subgraph "Data Plane (High Frequency)"
46
+ B[XovisTCPServer / XovisUDPServer / XovisHTTPServer]
47
+ S[XovisSink]
48
+ end
49
+
50
+ subgraph "Control & State Plane (SDK Core)"
51
+ C[DeviceClient]
52
+ F[HubClient]
53
+ D[HostStateBucket / ConfigCache]
54
+
55
+ F -- "connect_device()" --> C
56
+ C <--> D
57
+ end
58
+
59
+ subgraph "Agentic & Tooling Layer"
60
+ G[XovisAIToolkit]
61
+ M[MCP Server / Model Context Protocol]
62
+ R[REPLAccessor / CLI]
63
+ end
64
+
65
+ %% Data Connections
66
+ A -->|Live-Push up to 12.5Hz| B
67
+ B -->|Sliding Buffer Extraction| S
68
+
69
+ %% Control Connections
70
+ A <-->|Local REST API v5| C
71
+ H <-->|Hub REST API| F
72
+
73
+ %% Fleet Integration
74
+ D -. "Reflect State" .-> R
75
+ F -. "Fleet Sync" .-> D
76
+
77
+ %% AI Integration
78
+ D --- G
79
+ F --- G
80
+ G --- M
81
+ M --- LLM[LLM / Autonomous Agents]
82
+
83
+ %% Styling
84
+ style A fill:#1e293b,stroke:#38bdf8,stroke-width:2px
85
+ style H fill:#1e293b,stroke:#38bdf8,stroke-width:2px
86
+ style B fill:#0f172a,stroke:#2dd4bf,stroke-width:2px
87
+ style C fill:#0f172a,stroke:#2dd4bf,stroke-width:2px
88
+ style F fill:#0f172a,stroke:#2dd4bf,stroke-width:2px
89
+ style G fill:#1e293b,stroke:#818cf8,stroke-width:2px
90
+ style M fill:#1e293b,stroke:#818cf8,stroke-width:2px
91
+ ```
92
+
93
+ ## Architectural Pillars
94
+
95
+ The SDK is strictly quadrifurcated to prevent blocking the asynchronous Python event loop during high-frequency operations while enabling autonomous systems:
96
+
97
+ 1. **The Data Plane:** A zero-copy, lock-free telemetry ingestion engine. Bypasses standard JSON validation in the hot path, converting edge data (TCP, UDP Datagrams, and HTTP Webhooks) directly into optimized structures for downstream sinks. Supports **Live-Push (up to 12.5Hz)** coordinates and minutely **Logic-Push** events.
98
+ 2. **The Control Plane:** A resilient, asynchronous HTTP engine wrapping the Xovis Edge and HUB APIs. It implements a version-agnostic **Manual Bridge Layer** that abstracts firmware-specific JSON variations into stable SDK properties. Supports complex Custom Logic (RPN filters, age histograms), spatial entities (Lines, Masks, Blocked Spaces), core business logic (Logics, Layers, ObjectTypes), high-frequency DataPush pipelines (Agents, Connections, manual triggers), automated OAuth2 token lifecycles, proactive hardware capability probing, intelligent error mapping for hardware-level restrictions (HTTP 403), and strict Pydantic V2 schema enforcement.
99
+ 3. **The Topology & State Plane:** A memory-efficient graph engine. It models complex multisensor parent-/child relations and provides an **offline-first Native State Bucket**. It features **Firmware Autonomy** via a passive discovery crawler that identifies unknown hardware API fields during synchronization, ensuring the "Universal Translator" remains compatible with new releases.
100
+ 4. **The Agentic Layer (AI Toolkit):** A Universal Tool Adapter leveraging Pydantic V2 to expose SDK methods as strictly validated JSON schemas or asynchronous callable primitives. This grants autonomous orchestration capabilities to modern AI frameworks and LLMs natively. Includes the **Native Bucket Memory Plane** for zero-latency hardware observation.
101
+
102
+ ## Core Capabilities & API Preview
103
+
104
+ ### 1. Fleet Orchestration (Cloud Hub)
105
+
106
+ Execute resilient, concurrent operations across an entire filtered fleet utilizing secure Xovis HUB Cloud tunnels with built-in fault isolation.
107
+
108
+ ```python
109
+ from xovis.api.hub.client import HubClient
110
+
111
+ async def update_timezone(device):
112
+ """Callback function mapped across the fleet."""
113
+ return await device.time.update({"time_zone": "Europe/Zurich"})
114
+
115
+ async def main():
116
+ target_filter = {"customerName": "RetailCorp", "categories": ["Region-DACH"]}
117
+
118
+ async with HubClient(client_id="...", client_secret="...", fleet_filter=target_filter) as hub:
119
+ results = await hub.bulk_execute(update_timezone)
120
+
121
+ for mac, result in results.items():
122
+ if isinstance(result, Exception):
123
+ print(f"Failed on {mac}: {result}")
124
+
125
+ ```
126
+
127
+ ### 2. Topology-Aware Edge Configuration (Offline-First)
128
+
129
+ Interact natively with hardware topologies using the **Native State Bucket**. The SDK automatically distinguishes between physical lenses (`singlesensor`) and virtual stitched environments (`multisensors`), resolving human-readable names to internal IDs via a zero-network-penalty cache.
130
+
131
+ **DX:** Every collection (agents, logics, geometries, etc.) features a `.by_name` accessor for instant dot-notation discovery and IDE autosuggestions, eliminating the need for brittle ID management.
132
+
133
+ #### Offline-First Persistence
134
+ The SDK features a non-blocking configuration cache that can be persisted to disk to enable instant "Cold Starts" and resilience against temporary network failures.
135
+
136
+ * **Explicit:** `auto_persist_path="./state.json"` (Single file)
137
+ * **Managed:** `persistence_dir="./states/"` (Auto-organized by MAC address)
138
+
139
+ ```python
140
+ from xovis.api.device.client import DeviceClient
141
+ from xovis.models.device_auto import SceneGeometry
142
+
143
+ async def configure_edge():
144
+ # Cache Watcher and auto-persistence initiate securely in the background
145
+ # Note: Default username is "admin"
146
+ async with DeviceClient("10.0.0.50", "admin", "password", auto_persist_path="./state.json") as device:
147
+
148
+ # Proactive hardware capability probing prevents silent exceptions
149
+ if await device.has_analytics:
150
+ # DOT-NOTATION DISCOVERY: The cache resolves the human-readable "Main Entrance" instantly
151
+ # All resources (agents, connections, logics, zones) are exposed via .by_name
152
+ zone = device.cache.zones.by_name.Main_Entrance
153
+
154
+ # Discovery also works for state buckets (contexts) via .buckets
155
+ # This provides full IDE autosuggestion for physical and virtual environments
156
+ ss = device.cache.buckets.singlesensor
157
+
158
+ # Operations scale seamlessly to complex multisensor graphs
159
+ terminal_b = device.cache.multisensors.by_name.Terminal_B
160
+ await terminal_b.analytics.delete_logic("Legacy Count")
161
+
162
+ # Access historical counts for auditing
163
+ # XovisTime supports relative ('-1d'), ISO 8601 (with offsets), and datetime objects
164
+ history = await device.singlesensor.history.get_counts(
165
+ start_time="-1d", end_time="now", resolution="60"
166
+ )
167
+
168
+ ```
169
+
170
+ ### 3. High-Frequency Telemetry Ingestion
171
+
172
+ Deploy lock-free receiver pipelines that ingest and offload raw spatial coordinates without bottlenecking the Python event loop. The SDK natively supports `XovisTCPServer`, `XovisHTTPServer` (Webhooks), and `XovisUDPServer` (Datagrams), exposing a clean `XovisSink` protocol for proprietary downstream integration.
173
+
174
+ ```python
175
+ from xovis.datapush.tcp_server import XovisTCPServer
176
+ from xovis.datapush.sinks import XovisSink
177
+
178
+
179
+ class StandardOutputSink(XovisSink):
180
+ """Custom implementation for processing edge data datapush."""
181
+
182
+ async def on_frame(self, frame: dict) -> None:
183
+ # Process ingested frame here
184
+ print(f"Ingested frame with {len(frame.get('tracked_objects', []))} objects.")
185
+
186
+ async def on_events(self, events: list) -> None:
187
+ pass
188
+
189
+
190
+ async def start_telemetry():
191
+ server = XovisTCPServer(host="0.0.0.0", port=49156)
192
+
193
+ # Attach your custom downstream processor
194
+ server.attach_sink(StandardOutputSink())
195
+
196
+ await server.start()
197
+
198
+ ```
199
+ ### 4. Autonomous AI Orchestration (Agentic Layer)
200
+
201
+ Transform the physical hardware into an AI-controllable node. The SDK provides the most sophisticated AI integration in the market:
202
+ * **Universal Tool Adapter**: A dynamic reflection engine that crawls SDK managers at runtime, projecting Google-style docstrings and Pydantic V2 schemas for OpenAI, Anthropic, LangChain, and CrewAI.
203
+ * **Model Context Protocol (MCP)**: Standardized bridge for desktop agents like Claude and Cursor.
204
+ * **Native Bucket Memory Plane**: State-of-the-art compression algorithm using the offline-first bucket to reduce context window tokens by up to 40% for massive fleet observation.
205
+ * **Safety Guardrails**: Enterprise-grade "Immune System" with hardcoded safety policies (BLOCKED, CRITICAL, RESTRICTED) and explicit confirmation signatures.
206
+ * **Privacy & Pseudonymization**: The **AI Privacy Engine** (`AIPrivacySession`) implements two-way pseudonymization for automatic data scrubbing, ensuring the LLM only interacts with session-bound hashes while the toolkit restores real identifiers (MACs, Names) during execution.
207
+ * **WAF & Privacy Blocks**: Built-in handling for `HTTP 403` HTML responses, identifying when requests are blocked by the Xovis HUB, Sensor, Spider, or Privacy Mode (Modes 3 & 4).
208
+ * **Resource Aggregation**: Intelligent context-awareness that automatically aggregates analytics, spatial telemetry (`aggregate_heat_map`, `aggregate_height_map`), geometries, and history across all `active_contexts`.
209
+ * **Adaptive Pacing Engine**: Built-in congestion control that adjusts request delays (0.2s for LAN, 1.0s for Cloud) to respect rate limits and prevent hardware saturation.
210
+ * **AI Safety TUI**: A dedicated management interface (`xovis-cli gui`) for configuring granular field-level privacy toggles and persistent tool-to-safety-level mappings.
211
+ * **Strict Concurrency & Scalability**: Enforced 350-device threshold for State Buckets and Agent Authorization Scopes for zero-trust fleet isolation.
212
+
213
+ ```python
214
+ import json
215
+ from xovis.api.device.client import DeviceClient
216
+ from xovis.api.hub.client import HubClient
217
+ from xovis.skills.toolkit import XovisAIToolkit, XovisAgentMemory
218
+
219
+ async def autonomous_agent():
220
+ # 1. Edge-Level Orchestration
221
+ async with DeviceClient("10.0.0.50", "admin", "password") as device:
222
+ # Native Bucket Memory provides zero-latency context with 40% better token efficiency
223
+ memory = XovisAgentMemory(device.cache._state)
224
+ context = memory.get_compressed_state()
225
+
226
+ toolkit = XovisAIToolkit(device)
227
+
228
+ # Seamlessly inject Xovis capabilities into GPT-5.5
229
+ response = await openai.chat.completions.create(
230
+ model="gpt-5.5",
231
+ messages=[
232
+ {"role": "system", "content": f"Current Device State: {context}"},
233
+ {"role": "user", "content": "Reboot the sensor."}
234
+ ],
235
+ tools=toolkit.get_openai_tools()
236
+ )
237
+
238
+ # 2. Fleet-Level Orchestration
239
+ async with HubClient(client_id="...", client_secret="...") as hub:
240
+ fleet_toolkit = XovisAIToolkit(hub)
241
+
242
+ # Execute fleet-wide operations with a single LLM tool call
243
+ # The adaptive pacing (1.0s) ensures we don't saturate the Cloud HUB tunnel
244
+ await fleet_toolkit.execute_tool("fleet_reboot", {"confirmation": True})
245
+
246
+ ```
247
+
248
+ ### Model Context Protocol (MCP)
249
+
250
+ The Xovis SDK includes a first-class MCP server, allowing AI agents (like Claude Desktop and Cursor) to directly orchestrate hardware.
251
+
252
+ **Quick Install with Smithery:**
253
+ [![Smithery Install](https://img.shields.io/badge/Smithery-Install-orange.svg)](https://smithery.ai/server/xovis-sdk)
254
+
255
+ Alternatively, install manually: `npx -y smithery install xovis-sdk`
256
+
257
+ ## Developer Experience & Type Safety (CLI)
258
+
259
+ The SDK is designed for maximum developer ergonomics. It includes a native CLI tool to extract topology data from an offline sensor cache, generating strict Python `Literal` types for perfect IDE autocompletion.
260
+
261
+ Features include zero-dependency ANSI color outputs, generation analytics ("the receipt"), `--dry-run` safety, dynamic path resolution, and native `ruff` formatting integration.
262
+
263
+ ```bash
264
+ # Generate static types
265
+ xovis-cli generate-types --source ./device_state.json
266
+
267
+ # Launch Xovis Open SDK Mission Control TUI
268
+ xovis-cli ui
269
+
270
+ # Launch Xovis Open SDK Datapush Studio TUI
271
+ xovis-cli datapush --protocol TCP --port 9000
272
+ ```
273
+
274
+ ## Enterprise Testing & Contribution
275
+
276
+ We welcome contributions from systems engineers and data scientists. The `xovis-sdk` adheres to the absolute highest tier of enterprise SDET standards:
277
+
278
+ 1. **The 4-Tier SDET Matrix:** The SDK is guarded by a comprehensive Software Development Engineer in Test (SDET) suite, strictly isolated into Smoke (Stateless - including `XovisTime` normalization), Stateful Configuration (CRUD - consolidated Tier 2), Data Plane (High-Frequency), and Endurance/Integrity (Validation).
279
+ 2. **Strict Idempotency:** All E2E hardware tests (`@pytest.mark.destructive`) execute a pre-flight state sweep and guarantee a hard teardown via strict `try...finally` boundaries to prevent physical hardware exhaustion.
280
+ 3. **Clean Code Philosophy (Zero-Comment, Max-Docstring):** The codebase strictly prohibits inline developer chatter. Architectural intent, Pydantic constraints, and plane boundaries are formalized exclusively through rigorous Google-style docstrings.
281
+
282
+ Please ensure all PRs pass the GitHub Actions CI pipeline (`ruff format`, `ruff check`, and `-m "not destructive"`) before requesting a review.