xenfra-sdk 0.2.2__tar.gz → 0.2.4__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 (41) hide show
  1. xenfra_sdk-0.2.4/PKG-INFO +116 -0
  2. xenfra_sdk-0.2.4/README.md +82 -0
  3. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/pyproject.toml +54 -37
  4. xenfra_sdk-0.2.4/src/xenfra_sdk/__init__.py +61 -0
  5. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/cli/main.py +226 -226
  6. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/client.py +90 -90
  7. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/config.py +26 -26
  8. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/db/models.py +24 -24
  9. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/db/session.py +30 -30
  10. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/dependencies.py +39 -39
  11. xenfra_sdk-0.2.4/src/xenfra_sdk/detection.py +396 -0
  12. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/dockerizer.py +195 -194
  13. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/engine.py +741 -619
  14. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/exceptions.py +19 -19
  15. xenfra_sdk-0.2.4/src/xenfra_sdk/manifest.py +212 -0
  16. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/mcp_client.py +154 -154
  17. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/models.py +184 -184
  18. xenfra_sdk-0.2.4/src/xenfra_sdk/orchestrator.py +666 -0
  19. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/patterns.json +13 -13
  20. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/privacy.py +153 -153
  21. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/recipes.py +26 -26
  22. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/resources/base.py +3 -3
  23. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/resources/deployments.py +278 -248
  24. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/resources/files.py +101 -101
  25. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/resources/intelligence.py +102 -95
  26. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/security.py +41 -41
  27. xenfra_sdk-0.2.4/src/xenfra_sdk/security_scanner.py +431 -0
  28. xenfra_sdk-0.2.4/src/xenfra_sdk/templates/Caddyfile.j2 +14 -0
  29. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/templates/Dockerfile.j2 +41 -38
  30. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/templates/cloud-init.sh.j2 +90 -90
  31. xenfra_sdk-0.2.4/src/xenfra_sdk/templates/docker-compose-multi.yml.j2 +29 -0
  32. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/templates/docker-compose.yml.j2 +30 -30
  33. xenfra_sdk-0.2.2/PKG-INFO +0 -118
  34. xenfra_sdk-0.2.2/README.md +0 -91
  35. xenfra_sdk-0.2.2/src/xenfra_sdk/__init__.py +0 -21
  36. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/cli/__init__.py +0 -0
  37. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/client_with_hooks.py +0 -0
  38. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/db/__init__.py +0 -0
  39. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/resources/__init__.py +0 -0
  40. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/resources/projects.py +0 -0
  41. {xenfra_sdk-0.2.2 → xenfra_sdk-0.2.4}/src/xenfra_sdk/utils.py +0 -0
@@ -0,0 +1,116 @@
1
+ Metadata-Version: 2.3
2
+ Name: xenfra-sdk
3
+ Version: 0.2.4
4
+ Summary: Xenfra SDK: Core engine and utilities for the Xenfra platform.
5
+ Author: xenfra-cloud
6
+ Author-email: xenfra-cloud <xenfracloud@gmail.com>
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Topic :: Software Development :: Build Tools
13
+ Classifier: Topic :: System :: Systems Administration
14
+ Requires-Dist: fabric>=3.2.2
15
+ Requires-Dist: python-digitalocean>=1.17.0
16
+ Requires-Dist: python-dotenv>=1.2.1
17
+ Requires-Dist: rich>=14.2.0
18
+ Requires-Dist: sqlmodel>=0.0.16
19
+ Requires-Dist: pyyaml>=6.0.1
20
+ Requires-Dist: httpx>=0.27.0
21
+ Requires-Dist: jinja2>=3.1.3
22
+ Requires-Dist: python-jose[cryptography]>=3.3.0
23
+ Requires-Dist: passlib>=1.7.4
24
+ Requires-Dist: cryptography>=41.0.0
25
+ Requires-Dist: pytest>=8.0.0 ; extra == 'dev'
26
+ Requires-Dist: pytest-mock>=3.12.0 ; extra == 'dev'
27
+ Requires-Dist: pytest-cov>=4.0.0 ; extra == 'dev'
28
+ Requires-Dist: pytest-asyncio>=0.21.0 ; extra == 'dev'
29
+ Requires-Python: >=3.11
30
+ Project-URL: Homepage, https://github.com/xenfra-cloud/xenfra-sdk
31
+ Project-URL: Issues, https://github.com/xenfra-cloud/xenfra-sdk/issues
32
+ Provides-Extra: dev
33
+ Description-Content-Type: text/markdown
34
+
35
+ # Xenfra SDK (The Engine) 📦
36
+
37
+ [![PyPI](https://img.shields.io/pypi/v/xenfra-sdk)](https://pypi.org/project/xenfra-sdk/)
38
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
39
+ [![Python](https://img.shields.io/pypi/pyversions/xenfra-sdk.svg)](https://pypi.org/project/xenfra-sdk/)
40
+
41
+ The core infrastructure automation engine behind **Xenfra** (The Sovereign Cloud OS). This SDK provides the primitives for deploying, managing, and diagnosing applications on DigitalOcean with "Zen Mode" auto-healing.
42
+
43
+ ## 🚀 Features
44
+
45
+ - **InfraEngine**: A robust 9-phase deployment pipeline (Setup -> Asset Gen -> Droplet -> Code -> Build -> Health).
46
+ - **Dockerizer**: Deterministic Dockerfile and Compose generation using Jinja2 templates.
47
+ - **Zen Mode**: Utilities to automatically heal common failures (e.g., locked dpkg, exhausted ports).
48
+ - **Privacy-First**: Built-in PII scrubbing for logs before they touch any AI services.
49
+ - **Security**: Fernet encryption for tokens and RS256 JWT validation helpers.
50
+
51
+ ## 📦 Installation
52
+
53
+ ```bash
54
+ pip install xenfra-sdk
55
+ # or with uv
56
+ uv add xenfra-sdk
57
+ ```
58
+
59
+ ## 🛠️ Usage
60
+
61
+ ### 1. Initialize the Engine
62
+
63
+ ```python
64
+ from xenfra_sdk import XenfraClient, InfraEngine
65
+
66
+ # Authenticate (Token usually comes from the CLI)
67
+ client = XenfraClient(token="xenfra_...")
68
+ engine = InfraEngine(client)
69
+ ```
70
+
71
+ ### 2. Deploy a Project
72
+
73
+ ```python
74
+ project_path = "/path/to/my-fastapi-app"
75
+
76
+ # The engine handles detection (Python/Node), dockerization, and provisioning
77
+ deployment = await engine.deploy(
78
+ path=project_path,
79
+ project_id="proj_123",
80
+ env_vars={"DATABASE_URL": "..."}
81
+ )
82
+
83
+ print(f"🚀 Deployed successfully to: http://{deployment.ip_address}")
84
+ ```
85
+
86
+ ### 3. Diagnose a Failure
87
+
88
+ ```python
89
+ from xenfra_sdk.intelligence import diagnose_failure
90
+
91
+ logs = client.deployments.get_logs(deployment.id)
92
+ analysis = await diagnose_failure(logs)
93
+
94
+ print(f"Diagnosis: {analysis.root_cause}")
95
+ print(f"Suggested Fix: {analysis.suggestion}")
96
+ ```
97
+
98
+ ## 🔗 The Xenfra Ecosystem
99
+
100
+ This SDK is the "Body" of the Xenfra Open Core architecture:
101
+
102
+ - **[xenfra-cli](https://github.com/xenfracloud/xenfra-cli)**: The Terminal Interface (Uses this SDK).
103
+ - **[xenfra-mcp](https://github.com/xenfracloud/xenfra-mcp)**: The AI Agent Interface (Uses this SDK).
104
+ - **xenfra-platform**: The Private SaaS Backend (Uses this SDK).
105
+
106
+ ## 🤝 Contributing
107
+
108
+ We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.
109
+
110
+ 1. Clone: `git clone https://github.com/xenfracloud/xenfra-sdk`
111
+ 2. Install: `uv sync`
112
+ 3. Test: `pytest`
113
+
114
+ ## 📄 License
115
+
116
+ MIT © [Xenfra Cloud](https://xenfra.tech)
@@ -0,0 +1,82 @@
1
+ # Xenfra SDK (The Engine) 📦
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/xenfra-sdk)](https://pypi.org/project/xenfra-sdk/)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![Python](https://img.shields.io/pypi/pyversions/xenfra-sdk.svg)](https://pypi.org/project/xenfra-sdk/)
6
+
7
+ The core infrastructure automation engine behind **Xenfra** (The Sovereign Cloud OS). This SDK provides the primitives for deploying, managing, and diagnosing applications on DigitalOcean with "Zen Mode" auto-healing.
8
+
9
+ ## 🚀 Features
10
+
11
+ - **InfraEngine**: A robust 9-phase deployment pipeline (Setup -> Asset Gen -> Droplet -> Code -> Build -> Health).
12
+ - **Dockerizer**: Deterministic Dockerfile and Compose generation using Jinja2 templates.
13
+ - **Zen Mode**: Utilities to automatically heal common failures (e.g., locked dpkg, exhausted ports).
14
+ - **Privacy-First**: Built-in PII scrubbing for logs before they touch any AI services.
15
+ - **Security**: Fernet encryption for tokens and RS256 JWT validation helpers.
16
+
17
+ ## 📦 Installation
18
+
19
+ ```bash
20
+ pip install xenfra-sdk
21
+ # or with uv
22
+ uv add xenfra-sdk
23
+ ```
24
+
25
+ ## 🛠️ Usage
26
+
27
+ ### 1. Initialize the Engine
28
+
29
+ ```python
30
+ from xenfra_sdk import XenfraClient, InfraEngine
31
+
32
+ # Authenticate (Token usually comes from the CLI)
33
+ client = XenfraClient(token="xenfra_...")
34
+ engine = InfraEngine(client)
35
+ ```
36
+
37
+ ### 2. Deploy a Project
38
+
39
+ ```python
40
+ project_path = "/path/to/my-fastapi-app"
41
+
42
+ # The engine handles detection (Python/Node), dockerization, and provisioning
43
+ deployment = await engine.deploy(
44
+ path=project_path,
45
+ project_id="proj_123",
46
+ env_vars={"DATABASE_URL": "..."}
47
+ )
48
+
49
+ print(f"🚀 Deployed successfully to: http://{deployment.ip_address}")
50
+ ```
51
+
52
+ ### 3. Diagnose a Failure
53
+
54
+ ```python
55
+ from xenfra_sdk.intelligence import diagnose_failure
56
+
57
+ logs = client.deployments.get_logs(deployment.id)
58
+ analysis = await diagnose_failure(logs)
59
+
60
+ print(f"Diagnosis: {analysis.root_cause}")
61
+ print(f"Suggested Fix: {analysis.suggestion}")
62
+ ```
63
+
64
+ ## 🔗 The Xenfra Ecosystem
65
+
66
+ This SDK is the "Body" of the Xenfra Open Core architecture:
67
+
68
+ - **[xenfra-cli](https://github.com/xenfracloud/xenfra-cli)**: The Terminal Interface (Uses this SDK).
69
+ - **[xenfra-mcp](https://github.com/xenfracloud/xenfra-mcp)**: The AI Agent Interface (Uses this SDK).
70
+ - **xenfra-platform**: The Private SaaS Backend (Uses this SDK).
71
+
72
+ ## 🤝 Contributing
73
+
74
+ We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.
75
+
76
+ 1. Clone: `git clone https://github.com/xenfracloud/xenfra-sdk`
77
+ 2. Install: `uv sync`
78
+ 3. Test: `pytest`
79
+
80
+ ## 📄 License
81
+
82
+ MIT © [Xenfra Cloud](https://xenfra.tech)
@@ -1,37 +1,54 @@
1
- [project]
2
- name = "xenfra-sdk"
3
- version = "0.2.2"
4
- description = "Xenfra SDK: Core engine and utilities for the Xenfra platform."
5
- readme = "README.md"
6
- authors = [
7
- { name = "xenfra-cloud", email = "xenfracloud@gmail.com" }
8
- ]
9
-
10
- classifiers = [
11
- "Programming Language :: Python :: 3",
12
- "License :: OSI Approved :: MIT License",
13
- "Operating System :: OS Independent",
14
- "Development Status :: 3 - Alpha",
15
- "Intended Audience :: Developers",
16
- "Topic :: Software Development :: Build Tools",
17
- "Topic :: System :: Systems Administration",
18
- ]
19
-
20
- dependencies = [
21
- "fabric>=3.2.2",
22
- "python-digitalocean>=1.17.0",
23
- "python-dotenv>=1.2.1",
24
- "rich>=14.2.0",
25
- "sqlmodel>=0.0.16",
26
- "PyYAML>=6.0.1",
27
- "httpx>=0.27.0",
28
- "Jinja2>=3.1.3",
29
- "python-jose[cryptography]>=3.3.0",
30
- "passlib>=1.7.4",
31
- "cryptography>=41.0.0",
32
- ]
33
- requires-python = ">=3.13"
34
-
35
- [build-system]
36
- requires = ["uv_build>=0.9.18,<0.10.0"]
37
- build-backend = "uv_build"
1
+ [project]
2
+ name = "xenfra-sdk"
3
+ version = "0.2.4"
4
+ description = "Xenfra SDK: Core engine and utilities for the Xenfra platform."
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "xenfra-cloud", email = "xenfracloud@gmail.com" }
8
+ ]
9
+
10
+ classifiers = [
11
+ "Programming Language :: Python :: 3",
12
+ "License :: OSI Approved :: MIT License",
13
+ "Operating System :: OS Independent",
14
+ "Development Status :: 3 - Alpha",
15
+ "Intended Audience :: Developers",
16
+ "Topic :: Software Development :: Build Tools",
17
+ "Topic :: System :: Systems Administration",
18
+ ]
19
+
20
+ dependencies = [
21
+ "fabric>=3.2.2",
22
+ "python-digitalocean>=1.17.0",
23
+ "python-dotenv>=1.2.1",
24
+ "rich>=14.2.0",
25
+ "sqlmodel>=0.0.16",
26
+ "PyYAML>=6.0.1",
27
+ "httpx>=0.27.0",
28
+ "Jinja2>=3.1.3",
29
+ "python-jose[cryptography]>=3.3.0",
30
+ "passlib>=1.7.4",
31
+ "cryptography>=41.0.0",
32
+ ]
33
+ requires-python = ">=3.11"
34
+
35
+ [project.urls]
36
+ Homepage = "https://github.com/xenfra-cloud/xenfra-sdk"
37
+ Issues = "https://github.com/xenfra-cloud/xenfra-sdk/issues"
38
+
39
+ [project.optional-dependencies]
40
+ dev = [
41
+ "pytest>=8.0.0",
42
+ "pytest-mock>=3.12.0",
43
+ "pytest-cov>=4.0.0",
44
+ "pytest-asyncio>=0.21.0"
45
+ ]
46
+
47
+ [tool.pytest.ini_options]
48
+ asyncio_mode = "auto"
49
+ testpaths = ["tests"]
50
+ python_files = ["test_*.py"]
51
+
52
+ [build-system]
53
+ requires = ["uv_build>=0.9.18,<0.10.0"]
54
+ build-backend = "uv_build"
@@ -0,0 +1,61 @@
1
+ # This file makes src/xenfra_sdk a Python package.
2
+
3
+ from .client import XenfraClient
4
+ from .exceptions import AuthenticationError, XenfraAPIError, XenfraError
5
+ from .models import (
6
+ CodebaseAnalysisResponse,
7
+ DiagnosisResponse,
8
+ PatchObject,
9
+ ProjectRead,
10
+ )
11
+
12
+ # Microservices support
13
+ from .manifest import (
14
+ ServiceDefinition,
15
+ load_services_from_xenfra_yaml,
16
+ is_microservices_project,
17
+ get_deployment_mode,
18
+ add_services_to_xenfra_yaml,
19
+ create_services_from_detected,
20
+ )
21
+ from .detection import (
22
+ auto_detect_services,
23
+ detect_docker_compose_services,
24
+ detect_pyproject_services,
25
+ )
26
+ from .orchestrator import (
27
+ ServiceOrchestrator,
28
+ get_orchestrator_for_project,
29
+ )
30
+
31
+ # Security
32
+ from .security_scanner import (
33
+ scan_directory,
34
+ scan_file_list,
35
+ ScanResult,
36
+ SecurityIssue,
37
+ Severity,
38
+ )
39
+
40
+ __all__ = [
41
+ "XenfraClient",
42
+ "XenfraError",
43
+ "AuthenticationError",
44
+ "XenfraAPIError",
45
+ "DiagnosisResponse",
46
+ "CodebaseAnalysisResponse",
47
+ "PatchObject",
48
+ "ProjectRead",
49
+ # Microservices
50
+ "ServiceDefinition",
51
+ "load_services_from_xenfra_yaml",
52
+ "is_microservices_project",
53
+ "get_deployment_mode",
54
+ "add_services_to_xenfra_yaml",
55
+ "create_services_from_detected",
56
+ "auto_detect_services",
57
+ "detect_docker_compose_services",
58
+ "detect_pyproject_services",
59
+ "ServiceOrchestrator",
60
+ "get_orchestrator_for_project",
61
+ ]