Metadata-Version: 2.4
Name: leap0-adk
Version: 0.1.0
Summary: Leap0 plugin for Google ADK (sandbox, Python code interpreter, filesystem)
Author: Leap0
License: Apache-2.0
Project-URL: Homepage, https://github.com/leap0/leap0-adk-plugin
Project-URL: Repository, https://github.com/leap0/leap0-adk-plugin
Keywords: adk,leap0,sandbox,plugin,google-adk
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: google-adk>=0.1.0
Requires-Dist: leap0>=0.8
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Requires-Dist: google-adk[extensions]>=0.1.0; extra == "dev"
Provides-Extra: openrouter
Requires-Dist: google-adk[extensions]>=0.1.0; extra == "openrouter"
Dynamic: license-file

# leap0-adk

Google ADK plugin for running **Python** in a [Leap0](https://leap0.dev) sandbox using the [code interpreter](https://leap0.dev/docs/code-interpreter), plus filesystem read, write, list, and delete. One sandbox is shared by all tools for the lifetime of the plugin.

## Install

```bash
pip install leap0-adk
```

Dependencies: `google-adk`, `leap0` (Python SDK).

## Configuration

Set your Leap0 API key (or pass `api_key=` to `Leap0Plugin`):

```bash
export LEAP0_API_KEY="your-key"
```

Optional: `LEAP0_BASE_URL` if you use a non-default control plane.

## Usage

Always delete the sandbox when your agent session ends so you do not leave sandboxes running.

```python
import asyncio

from google.adk.agents import Agent
from google.adk.runners import InMemoryRunner
from leap0_adk import Leap0Plugin


async def main() -> None:
    plugin = Leap0Plugin()
    try:
        agent = Agent(
            model="gemini-2.0-flash",
            name="leap0_agent",
            tools=plugin.get_tools(),
        )
        async with InMemoryRunner(
            app_name="my_app",
            agent=agent,
            plugins=[plugin],
        ) as runner:
            await runner.run_debug(
                "Run Python: x = 40 + 2; print(x). Then write the result to /tmp/answer.txt and read it back."
            )
    finally:
        plugin.destroy_sandbox()
        await plugin.close()


if __name__ == "__main__":
    asyncio.run(main())
```

`destroy_sandbox()` calls the Leap0 API to delete the sandbox. `close()` also deletes the sandbox and, if the plugin created the `Leap0Client` itself, closes the HTTP client.

## Examples

Runnable scripts live under [examples/](examples/). They use **Gemini via OpenRouter** (`OPENROUTER_API_KEY`, `pip install 'leap0-adk[openrouter]'`). See [examples/README.md](examples/README.md).

## Tools

| Tool | Purpose |
|------|---------|
| `execute_code_in_leap0` | Python via `code_interpreter.execute` (optional `context_id`, `timeout_ms`, `env_vars`) |
| `leap0_fs_read` | Read UTF-8 file (`path`, optional `offset` / `limit` / `head` / `tail`) |
| `leap0_fs_write` | Write UTF-8 file (`path`, `content`, optional `permissions`) |
| `leap0_fs_list` | Directory listing (`path`, optional `recursive`, `exclude`) |
| `leap0_fs_delete` | Delete file or directory (`path`, optional `recursive`) |

TypeScript/JavaScript execution is not exposed in this version (Python only).

## Development

```bash
pip install -e ".[dev]"
pytest
```

## License

Apache-2.0 (see [LICENSE](LICENSE)).
