Metadata-Version: 2.5
Name: zygo-sdk
Version: 0.1.2
Summary: Python client for Zygo — warm, isolated sandboxes for function-shaped code
Project-URL: Homepage, https://github.com/mhmtskrc2/zygo
Project-URL: Source, https://github.com/mhmtskrc2/zygo/tree/main/sdk/python
Author: Zygo contributors
License-Expression: Apache-2.0
License-File: LICENSE
License-File: NOTICE
Keywords: agent,container,isolation,sandbox,serverless
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Interpreters
Classifier: Topic :: System :: Systems Administration
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# zygo — Python client

Warm, isolated sandboxes for function-shaped code. A warm function costs about
a millisecond and gets a clean process per request.

```bash
pip install zygo-sdk      # then `import zygo_sdk`
```

```python
import zygo_sdk as zygo

client = zygo.connect()                 # `zygo api`, on loopback or a unix socket
resize = client.fn("resize")            # a function declared in sandbox.toml

out = resize({"url": "https://example.com/a.png"})
print(out.result, out.metrics.wall_ms)
```

Asynchronous, which is what an agent framework needs — the same methods,
every one a coroutine:

```python
import asyncio
import zygo_sdk as zygo

async def main(events):
    async with zygo.aio.connect() as client:
        return await asyncio.gather(*(client.call("resize", e) for e in events))

asyncio.run(main([{"url": "https://example.com/a.png"}]))
```

A refused request can be retried for you. `Busy` (the pool was full) and
`Unavailable` (the host is still building or warming something) both mean the
request never ran, so sending it again is safe; nothing else is retried:

```python
client = zygo.connect(retries=3)        # waits the server's Retry-After, then again
```

A one-shot sandbox, needing nothing declared in advance:

```python
r = client.run("python:3.12-slim", ["python3", "-c", "print(6 * 7)"], mem="128M")
print(r.stdout)
```

**No dependencies.** The standard library has an HTTP client, and a unix socket
is thirty lines on top of it.

Full documentation: [docs/book/17-api-sdk-mcp.md](../../docs/book/17-api-sdk-mcp.md). The project:
[zygo](../../README.md).

## Tests

```bash
python -m unittest discover -s tests
```

They run against a stand-in API and need no Linux, no kernel and no sandbox:
what is under test is the client. A test that needs a real sandbox belongs in
the Rust suites, against a real kernel.
