agentix-deployment-docker 0.1.0__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.
- agentix_deployment_docker-0.1.0/.gitignore +18 -0
- agentix_deployment_docker-0.1.0/LICENSE +21 -0
- agentix_deployment_docker-0.1.0/PKG-INFO +60 -0
- agentix_deployment_docker-0.1.0/README.md +42 -0
- agentix_deployment_docker-0.1.0/agentix/deployment/docker.py +122 -0
- agentix_deployment_docker-0.1.0/pyproject.toml +58 -0
|
@@ -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.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentix-deployment-docker
|
|
3
|
+
Version: 0.1.0
|
|
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: agentix>=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,42 @@
|
|
|
1
|
+
# agentix-deployment-docker
|
|
2
|
+
|
|
3
|
+
Docker deployment backend for [Agentix](https://github.com/Agentiix/Agentix).
|
|
4
|
+
|
|
5
|
+
Provisions a sandbox by running an Agentix bundle image in a local
|
|
6
|
+
Docker daemon, returns the runtime URL the orchestrator's
|
|
7
|
+
`RuntimeClient` connects to.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install agentix-deployment-docker
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Use
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from agentix import RuntimeClient, SandboxConfig
|
|
19
|
+
from agentix.deployment.docker import DockerDeployment
|
|
20
|
+
|
|
21
|
+
async with DockerDeployment().lifecycle(
|
|
22
|
+
SandboxConfig(image="my-agent:0.1.0")
|
|
23
|
+
) as sandbox:
|
|
24
|
+
async with RuntimeClient(sandbox.runtime_url) as c:
|
|
25
|
+
...
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Or via the CLI:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
agentix deploy local --image my-agent:0.1.0
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The `local` name comes from the entry point this wheel declares under
|
|
35
|
+
`agentix.deployment` — once installed, the framework discovers it
|
|
36
|
+
automatically. No core-framework changes are required to register a new
|
|
37
|
+
backend; the same pattern works for `agentix-deployment-daytona`,
|
|
38
|
+
`agentix-deployment-e2b`, or any third-party backend.
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -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,58 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "agentix-deployment-docker"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Docker deployment backend for Agentix"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "Agentiix" }]
|
|
13
|
+
urls = { Homepage = "https://github.com/Agentiix/Agentix-Deployment-Docker" }
|
|
14
|
+
dependencies = [
|
|
15
|
+
# `Sandbox`, `Deployment` Protocol, `SandboxConfig`, `SandboxInfo`,
|
|
16
|
+
# and the `SandboxId` branded NewType all live in core Agentix.
|
|
17
|
+
"agentix>=0.1.0",
|
|
18
|
+
# The backend talks to dockerd over a unix socket via httpx (which
|
|
19
|
+
# core agentix already pulls in, but we declare it explicitly so
|
|
20
|
+
# `pip install agentix-deployment-docker` is self-sufficient).
|
|
21
|
+
"httpx>=0.27",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
[project.optional-dependencies]
|
|
25
|
+
dev = [
|
|
26
|
+
"pytest>=8",
|
|
27
|
+
"pytest-asyncio>=0.23",
|
|
28
|
+
"ruff>=0.6",
|
|
29
|
+
"pyright>=1.1.380",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
# `pip install agentix-deployment-docker` makes `agentix deploy local`
|
|
33
|
+
# work with zero framework changes — the framework walks this group
|
|
34
|
+
# at startup and routes the `local` backend name to DockerDeployment.
|
|
35
|
+
[project.entry-points."agentix.deployment"]
|
|
36
|
+
local = "agentix.deployment.docker:DockerDeployment"
|
|
37
|
+
|
|
38
|
+
[tool.hatch.build.targets.wheel]
|
|
39
|
+
# Ship one file at `agentix/deployment/docker.py`. The directory has
|
|
40
|
+
# no __init__.py in this wheel — that file is owned by core Agentix
|
|
41
|
+
# and pip installs siblings into the same site-packages dir.
|
|
42
|
+
packages = ["agentix"]
|
|
43
|
+
|
|
44
|
+
[tool.ruff]
|
|
45
|
+
line-length = 120
|
|
46
|
+
target-version = "py311"
|
|
47
|
+
|
|
48
|
+
[tool.ruff.lint]
|
|
49
|
+
select = ["E", "F", "I", "W", "UP"]
|
|
50
|
+
|
|
51
|
+
[tool.pyright]
|
|
52
|
+
include = ["agentix"]
|
|
53
|
+
exclude = ["**/__pycache__", ".venv"]
|
|
54
|
+
typeCheckingMode = "basic"
|
|
55
|
+
pythonVersion = "3.11"
|
|
56
|
+
|
|
57
|
+
[tool.pytest.ini_options]
|
|
58
|
+
asyncio_mode = "auto"
|