agentix-deployment-docker 0.1.1__py3-none-any.whl

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.
@@ -0,0 +1,122 @@
1
+ """Docker deployment: sandbox CRUD via local Docker.
2
+
3
+ Design:
4
+
5
+ Bundle images are produced by `agentix build` and are self-contained:
6
+ they ship the runtime + every namespace's Python package in one venv,
7
+ plus any system deps under `/nix`. The deployment runs the bundle
8
+ image directly — no volume populate, no mount-and-merge, no custom
9
+ entrypoint.
10
+
11
+ Sandbox create:
12
+ docker run -d --name <sid> --network host \\
13
+ -e AGENTIX_BIND_PORT=<port> \\
14
+ <bundle-image>
15
+
16
+ The container's `ENTRYPOINT` is `agentix-server`, which binds to the
17
+ port from the env var. We pick a free host port, pass it through, and
18
+ health-check `/health` on it.
19
+ """
20
+
21
+ from __future__ import annotations
22
+
23
+ import asyncio
24
+ import logging
25
+ import socket
26
+ from uuid import uuid4
27
+
28
+ import httpx
29
+
30
+ from agentix.deployment.base import Deployment, Sandbox
31
+ from agentix.idents import SandboxId
32
+ from agentix.models import SandboxConfig, SandboxInfo
33
+
34
+ logger = logging.getLogger("agentix.deployment.docker")
35
+
36
+
37
+ async def _docker(*args: str, check: bool = True) -> tuple[int, bytes, bytes]:
38
+ proc = await asyncio.create_subprocess_exec(
39
+ "docker", *args,
40
+ stdout=asyncio.subprocess.PIPE,
41
+ stderr=asyncio.subprocess.PIPE,
42
+ )
43
+ stdout, stderr = await proc.communicate()
44
+ rc = proc.returncode or 0
45
+ if check and rc != 0:
46
+ raise RuntimeError(f"docker {args[0]} failed: {stderr.decode(errors='replace')}")
47
+ return rc, stdout, stderr
48
+
49
+
50
+ class DockerDeployment(Deployment):
51
+ """Sandbox CRUD via local Docker."""
52
+
53
+ def __init__(self):
54
+ self._ports: dict[SandboxId, int] = {} # sandbox_id → host port
55
+
56
+ @staticmethod
57
+ def _allocate_port() -> int:
58
+ # Ask the kernel for any free TCP port. There's still a small
59
+ # TOCTOU window before the container binds, but no worse than a
60
+ # linear probe and without the seed parameter.
61
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
62
+ s.bind(("127.0.0.1", 0))
63
+ return s.getsockname()[1]
64
+
65
+ async def create(self, config: SandboxConfig) -> Sandbox:
66
+ sandbox_id = SandboxId(f"agentix-{uuid4().hex[:8]}")
67
+ port = self._allocate_port()
68
+
69
+ env_args: list[str] = ["-e", f"AGENTIX_BIND_PORT={port}"]
70
+ if config.env:
71
+ for k, v in config.env.items():
72
+ env_args.extend(["-e", f"{k}={v}"])
73
+
74
+ await _docker(
75
+ "run", "-d",
76
+ "--name", sandbox_id,
77
+ "--network", "host",
78
+ *env_args,
79
+ config.image,
80
+ )
81
+
82
+ self._ports[sandbox_id] = port
83
+ logger.info("Created sandbox %s on port %d", sandbox_id, port)
84
+
85
+ await self._wait_healthy(port)
86
+ return Sandbox(
87
+ sandbox_id=sandbox_id,
88
+ runtime_url=f"http://localhost:{port}",
89
+ status="running",
90
+ )
91
+
92
+ async def _wait_healthy(self, port: int) -> None:
93
+ base_url = f"http://localhost:{port}"
94
+ async with httpx.AsyncClient(base_url=base_url, timeout=60) as client:
95
+ for _ in range(120):
96
+ try:
97
+ r = await client.get("/health")
98
+ if r.status_code == 200:
99
+ return
100
+ except (httpx.ConnectError, httpx.ReadError, httpx.RemoteProtocolError):
101
+ pass
102
+ await asyncio.sleep(0.5)
103
+ raise TimeoutError(f"Runtime server not alive at {base_url}")
104
+
105
+ async def get(self, sandbox_id: SandboxId) -> SandboxInfo:
106
+ port = self._ports.get(sandbox_id)
107
+ if port is None:
108
+ raise KeyError(f"Sandbox not found: {sandbox_id}")
109
+ rc, stdout, _ = await _docker(
110
+ "inspect", "-f", "{{.State.Status}}", sandbox_id, check=False,
111
+ )
112
+ status = stdout.decode().strip() if rc == 0 else "unknown"
113
+ return SandboxInfo(
114
+ sandbox_id=sandbox_id,
115
+ runtime_url=f"http://localhost:{port}",
116
+ status=status,
117
+ )
118
+
119
+ async def delete(self, sandbox_id: SandboxId) -> None:
120
+ await _docker("rm", "-f", sandbox_id, check=False)
121
+ self._ports.pop(sandbox_id, None)
122
+ logger.info("Deleted sandbox %s", sandbox_id)
@@ -0,0 +1,60 @@
1
+ Metadata-Version: 2.4
2
+ Name: agentix-deployment-docker
3
+ Version: 0.1.1
4
+ Summary: Docker deployment backend for Agentix
5
+ Project-URL: Homepage, https://github.com/Agentiix/Agentix-Deployment-Docker
6
+ Author: Agentiix
7
+ License: MIT
8
+ License-File: LICENSE
9
+ Requires-Python: >=3.11
10
+ Requires-Dist: agentixx>=0.1.0
11
+ Requires-Dist: httpx>=0.27
12
+ Provides-Extra: dev
13
+ Requires-Dist: pyright>=1.1.380; extra == 'dev'
14
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
15
+ Requires-Dist: pytest>=8; extra == 'dev'
16
+ Requires-Dist: ruff>=0.6; extra == 'dev'
17
+ Description-Content-Type: text/markdown
18
+
19
+ # agentix-deployment-docker
20
+
21
+ Docker deployment backend for [Agentix](https://github.com/Agentiix/Agentix).
22
+
23
+ Provisions a sandbox by running an Agentix bundle image in a local
24
+ Docker daemon, returns the runtime URL the orchestrator's
25
+ `RuntimeClient` connects to.
26
+
27
+ ## Install
28
+
29
+ ```bash
30
+ pip install agentix-deployment-docker
31
+ ```
32
+
33
+ ## Use
34
+
35
+ ```python
36
+ from agentix import RuntimeClient, SandboxConfig
37
+ from agentix.deployment.docker import DockerDeployment
38
+
39
+ async with DockerDeployment().lifecycle(
40
+ SandboxConfig(image="my-agent:0.1.0")
41
+ ) as sandbox:
42
+ async with RuntimeClient(sandbox.runtime_url) as c:
43
+ ...
44
+ ```
45
+
46
+ Or via the CLI:
47
+
48
+ ```bash
49
+ agentix deploy local --image my-agent:0.1.0
50
+ ```
51
+
52
+ The `local` name comes from the entry point this wheel declares under
53
+ `agentix.deployment` — once installed, the framework discovers it
54
+ automatically. No core-framework changes are required to register a new
55
+ backend; the same pattern works for `agentix-deployment-daytona`,
56
+ `agentix-deployment-e2b`, or any third-party backend.
57
+
58
+ ## License
59
+
60
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,6 @@
1
+ agentix/deployment/docker.py,sha256=5REOsUa8cfgRLEvfSU-kUEcZYCnlt-J-lx6Vv7-hL_o,4196
2
+ agentix_deployment_docker-0.1.1.dist-info/METADATA,sha256=cAq_fZYmsPz2qPxW1fSNrjZfwdOy5jMylSLRYNld6Os,1638
3
+ agentix_deployment_docker-0.1.1.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
4
+ agentix_deployment_docker-0.1.1.dist-info/entry_points.txt,sha256=XZvz5CURq-FLRHLq03zO6OtK05fwu_pZhh3i83MfD0M,72
5
+ agentix_deployment_docker-0.1.1.dist-info/licenses/LICENSE,sha256=mt35xkyIDkKZlEgxp-WYN0zaNDhtZtYtagSi6rMQmXg,1065
6
+ agentix_deployment_docker-0.1.1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.29.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [agentix.deployment]
2
+ local = agentix.deployment.docker:DockerDeployment
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Agentiix
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.